741 ancs = self.index.commonancestorsheads(a, b) |
741 ancs = self.index.commonancestorsheads(a, b) |
742 except (AttributeError, OverflowError): # C implementation failed |
742 except (AttributeError, OverflowError): # C implementation failed |
743 ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) |
743 ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) |
744 return map(self.node, ancs) |
744 return map(self.node, ancs) |
745 |
745 |
746 def commonancestors(self, a, b): |
746 def ancestor(self, a, b): |
747 """calculate the least common ancestors of nodes a and b""" |
747 """calculate the least common ancestor of nodes a and b""" |
|
748 |
748 a, b = self.rev(a), self.rev(b) |
749 a, b = self.rev(a), self.rev(b) |
749 try: |
750 try: |
750 ancs = self.index.ancestors(a, b) |
751 ancs = self.index.ancestors(a, b) |
751 except (AttributeError, OverflowError): # C implementation failed |
752 except (AttributeError, OverflowError): |
752 ancs = ancestor.ancestors(self.parentrevs, a, b) |
753 ancs = ancestor.ancestors(self.parentrevs, a, b) |
753 return map(self.node, ancs) |
|
754 |
|
755 def ancestor(self, a, b): |
|
756 """calculate a least common ancestor of nodes a and b""" |
|
757 ancs = self.commonancestors(a, b) |
|
758 if ancs: |
754 if ancs: |
759 # choose a consistent winner when there's a tie |
755 # choose a consistent winner when there's a tie |
760 return min(ancs) |
756 return min(map(self.node, ancs)) |
761 return nullid |
757 return nullid |
762 |
758 |
763 def _match(self, id): |
759 def _match(self, id): |
764 if isinstance(id, int): |
760 if isinstance(id, int): |
765 # rev |
761 # rev |