evolve: extend obsstore object to use prune parent information
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 19 Feb 2014 17:27:45 -0800
changeset 806 895fadf6ba3e
parent 805 66c02a2e8e2f
child 807 4dd1cda16fd0
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.
hgext/evolve.py
--- 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                                                  ###
 #####################################################################