Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 38668:21846c94e605
revlog: delete isdescendantrev() in favor of isancestorrev()
As agreed on by Boris, Yuya, and me on D3929.
Differential Revision: https://phab.mercurial-scm.org/D3934
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 12 Jul 2018 08:14:21 -0700 |
parents | a06b2b032557 |
children | 4ac3c2078567 |
comparison
equal
deleted
inserted
replaced
38667:572dff5c946e | 38668:21846c94e605 |
---|---|
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 isdescendantrev(self, a, b): | |
1649 """True if revision a is a descendant of revision b | |
1650 | |
1651 A revision is considered a descendant of itself. | |
1652 | |
1653 The implementation of this is trivial but the use of | |
1654 commonancestorsheads is not.""" | |
1655 if b == nullrev: | |
1656 return True | |
1657 elif a == b: | |
1658 return True | |
1659 elif a < b: | |
1660 return False | |
1661 return b in self._commonancestorsheads(a, b) | |
1662 | |
1663 def commonancestorsheads(self, a, b): | 1648 def commonancestorsheads(self, a, b): |
1664 """calculate all the heads of the common ancestors of nodes a and b""" | 1649 """calculate all the heads of the common ancestors of nodes a and b""" |
1665 a, b = self.rev(a), self.rev(b) | 1650 a, b = self.rev(a), self.rev(b) |
1666 ancs = self._commonancestorsheads(a, b) | 1651 ancs = self._commonancestorsheads(a, b) |
1667 return pycompat.maplist(self.node, ancs) | 1652 return pycompat.maplist(self.node, ancs) |
1682 return self.isancestorrev(a, b) | 1667 return self.isancestorrev(a, b) |
1683 | 1668 |
1684 def isancestorrev(self, a, b): | 1669 def isancestorrev(self, a, b): |
1685 """return True if revision a is an ancestor of revision b | 1670 """return True if revision a is an ancestor of revision b |
1686 | 1671 |
1687 A revision is considered an ancestor of itself.""" | 1672 A revision is considered an ancestor of itself. |
1688 return self.isdescendantrev(b, a) | 1673 |
1674 The implementation of this is trivial but the use of | |
1675 commonancestorsheads is not.""" | |
1676 if a == nullrev: | |
1677 return True | |
1678 elif a == b: | |
1679 return True | |
1680 elif a > b: | |
1681 return False | |
1682 return a in self._commonancestorsheads(a, b) | |
1689 | 1683 |
1690 def ancestor(self, a, b): | 1684 def ancestor(self, a, b): |
1691 """calculate the "best" common ancestor of nodes a and b""" | 1685 """calculate the "best" common ancestor of nodes a and b""" |
1692 | 1686 |
1693 a, b = self.rev(a), self.rev(b) | 1687 a, b = self.rev(a), self.rev(b) |