Patchwork obsstore: record data as floating point in fm0 format

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 16, 2014, 11:05 p.m.
Message ID <6f1411cda808c23be651.1413500728@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6351/
State Superseded
Headers show

Comments

Pierre-Yves David - Oct. 16, 2014, 11:05 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413495997 25200
#      Thu Oct 16 14:46:37 2014 -0700
# Node ID 6f1411cda808c23be651f5b3a22430365b98f588
# Parent  840be5ca03e1db16ba994e55597771c418166c97
obsstore: record data as floating point in fm0 format

For python struct module, "d" is double. But for python string formating, "d" is
integer. We want to preserve the float nature of the data. So we store it the
metadata as float. We use "%r" to make sure we get as much significant digitis as
necessary to restore the float to the exact same value on the other side.

The fm1 is transmitting the information as float. The lack of this makes
fm1-stored markers not survive a round-trip to fm0 leading to duplicated
markers (or two markers very alike).
Augie Fackler - Oct. 17, 2014, 2:12 p.m.
On Thu, Oct 16, 2014 at 04:05:28PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1413495997 25200
> #      Thu Oct 16 14:46:37 2014 -0700
> # Node ID 6f1411cda808c23be651f5b3a22430365b98f588
> # Parent  840be5ca03e1db16ba994e55597771c418166c97
> obsstore: record data as floating point in fm0 format

Looks like you sent this twice, so I'm going to ignore this one.

>
> For python struct module, "d" is double. But for python string formating, "d" is
> integer. We want to preserve the float nature of the data. So we store it the
> metadata as float. We use "%r" to make sure we get as much significant digitis as
> necessary to restore the float to the exact same value on the other side.
>
> The fm1 is transmitting the information as float. The lack of this makes
> fm1-stored markers not survive a round-trip to fm0 leading to duplicated
> markers (or two markers very alike).
>
> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
> --- a/mercurial/obsolete.py
> +++ b/mercurial/obsolete.py
> @@ -200,11 +200,12 @@ def _fm0readmarkers(data, off=0):
>  def _fm0encodeonemarker(marker):
>      pre, sucs, flags, metadata, date, parents = marker
>      if flags & usingsha256:
>          raise util.Abort(_('cannot handle sha256 with old obsstore format'))
>      metadata = dict(metadata)
> -    metadata['date'] = '%d %i' % date
> +    time, tz = date
> +    metadata['date'] = '%r %i' % (time, tz)
>      if parents is not None:
>          if not parents:
>              # mark that we explicitly recorded no parents
>              metadata['p0'] = ''
>          for i, p in enumerate(parents):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -200,11 +200,12 @@  def _fm0readmarkers(data, off=0):
 def _fm0encodeonemarker(marker):
     pre, sucs, flags, metadata, date, parents = marker
     if flags & usingsha256:
         raise util.Abort(_('cannot handle sha256 with old obsstore format'))
     metadata = dict(metadata)
-    metadata['date'] = '%d %i' % date
+    time, tz = date
+    metadata['date'] = '%r %i' % (time, tz)
     if parents is not None:
         if not parents:
             # mark that we explicitly recorded no parents
             metadata['p0'] = ''
         for i, p in enumerate(parents):