changeset 22258:cf414981978a

obsstore: also store the 'parents' field on disk We now store the `parents` field on disk. We use the same strategy as for `date`: We stick it into the metadata. This is slow and dirty, but this is also the only way we currently have. At some point we'll have a new obsstore format to store this properly.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 18 Aug 2014 16:28:44 -0700
parents 4bc96685a40c
children 2e6f03a193f9
files mercurial/obsolete.py
diffstat 1 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Mon Aug 18 17:06:08 2014 -0700
+++ b/mercurial/obsolete.py	Mon Aug 18 16:28:44 2014 -0700
@@ -173,9 +173,28 @@
             date = util.parsedate(decodemeta(metadata).pop('date', '0 0'))
         except util.Abort:
             date = (0., 0)
+        parents = None
+        if 'p2' in meta:
+            parents = (meta.pop('p1', None), meta.pop('p2', None))
+        elif 'p1' in meta:
+            parents = (meta.pop('p1', None),)
+        elif 'p0' in meta:
+            parents = ()
+        if parents is not None:
+            try:
+                parents = tuple(node.bin(p) for p in parents)
+                # if parent content is not a nodeid, drop the data
+                for p in parents:
+                    if len(p) != 20:
+                        parents = None
+                        break
+            except TypeError:
+                # if content cannot be translated to nodeid drop the data.
+                parents = None
+
         metadata = encodemeta(meta)
 
-        yield (pre, sucs, flags, metadata, date, None)
+        yield (pre, sucs, flags, metadata, date, parents)
 
 def encodemeta(meta):
     """Return encoded metadata string to string mapping.
@@ -371,6 +390,12 @@
     pre, sucs, flags, metadata, date, parents = marker
     metadata = decodemeta(metadata)
     metadata['date'] = '%d %i' % date
+    if parents is not None:
+        if not parents:
+            # mark that we explicitly recorded no parents
+            metadata['p0'] = ''
+        for i, p in enumerate(parents, 1):
+            metadata['p%i' % i] = node.hex(p)
     metadata = encodemeta(metadata)
     nbsuc = len(sucs)
     format = _fmfixed + (_fmnode * nbsuc)