comparison mercurial/revlog.py @ 3928:4df475e22248

Sync with -stable
author Matt Mackall <mpm@selenic.com>
date Sun, 17 Dec 2006 21:48:22 -0600
parents 6b4127c7d52a 27230c29bfec
children 01d98d68d697
comparison
equal deleted inserted replaced
3924:a8bd7280330f 3928:4df475e22248
714 assert orderedout 714 assert orderedout
715 assert roots 715 assert roots
716 assert heads 716 assert heads
717 return (orderedout, roots, heads) 717 return (orderedout, roots, heads)
718 718
719 def heads(self, start=None): 719 def heads(self, start=None, stop=None):
720 """return the list of all nodes that have no children 720 """return the list of all nodes that have no children
721 721
722 if start is specified, only heads that are descendants of 722 if start is specified, only heads that are descendants of
723 start will be returned 723 start will be returned
724 724 if stop is specified, it will consider all the revs from stop
725 as if they had no children
725 """ 726 """
726 if start is None: 727 if start is None:
727 start = nullid 728 start = nullid
729 if stop is None:
730 stop = []
731 stoprevs = dict.fromkeys([self.rev(n) for n in stop])
728 startrev = self.rev(start) 732 startrev = self.rev(start)
729 reachable = {startrev: 1} 733 reachable = {startrev: 1}
730 heads = {startrev: 1} 734 heads = {startrev: 1}
731 735
732 parentrevs = self.parentrevs 736 parentrevs = self.parentrevs
733 for r in xrange(startrev + 1, self.count()): 737 for r in xrange(startrev + 1, self.count()):
734 for p in parentrevs(r): 738 for p in parentrevs(r):
735 if p in reachable: 739 if p in reachable:
736 reachable[r] = 1 740 if r not in stoprevs:
741 reachable[r] = 1
737 heads[r] = 1 742 heads[r] = 1
738 if p in heads: 743 if p in heads and p not in stoprevs:
739 del heads[p] 744 del heads[p]
745
740 return [self.node(r) for r in heads] 746 return [self.node(r) for r in heads]
741 747
742 def children(self, node): 748 def children(self, node):
743 """find the children of a given node""" 749 """find the children of a given node"""
744 c = [] 750 c = []