Show More
@@ -1137,17 +1137,22 b' class revlog(object):' | |||||
1137 | self._cache = (node, curr, text) |
|
1137 | self._cache = (node, curr, text) | |
1138 | return node |
|
1138 | return node | |
1139 |
|
1139 | |||
|
1140 | def descendant(self, a, b): | |||
|
1141 | if a > b: | |||
|
1142 | return False | |||
|
1143 | for i in self.descendants(a): | |||
|
1144 | if i == b: | |||
|
1145 | return True | |||
|
1146 | elif i > b: | |||
|
1147 | break | |||
|
1148 | return False | |||
|
1149 | ||||
1140 | def ancestor(self, a, b): |
|
1150 | def ancestor(self, a, b): | |
1141 | """calculate the least common ancestor of nodes a and b""" |
|
1151 | """calculate the least common ancestor of nodes a and b""" | |
1142 |
|
1152 | |||
1143 | # fast path, check if it is a descendant |
|
|||
1144 | a, b = self.rev(a), self.rev(b) |
|
|||
1145 | start, end = sorted((a, b)) |
|
1153 | start, end = sorted((a, b)) | |
1146 |
|
|
1154 | if self.descendant(a, b): | |
1147 | if i == end: |
|
1155 | return self.node(start) | |
1148 | return self.node(start) |
|
|||
1149 | elif i > end: |
|
|||
1150 | break |
|
|||
1151 |
|
1156 | |||
1152 | def parents(rev): |
|
1157 | def parents(rev): | |
1153 | return [p for p in self.parentrevs(rev) if p != nullrev] |
|
1158 | return [p for p in self.parentrevs(rev) if p != nullrev] |
General Comments 0
You need to be logged in to leave comments.
Login now