Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 17009:0c18aed2fcca
revlog: remove reachable and switch call sites to ancestors
This change does a trivial conversion of callsites to ancestors.
Followon diffs will switch the callsites over to revs.
author | Joshua Redstone <joshua.redstone@fb.com> |
---|---|
date | Fri, 08 Jun 2012 08:39:44 -0700 |
parents | 553e8f5aba7a |
children | 1028a1c9077a e7167007c083 |
comparison
equal
deleted
inserted
replaced
17008:553e8f5aba7a | 17009:0c18aed2fcca |
---|---|
358 return l | 358 return l |
359 | 359 |
360 t = self.revision(self.node(rev)) | 360 t = self.revision(self.node(rev)) |
361 return len(t) | 361 return len(t) |
362 size = rawsize | 362 size = rawsize |
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 | 363 |
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. |
390 | 367 |