Show More
@@ -9,21 +9,19 b' import heapq' | |||||
9 | import util |
|
9 | import util | |
10 | from node import nullrev |
|
10 | from node import nullrev | |
11 |
|
11 | |||
12 |
def ancestors(pfunc, * |
|
12 | def commonancestorsheads(pfunc, *nodes): | |
13 | """ |
|
13 | """Returns a set with the heads of all common ancestors of all nodes, | |
14 | Returns the common ancestors of a and b that are furthest from a |
|
14 | heads(::nodes[0] and ::nodes[1] and ...) . | |
15 | root (as measured by longest path). |
|
|||
16 |
|
15 | |||
17 | pfunc must return a list of parent vertices for a given vertex. |
|
16 | pfunc must return a list of parent vertices for a given vertex. | |
18 | """ |
|
17 | """ | |
19 |
if not isinstance( |
|
18 | if not isinstance(nodes, set): | |
20 |
|
|
19 | nodes = set(nodes) | |
21 |
if nullrev in |
|
20 | if nullrev in nodes: | |
22 | return set() |
|
21 | return set() | |
23 |
if len( |
|
22 | if len(nodes) <= 1: | |
24 |
return |
|
23 | return nodes | |
25 |
|
24 | |||
26 | def candidates(nodes): |
|
|||
27 |
|
|
25 | allseen = (1 << len(nodes)) - 1 | |
28 |
|
|
26 | seen = [0] * (max(nodes) + 1) | |
29 |
|
|
27 | for i, n in enumerate(nodes): | |
@@ -67,6 +65,13 b' def ancestors(pfunc, *orignodes):' | |||||
67 |
|
|
65 | seen[p] = sv | |
68 |
|
|
66 | return gca | |
69 |
|
67 | |||
|
68 | def ancestors(pfunc, *orignodes): | |||
|
69 | """ | |||
|
70 | Returns the common ancestors of a and b that are furthest from a | |||
|
71 | root (as measured by longest path). | |||
|
72 | ||||
|
73 | pfunc must return a list of parent vertices for a given vertex. | |||
|
74 | """ | |||
70 | def deepest(nodes): |
|
75 | def deepest(nodes): | |
71 | interesting = {} |
|
76 | interesting = {} | |
72 | count = max(nodes) + 1 |
|
77 | count = max(nodes) + 1 | |
@@ -123,7 +128,7 b' def ancestors(pfunc, *orignodes):' | |||||
123 | k |= i |
|
128 | k |= i | |
124 | return set(n for (i, n) in mapping if k & i) |
|
129 | return set(n for (i, n) in mapping if k & i) | |
125 |
|
130 | |||
126 |
gca = c |
|
131 | gca = commonancestorsheads(pfunc, *orignodes) | |
127 |
|
132 | |||
128 | if len(gca) <= 1: |
|
133 | if len(gca) <= 1: | |
129 | return gca |
|
134 | return gca |
General Comments 0
You need to be logged in to leave comments.
Login now