author | Georges Racinet <georges.racinet@octobus.net> |
Wed, 20 Feb 2019 11:49:06 +0100 | |
changeset 41763 | 6843379bf99e |
parent 41762 | cde37ed080c9 |
child 41764 | 37ead13fb3d4 |
mercurial/changelog.py | file | annotate | diff | comparison | revisions | |
mercurial/revlog.py | file | annotate | diff | comparison | revisions |
--- a/mercurial/changelog.py Thu Feb 21 11:23:10 2019 +0100 +++ b/mercurial/changelog.py Wed Feb 20 11:49:06 2019 +0100 @@ -22,6 +22,7 @@ error, pycompat, revlog, + util, ) from .utils import ( dateutil, @@ -350,6 +351,27 @@ def reachableroots(self, minroot, heads, roots, includepath=False): return self.index.reachableroots2(minroot, heads, roots, includepath) + def _checknofilteredinrevs(self, revs): + """raise the appropriate error if 'revs' contains a filtered revision + + This returns a version of 'revs' to be used thereafter by the caller. + In particular, if revs is an iterator, it is converted into a set. + """ + safehasattr = util.safehasattr + if safehasattr(revs, '__next__'): + # Note that inspect.isgenerator() is not true for iterators, + revs = set(revs) + + filteredrevs = self.filteredrevs + if safehasattr(revs, 'first'): # smartset + offenders = revs & filteredrevs + else: + offenders = filteredrevs.intersection(revs) + + for rev in offenders: + raise error.FilteredIndexError(rev) + return revs + def headrevs(self, revs=None): if revs is None and self.filteredrevs: try: @@ -359,6 +381,8 @@ except AttributeError: return self._headrevs() + if self.filteredrevs: + revs = self._checknofilteredinrevs(revs) return super(changelog, self).headrevs(revs) def strip(self, *args, **kwargs):
--- a/mercurial/revlog.py Thu Feb 21 11:23:10 2019 +0100 +++ b/mercurial/revlog.py Wed Feb 20 11:49:06 2019 +0100 @@ -1121,7 +1121,7 @@ return self.index.headrevs() except AttributeError: return self._headrevs() - return dagop.headrevs(revs, self.parentrevs) + return dagop.headrevs(revs, self._uncheckedparentrevs) def computephases(self, roots): return self.index.computephasesmapsets(roots)