##// END OF EJS Templates
revlog: speed up isancestor...
Valentin Gatien-Baron -
r42639:055c3e2c default
parent child Browse files
Show More
@@ -420,9 +420,6 b' class changelog(revlog.revlog):'
420 if i not in self.filteredrevs:
420 if i not in self.filteredrevs:
421 yield i
421 yield i
422
422
423 def reachableroots(self, minroot, heads, roots, includepath=False):
424 return self.index.reachableroots2(minroot, heads, roots, includepath)
425
426 def _checknofilteredinrevs(self, revs):
423 def _checknofilteredinrevs(self, revs):
427 """raise the appropriate error if 'revs' contains a filtered revision
424 """raise the appropriate error if 'revs' contains a filtered revision
428
425
@@ -259,11 +259,10 b' def descendantrevs(revs, revsfn, parentr'
259 yield rev
259 yield rev
260 break
260 break
261
261
262 def _reachablerootspure(repo, minroot, roots, heads, includepath):
262 def _reachablerootspure(pfunc, minroot, roots, heads, includepath):
263 """See reachableroots"""
263 """See revlog.reachableroots"""
264 if not roots:
264 if not roots:
265 return []
265 return []
266 parentrevs = repo.changelog.parentrevs
267 roots = set(roots)
266 roots = set(roots)
268 visit = list(heads)
267 visit = list(heads)
269 reachable = set()
268 reachable = set()
@@ -280,7 +279,7 b' def _reachablerootspure(repo, minroot, r'
280 reached(rev)
279 reached(rev)
281 if not includepath:
280 if not includepath:
282 continue
281 continue
283 parents = parentrevs(rev)
282 parents = pfunc(rev)
284 seen[rev] = parents
283 seen[rev] = parents
285 for parent in parents:
284 for parent in parents:
286 if parent >= minroot and parent not in seen:
285 if parent >= minroot and parent not in seen:
@@ -296,18 +295,13 b' def _reachablerootspure(repo, minroot, r'
296 return reachable
295 return reachable
297
296
298 def reachableroots(repo, roots, heads, includepath=False):
297 def reachableroots(repo, roots, heads, includepath=False):
299 """return (heads(::<roots> and <roots>::<heads>))
298 """See revlog.reachableroots"""
300
301 If includepath is True, return (<roots>::<heads>)."""
302 if not roots:
299 if not roots:
303 return baseset()
300 return baseset()
304 minroot = roots.min()
301 minroot = roots.min()
305 roots = list(roots)
302 roots = list(roots)
306 heads = list(heads)
303 heads = list(heads)
307 try:
304 revs = repo.changelog.reachableroots(minroot, heads, roots, includepath)
308 revs = repo.changelog.reachableroots(minroot, heads, roots, includepath)
309 except AttributeError:
310 revs = _reachablerootspure(repo, minroot, roots, heads, includepath)
311 revs = baseset(revs)
305 revs = baseset(revs)
312 revs.sort()
306 revs.sort()
313 return revs
307 return revs
@@ -1216,14 +1216,25 b' class revlog(object):'
1216 A revision is considered an ancestor of itself.
1216 A revision is considered an ancestor of itself.
1217
1217
1218 The implementation of this is trivial but the use of
1218 The implementation of this is trivial but the use of
1219 commonancestorsheads is not."""
1219 reachableroots is not."""
1220 if a == nullrev:
1220 if a == nullrev:
1221 return True
1221 return True
1222 elif a == b:
1222 elif a == b:
1223 return True
1223 return True
1224 elif a > b:
1224 elif a > b:
1225 return False
1225 return False
1226 return a in self._commonancestorsheads(a, b)
1226 return bool(self.reachableroots(a, [b], [a], includepath=False))
1227
1228 def reachableroots(self, minroot, heads, roots, includepath=False):
1229 """return (heads(::<roots> and <roots>::<heads>))
1230
1231 If includepath is True, return (<roots>::<heads>)."""
1232 try:
1233 return self.index.reachableroots2(minroot, heads, roots,
1234 includepath)
1235 except AttributeError:
1236 return dagop._reachablerootspure(self.parentrevs,
1237 minroot, roots, heads, includepath)
1227
1238
1228 def ancestor(self, a, b):
1239 def ancestor(self, a, b):
1229 """calculate the "best" common ancestor of nodes a and b"""
1240 """calculate the "best" common ancestor of nodes a and b"""
General Comments 0
You need to be logged in to leave comments. Login now