31 |
31 |
32 graph = {0: [-1], 1: [0], 2: [1], 3: [1], 4: [2], 5: [4], 6: [4], |
32 graph = {0: [-1], 1: [0], 2: [1], 3: [1], 4: [2], 5: [4], 6: [4], |
33 7: [4], 8: [-1], 9: [6, 7], 10: [5], 11: [3, 7], 12: [9], |
33 7: [4], 8: [-1], 9: [6, 7], 10: [5], 11: [3, 7], 12: [9], |
34 13: [8]} |
34 13: [8]} |
35 pfunc = graph.get |
35 pfunc = graph.get |
|
36 |
|
37 class mockchangelog(object): |
|
38 parentrevs = graph.get |
36 |
39 |
37 def runmissingancestors(revs, bases): |
40 def runmissingancestors(revs, bases): |
38 print "%% ancestors of %s and not of %s" % (revs, bases) |
41 print "%% ancestors of %s and not of %s" % (revs, bases) |
39 print ancestor.missingancestors(revs, bases, pfunc) |
42 print ancestor.missingancestors(revs, bases, pfunc) |
40 |
43 |
68 runmissingancestors([12], [10]) |
71 runmissingancestors([12], [10]) |
69 runmissingancestors([12], [11]) |
72 runmissingancestors([12], [11]) |
70 runmissingancestors([10, 11, 12], [13]) |
73 runmissingancestors([10, 11, 12], [13]) |
71 runmissingancestors([13], [10, 11, 12]) |
74 runmissingancestors([13], [10, 11, 12]) |
72 |
75 |
|
76 def genlazyancestors(revs, stoprev=0, inclusive=False): |
|
77 print ("%% lazy ancestor set for %s, stoprev = %s, inclusive = %s" % |
|
78 (revs, stoprev, inclusive)) |
|
79 return ancestor.lazyancestors(mockchangelog, revs, stoprev=stoprev, |
|
80 inclusive=inclusive) |
|
81 |
|
82 def printlazyancestors(s, l): |
|
83 print [n for n in l if n in s] |
|
84 |
|
85 def test_lazyancestors(): |
|
86 # Empty revs |
|
87 s = genlazyancestors([]) |
|
88 printlazyancestors(s, [3, 0, -1]) |
|
89 |
|
90 # Standard example |
|
91 s = genlazyancestors([11, 13]) |
|
92 printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0]) |
|
93 |
|
94 # Including revs |
|
95 s = genlazyancestors([11, 13], inclusive=True) |
|
96 printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0]) |
|
97 |
|
98 # Test with stoprev |
|
99 s = genlazyancestors([11, 13], stoprev=6) |
|
100 printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0]) |
|
101 s = genlazyancestors([11, 13], stoprev=6, inclusive=True) |
|
102 printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0]) |
|
103 |
73 if __name__ == '__main__': |
104 if __name__ == '__main__': |
74 test_missingancestors() |
105 test_missingancestors() |
|
106 test_lazyancestors() |