Mercurial > hg
changeset 32006:c84c83b5df0f
hidden: extract the code generating "filtered rev" error for wrapping
The goal is to help experimentation in extensions (ie: evolve) around more
advance messages.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sat, 15 Apr 2017 18:13:10 +0200 |
parents | 2406dbba49bd |
children | f12b6185d435 |
files | mercurial/context.py |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Sat Apr 15 18:05:40 2017 -0400 +++ b/mercurial/context.py Sat Apr 15 18:13:10 2017 +0200 @@ -407,6 +407,19 @@ date, extra, editor) return ctx +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'): + 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 @@ -513,13 +526,7 @@ pass except (error.FilteredIndexError, error.FilteredLookupError, error.FilteredRepoLookupError): - if repo.filtername.startswith('visible'): - msg = _("hidden revision '%s'") % changeid - hint = _('use --hidden to access hidden revisions') - raise error.FilteredRepoLookupError(msg, hint=hint) - msg = _("filtered revision '%s' (not in '%s' subset)") - msg %= (changeid, repo.filtername) - raise error.FilteredRepoLookupError(msg) + raise _filterederror(repo, changeid) except IndexError: pass raise error.RepoLookupError(