##// END OF EJS Templates
revlog: remove reachable and switch call sites to ancestors...
Joshua Redstone -
r17009:0c18aed2 default
parent child Browse files
Show More
@@ -91,14 +91,22 b' class transplanter(object):'
91 '''returns True if a node is already an ancestor of parent
91 '''returns True if a node is already an ancestor of parent
92 or has already been transplanted'''
92 or has already been transplanted'''
93 if hasnode(repo, node):
93 if hasnode(repo, node):
94 if node in repo.changelog.reachable(parent, stop=node):
94 reachablerevs = repo.changelog.incancestors(
95 [repo.changelog.rev(parent)],
96 stoprev=repo.changelog.rev(node))
97 reachable = (repo.changelog.node(rev) for rev in reachablerevs)
98 if node in reachable:
95 return True
99 return True
96 for t in self.transplants.get(node):
100 for t in self.transplants.get(node):
97 # it might have been stripped
101 # it might have been stripped
98 if not hasnode(repo, t.lnode):
102 if not hasnode(repo, t.lnode):
99 self.transplants.remove(t)
103 self.transplants.remove(t)
100 return False
104 return False
101 if t.lnode in repo.changelog.reachable(parent, stop=t.lnode):
105 reachablerevs = repo.changelog.incancestors(
106 [repo.changelog.rev(parent)],
107 stoprev=repo.changelog.rev(t.lnode))
108 reachable = (repo.changelog.node(rev) for rev in reachablerevs)
109 if t.lnode in reachable:
102 return True
110 return True
103 return False
111 return False
104
112
@@ -214,8 +214,8 b' def checkheads(repo, remote, outgoing, r'
214 if latest not in newheads:
214 if latest not in newheads:
215 continue
215 continue
216 minhrev = min(cl.rev(h) for h in newheads)
216 minhrev = min(cl.rev(h) for h in newheads)
217 reachable = cl.reachable(latest, cl.node(minhrev))
217 reachable = [cl.node(rev) for rev in
218 reachable.remove(latest)
218 cl.ancestors([cl.rev(latest)], minhrev)]
219 newheads.difference_update(reachable)
219 newheads.difference_update(reachable)
220 branches = set([None])
220 branches = set([None])
221 newmap = {None: newheads}
221 newmap = {None: newheads}
@@ -590,8 +590,10 b' class localrepository(repo.repository):'
590 if latest not in bheads:
590 if latest not in bheads:
591 continue
591 continue
592 minbhnode = self[bheads[0]].node()
592 minbhnode = self[bheads[0]].node()
593 reachable = self.changelog.reachable(latest, minbhnode)
593 cl = self.changelog
594 reachable.remove(latest)
594 ancestors = cl.ancestors([cl.rev(latest)],
595 cl.rev(minbhnode))
596 reachable = [cl.node(rev) for rev in ancestors]
595 if reachable:
597 if reachable:
596 bheads = [b for b in bheads if b not in reachable]
598 bheads = [b for b in bheads if b not in reachable]
597 partial[branch] = bheads
599 partial[branch] = bheads
@@ -361,29 +361,6 b' class revlog(object):'
361 return len(t)
361 return len(t)
362 size = rawsize
362 size = rawsize
363
363
364 def reachable(self, node, stop=None):
365 """return the set of all nodes ancestral to a given node, including
366 the node itself, stopping when stop is matched"""
367 reachable = set((node,))
368 visit = util.deque([node])
369 if stop:
370 stopn = self.rev(stop)
371 else:
372 stopn = 0
373 while visit:
374 n = visit.popleft()
375 if n == stop:
376 continue
377 if n == nullid:
378 continue
379 for p in self.parents(n):
380 if self.rev(p) < stopn:
381 continue
382 if p not in reachable:
383 reachable.add(p)
384 visit.append(p)
385 return reachable
386
387 def ancestors(self, revs, stoprev=0):
364 def ancestors(self, revs, stoprev=0):
388 """Generate the ancestors of 'revs' in reverse topological order.
365 """Generate the ancestors of 'revs' in reverse topological order.
389 Does not generate revs lower than stoprev.
366 Does not generate revs lower than stoprev.
General Comments 0
You need to be logged in to leave comments. Login now