Patchwork [3,of,7] obsstore: keep track of children information

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 21, 2014, 3:20 a.m.
Message ID <0e700b1c54043586d946.1408591253@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5540/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 21, 2014, 3:20 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1408492433 25200
#      Tue Aug 19 16:53:53 2014 -0700
# Node ID 0e700b1c54043586d946b33202da450dc46f9c06
# Parent  2d424c3abcfb14aec61bf5d585cf847ea77e4470
obsstore: keep track of children information

We use the new `parents` fields to build a dictionary of markers that touch
children of a node. This will be used to link prune markers to a set of
exchanged nodes.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -263,10 +263,11 @@  class obsstore(object):
     """Store obsolete markers
 
     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)
+    - children[x]   -> set(markers on precursors edges of children(x)
     """
 
     fields = ('prec', 'succs', 'flag', 'meta', 'date', 'parents')
     # prec:    nodeid, precursor changesets
     # succes:  tuple of nodeid, successor changesets (0-N length)
@@ -280,10 +281,11 @@  class obsstore(object):
         # caches for various obsolescence related cache
         self.caches = {}
         self._all = []
         self.precursors = {}
         self.successors = {}
+        self.children = {}
         self.sopener = sopener
         data = sopener.tryread('obsstore')
         if data:
             self._load(_readmarkers(data))
 
@@ -374,10 +376,14 @@  class obsstore(object):
             self._all.append(mark)
             pre, sucs = mark[:2]
             self.successors.setdefault(pre, set()).add(mark)
             for suc in sucs:
                 self.precursors.setdefault(suc, set()).add(mark)
+            parents = mark[5]
+            if parents is not None:
+                for p in parents:
+                    self.children.setdefault(p, set()).add(mark)
         if node.nullid in self.precursors:
             raise util.Abort(_('bad obsolescence marker detected: '
                                'invalid successors nullid'))
 
 def _encodemarkers(markers, addheader=False):