Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 1550:ccb9b62de892
add a -r/--rev option to heads to show only heads descendant from rev
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 16 Nov 2005 12:08:25 +0100 |
parents | 7ae0ce7a3dc4 |
children | e793cbc8be00 |
comparison
equal
deleted
inserted
replaced
1547:4dea10839201 | 1550:ccb9b62de892 |
---|---|
407 assert orderedout | 407 assert orderedout |
408 assert roots | 408 assert roots |
409 assert heads | 409 assert heads |
410 return (orderedout, roots, heads) | 410 return (orderedout, roots, heads) |
411 | 411 |
412 def heads(self, stop=None): | 412 def heads(self, start=nullid): |
413 """return the list of all nodes that have no children""" | 413 """return the list of all nodes that have no children |
414 p = {} | 414 if start is specified, only heads that are children of |
415 h = [] | 415 start will be returned""" |
416 stoprev = 0 | 416 reachable = {start: 1} |
417 if stop and stop in self.nodemap: | 417 heads = {start: 1} |
418 stoprev = self.rev(stop) | 418 startrev = self.rev(start) |
419 | 419 |
420 for r in range(self.count() - 1, -1, -1): | 420 for r in xrange(startrev + 1, self.count()): |
421 n = self.node(r) | 421 n = self.node(r) |
422 if n not in p: | |
423 h.append(n) | |
424 if n == stop: | |
425 break | |
426 if r < stoprev: | |
427 break | |
428 for pn in self.parents(n): | 422 for pn in self.parents(n): |
429 p[pn] = 1 | 423 if pn in reachable: |
430 return h | 424 reachable[n] = 1 |
425 heads[n] = 1 | |
426 if pn in heads: | |
427 del heads[pn] | |
428 return heads.keys() | |
431 | 429 |
432 def children(self, node): | 430 def children(self, node): |
433 """find the children of a given node""" | 431 """find the children of a given node""" |
434 c = [] | 432 c = [] |
435 p = self.rev(node) | 433 p = self.rev(node) |