diff hgfastobs.py @ 795:c6888ec28e9e

copy precursor revset from evolve so we don't depend on involve
author Augie Fackler <raf@durin42.com>
date Sat, 16 Nov 2013 20:43:44 -0500
parents 089755743050
children 443e563f0943
line wrap: on
line diff
--- a/hgfastobs.py	Tue Sep 03 21:46:50 2013 +0200
+++ b/hgfastobs.py	Sat Nov 16 20:43:44 2013 -0500
@@ -24,8 +24,9 @@
 from mercurial import base85
 from mercurial import commands
 from mercurial import extensions
+from mercurial import node
 from mercurial import obsolete
-from mercurial import node
+from mercurial import revset
 from mercurial.i18n import _
 
 _strategies = {
@@ -57,6 +58,27 @@
     f = sys._getframe(4)
     return f.f_locals['outgoing']
 
+
+def _precursors(repo, s):
+    """Precursor of a changeset"""
+    cs = set()
+    nm = repo.changelog.nodemap
+    markerbysubj = repo.obsstore.precursors
+    for r in s:
+        for p in markerbysubj.get(repo[r].node(), ()):
+            pr = nm.get(p[0])
+            if pr is not None:
+                cs.add(pr)
+    return cs
+
+def _revsetprecursors(repo, subset, x):
+    s = revset.getset(repo, range(len(repo)), x)
+    cs = _precursors(repo, s)
+    return [r for r in subset if r in cs]
+
+revset.symbols['_fastobs_precursors'] = _revsetprecursors
+
+
 @_strategy('boxfill', default=True)
 def boxfill(repo, remote):
     """The "fill in the box" strategy from the 2.6 sprint.
@@ -75,7 +97,8 @@
     # kill markers for dead nodes descended from any of the precursors
     # of outgoing.missing.
     boxedges = urepo.revs(
-        '(descendants(precursors(%ln)) or descendants(%ln)) and hidden()',
+        '(descendants(_fastobs_precursors(%ln)) or '
+        ' descendants(%ln)) and hidden()',
         outgoing.missing, outgoing.missing)
     transmit = []
     for node in outgoing.missing: