##// END OF EJS Templates
copies: refactor symmetricdifference as _findlimit...
Matt Mackall -
r6431:a42d8d3e default
parent child Browse files
Show More
@@ -53,8 +53,8 b' def _findoldnames(fctx, limit):'
53 53 old.sort()
54 54 return [o[1] for o in old]
55 55
56 def _symmetricdifference(repo, a, b):
57 """find revisions that are ancestors of a or b, but not both"""
56 def _findlimit(repo, a, b):
57 "find the earliest revision that's an ancestor of a or b but not both"
58 58 # basic idea:
59 59 # - mark a and b with different sides
60 60 # - if a parent's children are all on the same side, the parent is
@@ -62,11 +62,12 b' def _symmetricdifference(repo, a, b):'
62 62 # - walk the graph in topological order with the help of a heap;
63 63 # - add unseen parents to side map
64 64 # - clear side of any parent that has children on different sides
65 # - track number of unvisited nodes that might still be on a side
66 # - quit when interesting nodes is zero
65 # - track number of interesting revs that might still be on a side
66 # - track the lowest interesting rev seen
67 # - quit when interesting revs is zero
67 68
68 69 cl = repo.changelog
69 working = cl.count()
70 working = cl.count() # pseudo rev for the working directory
70 71 if a is None:
71 72 a = working
72 73 if b is None:
@@ -76,6 +77,7 b' def _symmetricdifference(repo, a, b):'
76 77 visit = [-a, -b]
77 78 heapq.heapify(visit)
78 79 interesting = len(visit)
80 limit = working
79 81
80 82 while interesting:
81 83 r = -heapq.heappop(visit)
@@ -95,8 +97,9 b' def _symmetricdifference(repo, a, b):'
95 97 side[p] = 0
96 98 interesting -= 1
97 99 if side[r]:
100 limit = r # lowest rev visited
98 101 interesting -= 1
99 yield r
102 return limit
100 103
101 104 def copies(repo, c1, c2, ca, checkdirs=False):
102 105 """
@@ -106,7 +109,7 b' def copies(repo, c1, c2, ca, checkdirs=F'
106 109 if not c1 or not c2 or c1 == c2:
107 110 return {}, {}
108 111
109 limit = min(_symmetricdifference(repo, c1.rev(), c2.rev()))
112 limit = _findlimit(repo, c1.rev(), c2.rev())
110 113 m1 = c1.manifest()
111 114 m2 = c2.manifest()
112 115 ma = ca.manifest()
General Comments 0
You need to be logged in to leave comments. Login now