changeset 806:895fadf6ba3e

evolve: extend obsstore object to use prune parent information Now that we have the information, we can use it to build a mapping to access all marker that prune a children of a node. This is similar to what we do for successors and precursors. The performance impact is a few tens of second on my mercurial clone. Experimenting is worth the trouble.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 19 Feb 2014 17:27:45 -0800
parents 66c02a2e8e2f
children 4dd1cda16fd0
files hgext/evolve.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Thu Feb 13 18:09:54 2014 -0800
+++ b/hgext/evolve.py	Wed Feb 19 17:27:45 2014 -0800
@@ -325,6 +325,31 @@
 def createmarkers(*args, **kwargs):
     return obsolete.createmarkers(*args, **kwargs)
 
+class pruneobsstore(obsolete.obsstore):
+
+    def __init__(self, *args, **kwargs):
+        self.prunedchildren = {}
+        return super(pruneobsstore, self).__init__(*args, **kwargs)
+
+    def _load(self, markers):
+        markers = self._prunedetectingmarkers(markers)
+        return super(pruneobsstore, self)._load(markers)
+
+
+    def _prunedetectingmarkers(self, markers):
+        for m in markers:
+            if not m[1]: # no successors
+                meta = obsolete.decodemeta(m[3])
+                if 'p1' in meta:
+                    p1 = node.bin(meta['p1'])
+                    self.prunedchildren.setdefault(p1, set()).add(m)
+                if 'p2' in meta:
+                    p1 = node.bin(meta['p2'])
+                    self.prunedchildren.setdefault(p2, set()).add(m)
+            yield m
+
+obsolete.obsstore = pruneobsstore
+
 #####################################################################
 ### Critical fix                                                  ###
 #####################################################################