1643 c.append(self.node(r)) |
1643 c.append(self.node(r)) |
1644 elif p == nullrev: |
1644 elif p == nullrev: |
1645 c.append(self.node(r)) |
1645 c.append(self.node(r)) |
1646 return c |
1646 return c |
1647 |
1647 |
1648 def descendant(self, start, end): |
1648 def isdescendantrev(self, a, b): |
1649 """True if revision 'end' is an descendant of revision 'start' |
1649 """True if revision a is a descendant of revision b |
1650 |
1650 |
1651 A revision is considered as a descendant of itself. |
1651 A revision is considered a descendant of itself. |
1652 |
1652 |
1653 The implementation of this is trivial but the use of |
1653 The implementation of this is trivial but the use of |
1654 commonancestorsheads is not.""" |
1654 commonancestorsheads is not.""" |
1655 if start == nullrev: |
1655 if b == nullrev: |
1656 return True |
1656 return True |
1657 elif start == end: |
1657 elif a == b: |
1658 return True |
1658 return True |
1659 return start in self._commonancestorsheads(start, end) |
1659 return b in self._commonancestorsheads(a, b) |
1660 |
1660 |
1661 def commonancestorsheads(self, a, b): |
1661 def commonancestorsheads(self, a, b): |
1662 """calculate all the heads of the common ancestors of nodes a and b""" |
1662 """calculate all the heads of the common ancestors of nodes a and b""" |
1663 a, b = self.rev(a), self.rev(b) |
1663 a, b = self.rev(a), self.rev(b) |
1664 ancs = self._commonancestorsheads(a, b) |
1664 ancs = self._commonancestorsheads(a, b) |
1671 except (AttributeError, OverflowError): # C implementation failed |
1671 except (AttributeError, OverflowError): # C implementation failed |
1672 ancs = ancestor.commonancestorsheads(self.parentrevs, *revs) |
1672 ancs = ancestor.commonancestorsheads(self.parentrevs, *revs) |
1673 return ancs |
1673 return ancs |
1674 |
1674 |
1675 def isancestor(self, a, b): |
1675 def isancestor(self, a, b): |
1676 """return True if node a is an ancestor of node b""" |
1676 """return True if node a is an ancestor of node b |
|
1677 |
|
1678 A revision is considered an ancestor of itself.""" |
1677 a, b = self.rev(a), self.rev(b) |
1679 a, b = self.rev(a), self.rev(b) |
1678 return self.descendant(a, b) |
1680 return self.isdescendantrev(b, a) |
1679 |
1681 |
1680 def ancestor(self, a, b): |
1682 def ancestor(self, a, b): |
1681 """calculate the "best" common ancestor of nodes a and b""" |
1683 """calculate the "best" common ancestor of nodes a and b""" |
1682 |
1684 |
1683 a, b = self.rev(a), self.rev(b) |
1685 a, b = self.rev(a), self.rev(b) |