Mercurial > public > mercurial-scm > hg
diff mercurial/context.py @ 37385:ecd3f6909184
context: move handling of filtering error to revsymbol() (API)
When changectx's constructor runs into various Filtered*Error, it
creates an exception with a hint about using --hidden. This only makes
sense when the revision was provided by the user (if we get e.g. a
FilteredLookupError from repo[p1], then it's instead a programming
error). Thus, I'm moving the handling into revsymbol(). Also changed
"unfilteredrepo[changeid]" to "revsymbol(unfilteredrepo, changeid)" as
part of the move.
Differential Revision: https://phab.mercurial-scm.org/D3143
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 05 Apr 2018 00:04:09 -0700 |
parents | a6014392837e |
children | 167b22a906f3 |
line wrap: on
line diff
--- a/mercurial/context.py Thu Apr 05 17:56:24 2018 +0530 +++ b/mercurial/context.py Thu Apr 05 00:04:09 2018 -0700 @@ -33,7 +33,6 @@ fileset, match as matchmod, obsolete as obsmod, - obsutil, patch, pathutil, phases, @@ -378,31 +377,6 @@ return r -def _filterederror(repo, changeid): - """build an exception to be raised about a filtered changeid - - This is extracted in a function to help extensions (eg: evolve) to - experiment with various message variants.""" - if repo.filtername.startswith('visible'): - - # Check if the changeset is obsolete - unfilteredrepo = repo.unfiltered() - ctx = unfilteredrepo[changeid] - - # If the changeset is obsolete, enrich the message with the reason - # that made this changeset not visible - if ctx.obsolete(): - msg = obsutil._getfilteredreason(repo, changeid, ctx) - else: - msg = _("hidden revision '%s'") % changeid - - hint = _('use --hidden to access hidden revisions') - - return error.FilteredRepoLookupError(msg, hint=hint) - msg = _("filtered revision '%s' (not in '%s' subset)") - msg %= (changeid, repo.filtername) - return error.FilteredRepoLookupError(msg) - class changectx(basectx): """A changecontext object makes access to data related to a particular changeset convenient. It represents a read-only context already present in @@ -501,7 +475,7 @@ pass except (error.FilteredIndexError, error.FilteredLookupError, error.FilteredRepoLookupError): - raise _filterederror(repo, changeid) + raise except IndexError: pass raise error.RepoLookupError(