Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/changelog.py (35 lines) | |||
M | mercurial/repoview.py (35 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
from .thirdparty import attr | from .thirdparty import attr | ||||
from . import ( | from . import ( | ||||
copies, | copies, | ||||
encoding, | encoding, | ||||
error, | error, | ||||
pycompat, | pycompat, | ||||
revlog, | revlog, | ||||
util, | |||||
) | ) | ||||
from .utils import ( | from .utils import ( | ||||
dateutil, | dateutil, | ||||
stringutil, | stringutil, | ||||
) | ) | ||||
from .revlogutils import sidedata as sidedatamod | from .revlogutils import sidedata as sidedatamod | ||||
self._realopener = opener | self._realopener = opener | ||||
self._delayed = False | self._delayed = False | ||||
self._delaybuf = None | self._delaybuf = None | ||||
self._divert = False | self._divert = False | ||||
self.filteredrevs = frozenset() | self.filteredrevs = frozenset() | ||||
self._copiesstorage = opener.options.get(b'copies-storage') | self._copiesstorage = opener.options.get(b'copies-storage') | ||||
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: | |||||
return self.index.headrevsfiltered(self.filteredrevs) | |||||
# AttributeError covers non-c-extension environments and | |||||
# old c extensions without filter handling. | |||||
except AttributeError: | |||||
return self._headrevs() | |||||
if self.filteredrevs: | |||||
revs = self._checknofilteredinrevs(revs) | |||||
return super(changelog, self).headrevs(revs) | |||||
def strip(self, *args, **kwargs): | def strip(self, *args, **kwargs): | ||||
# XXX make something better than assert | # XXX make something better than assert | ||||
# We can't expect proper strip behavior if we are filtered. | # We can't expect proper strip behavior if we are filtered. | ||||
assert not self.filteredrevs | assert not self.filteredrevs | ||||
super(changelog, self).strip(*args, **kwargs) | super(changelog, self).strip(*args, **kwargs) | ||||
def rev(self, node): | def rev(self, node): | ||||
"""filtered version of revlog.rev""" | """filtered version of revlog.rev""" |
from .node import nullrev | from .node import nullrev | ||||
from .pycompat import ( | from .pycompat import ( | ||||
delattr, | delattr, | ||||
getattr, | getattr, | ||||
setattr, | setattr, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
error, | |||||
obsolete, | obsolete, | ||||
phases, | phases, | ||||
pycompat, | pycompat, | ||||
revlog, | revlog, | ||||
tags as tagsmod, | tags as tagsmod, | ||||
util, | util, | ||||
) | ) | ||||
from .utils import repoviewutil | from .utils import repoviewutil | ||||
return filterediter() | return filterediter() | ||||
def revs(self, start=0, stop=None): | def revs(self, start=0, stop=None): | ||||
"""filtered version of revlog.revs""" | """filtered version of revlog.revs""" | ||||
for i in super(filteredchangelog, self).revs(start, stop): | for i in super(filteredchangelog, self).revs(start, stop): | ||||
if i not in self.filteredrevs: | if i not in self.filteredrevs: | ||||
yield i | yield i | ||||
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: | |||||
return self.index.headrevsfiltered(self.filteredrevs) | |||||
# AttributeError covers non-c-extension environments and | |||||
# old c extensions without filter handling. | |||||
except AttributeError: | |||||
return self._headrevs() | |||||
if self.filteredrevs: | |||||
revs = self._checknofilteredinrevs(revs) | |||||
return super(filteredchangelog, self).headrevs(revs) | |||||
cl.__class__ = filteredchangelog | cl.__class__ = filteredchangelog | ||||
return cl | return cl | ||||
class repoview(object): | class repoview(object): | ||||
"""Provide a read/write view of a repo through a filtered changelog | """Provide a read/write view of a repo through a filtered changelog | ||||
This object is used to access a filtered version of a repository without | This object is used to access a filtered version of a repository without |