D7257: [RFC] repoview: add a "filter" that just disallows walking to heads
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Nov 6 17:04:29 UTC 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D7257
AFFECTED FILES
mercurial/commands.py
mercurial/repoview.py
CHANGE DETAILS
diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -168,6 +168,7 @@
# Otherwise your filter will have to recompute all its branches cache
# from scratch (very slow).
filtertable = {
+ b'notreally': lambda repo, visibilityexceptions=None: frozenset(),
b'visible': computehidden,
b'visible-hidden': computehidden,
b'served.hidden': computesecret,
@@ -331,6 +332,24 @@
return cl
+def poisonwalktoheads(unfichangelog):
+ cl = copy.copy(unfichangelog)
+
+ def poison(*args, **kwargs):
+ raise error.ProgrammingError('called method on changelog that requries '
+ 'filtering, but filtering was not requested')
+
+ class filteredchangelog(cl.__class__):
+ tiprev = poison
+ headrevs = poison
+ __iter__ = poison
+ children = poison
+
+ cl.__class__ = filteredchangelog
+
+ return cl
+
+
class repoview(object):
"""Provide a read/write view of a repo through a filtered changelog
@@ -399,8 +418,13 @@
cl = None
# could have been made None by the previous if
if cl is None:
- # Only filter if there's something to filter
- cl = wrapchangelog(unfichangelog, revs) if revs else unfichangelog
+ if self.filtername == b'notreally':
+ cl = poisonwalktoheads(unfichangelog)
+ elif revs:
+ # Only filter if there's something to filter
+ cl = wrapchangelog(unfichangelog, revs)
+ else:
+ cl = unfichangelog
object.__setattr__(self, r'_clcache', cl)
object.__setattr__(self, r'_clcachekey', newkey)
return cl
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6793,7 +6793,7 @@
if not revs and not change:
# Avoid loading obsmarkers if we're accessing only the working copy
# parent (which will never be hidden).
- repo = repo.unfiltered()
+ repo = repo.filtered(b'notreally')
if revs and change:
msg = _(b'cannot specify --rev and --change at the same time')
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list