##// END OF EJS Templates
changelog: prefilter in headrevs()...
Georges Racinet -
r41929:6843379b default
parent child Browse files
Show More
@@ -22,6 +22,7 from . import (
22 error,
22 error,
23 pycompat,
23 pycompat,
24 revlog,
24 revlog,
25 util,
25 )
26 )
26 from .utils import (
27 from .utils import (
27 dateutil,
28 dateutil,
@@ -350,6 +351,27 class changelog(revlog.revlog):
350 def reachableroots(self, minroot, heads, roots, includepath=False):
351 def reachableroots(self, minroot, heads, roots, includepath=False):
351 return self.index.reachableroots2(minroot, heads, roots, includepath)
352 return self.index.reachableroots2(minroot, heads, roots, includepath)
352
353
354 def _checknofilteredinrevs(self, revs):
355 """raise the appropriate error if 'revs' contains a filtered revision
356
357 This returns a version of 'revs' to be used thereafter by the caller.
358 In particular, if revs is an iterator, it is converted into a set.
359 """
360 safehasattr = util.safehasattr
361 if safehasattr(revs, '__next__'):
362 # Note that inspect.isgenerator() is not true for iterators,
363 revs = set(revs)
364
365 filteredrevs = self.filteredrevs
366 if safehasattr(revs, 'first'): # smartset
367 offenders = revs & filteredrevs
368 else:
369 offenders = filteredrevs.intersection(revs)
370
371 for rev in offenders:
372 raise error.FilteredIndexError(rev)
373 return revs
374
353 def headrevs(self, revs=None):
375 def headrevs(self, revs=None):
354 if revs is None and self.filteredrevs:
376 if revs is None and self.filteredrevs:
355 try:
377 try:
@@ -359,6 +381,8 class changelog(revlog.revlog):
359 except AttributeError:
381 except AttributeError:
360 return self._headrevs()
382 return self._headrevs()
361
383
384 if self.filteredrevs:
385 revs = self._checknofilteredinrevs(revs)
362 return super(changelog, self).headrevs(revs)
386 return super(changelog, self).headrevs(revs)
363
387
364 def strip(self, *args, **kwargs):
388 def strip(self, *args, **kwargs):
@@ -1121,7 +1121,7 class revlog(object):
1121 return self.index.headrevs()
1121 return self.index.headrevs()
1122 except AttributeError:
1122 except AttributeError:
1123 return self._headrevs()
1123 return self._headrevs()
1124 return dagop.headrevs(revs, self.parentrevs)
1124 return dagop.headrevs(revs, self._uncheckedparentrevs)
1125
1125
1126 def computephases(self, roots):
1126 def computephases(self, roots):
1127 return self.index.computephasesmapsets(roots)
1127 return self.index.computephasesmapsets(roots)
General Comments 0
You need to be logged in to leave comments. Login now