Patchwork [2,of,8] obsstore: add a `parents` field

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 19, 2014, 10:46 p.m.
Message ID <2b67de4393d277280d34.1408488400@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5517/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 19, 2014, 10:46 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 2b67de4393d277280d3483381ea4f1a7855b4bae
# Parent  4f98bcae042935c4b51336dfc5971458826bbcbf
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,16 +240,18 @@  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')
-    # prec:   nodeid, precursor changesets
-    # succes: tuple of nodeid, successors changesets (0-N length)
-    # flag:   integer, flag field carrying modifier for the markers (see doc)
-    # meta:   binary blob, encoded metadata dictionnary
-    # date:   (float, int) tuple, date of markers creation
+    fields = ('prec', 'succs', 'flag', 'meta', 'date', 'parents')
+    # prec:    nodeid, precursor changesets
+    # succes:  tuple of nodeid, successors changesets (0-N length)
+    # flag:    integer, flag field carrying modifier for the markers (see doc)
+    # meta:    binary blob, encoded metadata dictionnary
+    # date:    (float, int) tuple, date of markers creation
+    # parents: (tuple of nodeid) or None, parents of precursors.
+    #          None is used when no data have been recorded
 
     def __init__(self, sopener):
         # caches for various obsolescence related cache
         self.caches = {}
         self._all = []
@@ -298,11 +300,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
 
@@ -362,11 +364,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)