comparison tests/test-ancestor.py @ 23328:3a7d9c0c57a5

ancestor.lazyancestors: take parentrevs function rather than changelog Principle of least privilege, and it also brings this in line with missingancestors.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 14 Nov 2014 14:36:25 -0800
parents 731b2a90983b
children c6cd4b8b76f8
comparison
equal deleted inserted replaced
23327:bd296bb4b5c8 23328:3a7d9c0c57a5
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
39 36
40 def runmissingancestors(revs, bases): 37 def runmissingancestors(revs, bases):
41 print "%% ancestors of %s and not of %s" % (revs, bases) 38 print "%% ancestors of %s and not of %s" % (revs, bases)
42 print ancestor.missingancestors(revs, bases, pfunc) 39 print ancestor.missingancestors(revs, bases, pfunc)
43 40
74 runmissingancestors([13], [10, 11, 12]) 71 runmissingancestors([13], [10, 11, 12])
75 72
76 def genlazyancestors(revs, stoprev=0, inclusive=False): 73 def genlazyancestors(revs, stoprev=0, inclusive=False):
77 print ("%% lazy ancestor set for %s, stoprev = %s, inclusive = %s" % 74 print ("%% lazy ancestor set for %s, stoprev = %s, inclusive = %s" %
78 (revs, stoprev, inclusive)) 75 (revs, stoprev, inclusive))
79 return ancestor.lazyancestors(mockchangelog, revs, stoprev=stoprev, 76 return ancestor.lazyancestors(graph.get, revs, stoprev=stoprev,
80 inclusive=inclusive) 77 inclusive=inclusive)
81 78
82 def printlazyancestors(s, l): 79 def printlazyancestors(s, l):
83 print [n for n in l if n in s] 80 print [n for n in l if n in s]
84 81