[PATCH fix-for-default] obsstore: record data as floating point in fm0 format

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 16 18:07:08 CDT 2014

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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).

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):

More information about the Mercurial-devel mailing list