mercurial/changelog.py
changeset 41763 6843379bf99e
parent 41574 b436059c1cca
child 41831 ae189674bdad
equal deleted inserted replaced
41762:cde37ed080c9 41763:6843379bf99e
    20 from . import (
    20 from . import (
    21     encoding,
    21     encoding,
    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,
    28     stringutil,
    29     stringutil,
    29 )
    30 )
   348                 yield i
   349                 yield i
   349 
   350 
   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:
   356                 return self.index.headrevsfiltered(self.filteredrevs)
   378                 return self.index.headrevsfiltered(self.filteredrevs)
   357             # AttributeError covers non-c-extension environments and
   379             # AttributeError covers non-c-extension environments and
   358             # old c extensions without filter handling.
   380             # old c extensions without filter handling.
   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):
   365         # XXX make something better than assert
   389         # XXX make something better than assert
   366         # We can't expect proper strip behavior if we are filtered.
   390         # We can't expect proper strip behavior if we are filtered.