Show More
@@ -8,6 +8,7 b'' | |||||
8 | import re |
|
8 | import re | |
9 | import parser, util, error, discovery, hbisect, phases |
|
9 | import parser, util, error, discovery, hbisect, phases | |
10 | import node |
|
10 | import node | |
|
11 | import heapq | |||
11 | import match as matchmod |
|
12 | import match as matchmod | |
12 | import ancestor as ancestormod |
|
13 | import ancestor as ancestormod | |
13 | from i18n import _ |
|
14 | from i18n import _ | |
@@ -20,14 +21,24 b' def _revancestors(repo, revs, followfirs' | |||||
20 | """Like revlog.ancestors(), but supports followfirst.""" |
|
21 | """Like revlog.ancestors(), but supports followfirst.""" | |
21 | cut = followfirst and 1 or None |
|
22 | cut = followfirst and 1 or None | |
22 | cl = repo.changelog |
|
23 | cl = repo.changelog | |
23 | visit = util.deque(revs) |
|
24 | ||
|
25 | # Implementation to be changed in later patches based on revs order. | |||
|
26 | h = list(revs) | |||
|
27 | for i in xrange(len(h)): | |||
|
28 | h[i] = -h[i] | |||
|
29 | heapq.heapify(h) | |||
24 | seen = set([node.nullrev]) |
|
30 | seen = set([node.nullrev]) | |
25 | while visit: |
|
31 | def iterate(): | |
26 | for parent in cl.parentrevs(visit.popleft())[:cut]: |
|
32 | while h: | |
27 | if parent not in seen: |
|
33 | current = -heapq.heappop(h) | |
28 | visit.append(parent) |
|
34 | if current not in seen: | |
29 |
seen.add( |
|
35 | seen.add(current) | |
30 |
yield |
|
36 | yield current | |
|
37 | for parent in cl.parentrevs(current)[:cut]: | |||
|
38 | if parent != node.nullrev: | |||
|
39 | heapq.heappush(h, -parent) | |||
|
40 | ||||
|
41 | return descgeneratorset(iterate()) | |||
31 |
|
42 | |||
32 | def _revdescendants(repo, revs, followfirst): |
|
43 | def _revdescendants(repo, revs, followfirst): | |
33 | """Like revlog.descendants() but supports followfirst.""" |
|
44 | """Like revlog.descendants() but supports followfirst.""" | |
@@ -312,7 +323,7 b' def _ancestors(repo, subset, x, followfi' | |||||
312 | args = getset(repo, spanset(repo), x) |
|
323 | args = getset(repo, spanset(repo), x) | |
313 | if not args: |
|
324 | if not args: | |
314 | return baseset([]) |
|
325 | return baseset([]) | |
315 |
s = |
|
326 | s = _revancestors(repo, args, followfirst) | |
316 | return subset.filter(lambda r: r in s) |
|
327 | return subset.filter(lambda r: r in s) | |
317 |
|
328 | |||
318 | def ancestors(repo, subset, x): |
|
329 | def ancestors(repo, subset, x): | |
@@ -784,7 +795,7 b' def _follow(repo, subset, x, name, follo' | |||||
784 | else: |
|
795 | else: | |
785 | return baseset([]) |
|
796 | return baseset([]) | |
786 | else: |
|
797 | else: | |
787 |
s = |
|
798 | s = _revancestors(repo, baseset([c.rev()]), followfirst) | |
788 |
|
799 | |||
789 | return subset.filter(lambda r: r in s) |
|
800 | return subset.filter(lambda r: r in s) | |
790 |
|
801 |
General Comments 0
You need to be logged in to leave comments.
Login now