##// END OF EJS Templates
revset: introduce and use _revsbetween...
Bryan O'Sullivan -
r16862:b6efeb27 default
parent child Browse files
Show More
@@ -47,6 +47,36 b' def _revdescendants(repo, revs, followfi'
47 47 yield i
48 48 break
49 49
50 def _revsbetween(repo, roots, heads):
51 """Return all paths between roots and heads, inclusive of both endpoint
52 sets."""
53 if not roots:
54 return []
55 parentrevs = repo.changelog.parentrevs
56 visit = heads[:]
57 reachable = set()
58 seen = {}
59 minroot = min(roots)
60 roots = set(roots)
61 # open-code the post-order traversal due to the tiny size of
62 # sys.getrecursionlimit()
63 while visit:
64 rev = visit.pop()
65 if rev in roots:
66 reachable.add(rev)
67 parents = parentrevs(rev)
68 seen[rev] = parents
69 for parent in parents:
70 if parent >= minroot and parent not in seen:
71 visit.append(parent)
72 if not reachable:
73 return []
74 for rev in sorted(seen):
75 for parent in seen[rev]:
76 if parent in reachable:
77 reachable.add(rev)
78 return sorted(reachable)
79
50 80 elements = {
51 81 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
52 82 "~": (18, None, ("ancestor", 18)),
@@ -194,10 +224,7 b' def rangeset(repo, subset, x, y):'
194 224 def dagrange(repo, subset, x, y):
195 225 if subset:
196 226 r = range(len(repo))
197 m = getset(repo, r, x)
198 n = getset(repo, r, y)
199 cl = repo.changelog
200 xs = map(cl.rev, cl.nodesbetween(map(cl.node, m), map(cl.node, n))[0])
227 xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
201 228 s = set(subset)
202 229 return [r for r in xs if r in s]
203 230 return []
General Comments 0
You need to be logged in to leave comments. Login now