diff hgext/evolve.py @ 1388:c96e4ab4e5cc

merge with stable
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 18 Jun 2015 17:57:11 -0700
parents 3d2d3333fb0b b5eaec8a53d0
children 35518d26b549
line wrap: on
line diff
--- a/hgext/evolve.py	Thu Jun 18 15:25:51 2015 -0700
+++ b/hgext/evolve.py	Thu Jun 18 17:57:11 2015 -0700
@@ -257,7 +257,7 @@
 
 
     def templatekw(self, keywordname):
-        """Decorated function is a revset keyword
+        """Decorated function is a template keyword
 
         The name of the keyword must be given as the decorator argument.
         The symbol is added during `extsetup`.
@@ -444,7 +444,9 @@
     troubled.update(getrevs(repo, 'unstable'))
     troubled.update(getrevs(repo, 'bumped'))
     troubled.update(getrevs(repo, 'divergent'))
-    return subset & revset.baseset(troubled)
+    troubled = revset.baseset(troubled)
+    troubled.sort() # set is non-ordered, enforce order
+    return subset & troubled
 
 ### Obsolescence graph
 
@@ -455,16 +457,19 @@
     cs = set()
     nm = repo.changelog.nodemap
     markerbysubj = repo.obsstore.precursors
+    node = repo.changelog.node
     for r in s:
-        for p in markerbysubj.get(repo[r].node(), ()):
+        for p in markerbysubj.get(node(r), ()):
             pr = nm.get(p[0])
             if pr is not None:
                 cs.add(pr)
+    cs -= repo.changelog.filteredrevs # nodemap has no filtering
     return cs
 
 def _allprecursors(repo, s):  # XXX we need a better naming
     """transitive precursors of a subset"""
-    toproceed = [repo[r].node() for r in s]
+    node = repo.changelog.node
+    toproceed = [node(r) for r in s]
     seen = set()
     allsubjects = repo.obsstore.precursors
     while toproceed:
@@ -480,19 +485,22 @@
         pr = nm.get(p)
         if pr is not None:
             cs.add(pr)
+    cs -= repo.changelog.filteredrevs # nodemap has no filtering
     return cs
 
 def _successors(repo, s):
     """Successors of a changeset"""
     cs = set()
+    node = repo.changelog.node
     nm = repo.changelog.nodemap
     markerbyobj = repo.obsstore.successors
     for r in s:
-        for p in markerbyobj.get(repo[r].node(), ()):
+        for p in markerbyobj.get(node(r), ()):
             for sub in p[1]:
                 sr = nm.get(sub)
                 if sr is not None:
                     cs.add(sr)
+    cs -= repo.changelog.filteredrevs # nodemap has no filtering
     return cs
 
 def _allsuccessors(repo, s, haltonflags=0):  # XXX we need a better naming
@@ -500,7 +508,8 @@
 
     haltonflags allows to provide flags which prevent the evaluation of a
     marker.  """
-    toproceed = [repo[r].node() for r in s]
+    node = repo.changelog.node
+    toproceed = [node(r) for r in s]
     seen = set()
     allobjects = repo.obsstore.successors
     while toproceed:
@@ -520,6 +529,7 @@
         sr = nm.get(s)
         if sr is not None:
             cs.add(sr)
+    cs -= repo.changelog.filteredrevs # nodemap has no filtering
     return cs
 
 
@@ -540,8 +550,9 @@
     Obsolete changesets with non-obsolete descendants.
     """
     revset.getargs(x, 0, 0, 'suspended takes no arguments')
-    suspended = getrevs(repo, 'suspended')
-    return [r for r in subset if r in suspended]
+    suspended = revset.baseset(getrevs(repo, 'suspended'))
+    suspended.sort()
+    return subset & suspended
 
 
 @eh.revset('precursors')
@@ -550,8 +561,9 @@
     Immediate precursors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
-    cs = _precursors(repo, s)
-    return [r for r in subset if r in cs]
+    s = revset.baseset(_precursors(repo, s))
+    s.sort()
+    return subset & s
 
 
 @eh.revset('allprecursors')
@@ -560,8 +572,9 @@
     Transitive precursors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
-    cs = _allprecursors(repo, s)
-    return [r for r in subset if r in cs]
+    s = revset.baseset(_allprecursors(repo, s))
+    s.sort()
+    return subset & s
 
 
 @eh.revset('successors')
@@ -570,8 +583,9 @@
     Immediate successors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
-    cs = _successors(repo, s)
-    return [r for r in subset if r in cs]
+    s = revset.baseset(_successors(repo, s))
+    s.sort()
+    return subset & s
 
 @eh.revset('allsuccessors')
 def revsetallsuccessors(repo, subset, x):
@@ -579,8 +593,9 @@
     Transitive successors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
-    cs = _allsuccessors(repo, s)
-    return [r for r in subset if r in cs]
+    s = revset.baseset(_allsuccessors(repo, s))
+    s.sort()
+    return subset & s
 
 ### template keywords
 # XXX it does not handle troubles well :-/
@@ -1740,8 +1755,8 @@
 
     XXX this woobly function won't survive XXX
     """
-    repo = ctx.repo.unfitered()
-    for base in repo.set('reverse(precursors(%d))', ctx):
+    repo = ctx._repo.unfiltered()
+    for base in repo.set('reverse(allprecursors(%d))', ctx):
         newer = obsolete.successorssets(ctx._repo, base.node())
         # drop filter and solution including the original ctx
         newer = [n for n in newer if n and ctx.node() not in n]