Patchwork [1,of,7,V2,apply,on,date,fix] obsstore: add a `parents` field

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 19, 2014, 5:53 p.m.
Message ID <29f8c47a0222be4b34a1.1408470817@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5510/
State Superseded
Headers show

Comments

Pierre-Yves David - Aug. 19, 2014, 5:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1408403324 25200
#      Mon Aug 18 16:08:44 2014 -0700
# Node ID 29f8c47a0222be4b34a13394af03ac3319042778
# Parent  33d51be18d45556179966cd3d66833764f4c6de2
obsstore: add a `parents` field

This fields is intended to store the parent of the precursor. This is useful to
attache pruned changeset to a set of exchanged changesets. We currently just
add the fields with a None value. None stand for "no data recorded".

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -171,11 +171,11 @@  def _readmarkers(data):
         try:
             date = util.parsedate(decodemeta(metadata).pop('date', '0 0'))
         except util.Abort:
             date = (0., 0)
 
-        yield (pre, sucs, flags, metadata, date)
+        yield (pre, sucs, flags, metadata, date, None)
 
 def encodemeta(meta):
     """Return encoded metadata string to string mapping.
 
     Assume no ':' in key and no '\0' in both key and value."""
@@ -240,11 +240,11 @@  class obsstore(object):
     Markers can be accessed with two mappings:
     - precursors[x] -> set(markers on precursors edges of x)
     - successors[x] -> set(markers on successors edges of x)
     """
 
-    fields = ('prec', 'succs', 'flag', 'meta', 'date')
+    fields = ('prec', 'succs', 'flag', 'meta', 'date', 'parents')
 
     def __init__(self, sopener):
         # caches for various obsolescence related cache
         self.caches = {}
         self._all = []
@@ -293,11 +293,11 @@  class obsstore(object):
             if len(succ) != 20:
                 raise ValueError(succ)
         if prec in succs:
             raise ValueError(_('in-marker cycle with %s') % node.hex(prec))
         marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata),
-                  date)
+                  date, None)
         return bool(self.add(transaction, [marker]))
 
     def add(self, transaction, markers):
         """Add new markers to the store
 
@@ -357,11 +357,11 @@  def _encodemarkers(markers, addheader=Fa
     for marker in markers:
         yield _encodeonemarker(marker)
 
 
 def _encodeonemarker(marker):
-    pre, sucs, flags, metadata, date = marker
+    pre, sucs, flags, metadata, date, parents = marker
     metadata = decodemeta(metadata)
     metadata['date'] = '%d %i' % date
     metadata = encodemeta(metadata)
     nbsuc = len(sucs)
     format = _fmfixed + (_fmnode * nbsuc)