Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 10329:ae0ae8691e47
revlog: fix up previously stupid API change
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 06 Feb 2010 12:47:17 +0100 |
parents | bc72e21f9dc8 |
children | ea52a2d4f42c |
comparison
equal
deleted
inserted
replaced
10328:0798a3d5f812 | 10329:ae0ae8691e47 |
---|---|
1135 | 1135 |
1136 if type(text) == str: # only accept immutable objects | 1136 if type(text) == str: # only accept immutable objects |
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): | 1140 def descendant(self, start, end): |
1141 if a > b: | 1141 for i in self.descendants(start): |
1142 return False | 1142 if i == end: |
1143 for i in self.descendants(a): | |
1144 if i == b: | |
1145 return True | 1143 return True |
1146 elif i > b: | 1144 elif i > end: |
1147 break | 1145 break |
1148 return False | 1146 return False |
1149 | 1147 |
1150 def ancestor(self, a, b): | 1148 def ancestor(self, a, b): |
1151 """calculate the least common ancestor of nodes a and b""" | 1149 """calculate the least common ancestor of nodes a and b""" |
1152 | 1150 |
1151 # fast path, check if it is a descendant | |
1152 a, b = self.rev(a), self.rev(b) | |
1153 start, end = sorted((a, b)) | 1153 start, end = sorted((a, b)) |
1154 if self.descendant(a, b): | 1154 if self.descendant(start, end): |
1155 return self.node(start) | 1155 return self.node(start) |
1156 | 1156 |
1157 def parents(rev): | 1157 def parents(rev): |
1158 return [p for p in self.parentrevs(rev) if p != nullrev] | 1158 return [p for p in self.parentrevs(rev) if p != nullrev] |
1159 | 1159 |