Mercurial > public > mercurial-scm > hg-stable
diff mercurial/context.py @ 35571:265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
When trying to access filtered revision, it is likely because they have been
obsoleted by an obs-marker. The current message shows how to access the
revision anyway:
abort: hidden revision '13bedc178fce'!
But in the case of an obsoleted revision, the user is likely to want to update
to or use the successor of the revision.
We update the message to display more information about the obsolescence fate
of the revision in the following cases:
abort: hidden revision '13bedc178fce' is pruned!
abort: hidden revision '13bedc178fce' has diverged!
abort: hidden revision '13bedc178fce' was rewritten as X, Y and 2 more!
Differential Revision: https://phab.mercurial-scm.org/D1591
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 05 Jan 2018 09:12:08 +0100 |
parents | 8a0cac20a1ad |
children | cb0db11f392d |
line wrap: on
line diff
--- a/mercurial/context.py Fri Dec 29 03:37:36 2017 +0530 +++ b/mercurial/context.py Fri Jan 05 09:12:08 2018 +0100 @@ -36,6 +36,7 @@ match as matchmod, mdiff, obsolete as obsmod, + obsutil, patch, pathutil, phases, @@ -433,8 +434,21 @@ 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 + + # Check if the changeset is obsolete + unfilteredrepo = repo.unfiltered() + ctx = unfilteredrepo[changeid] + + # If the changeset is obsolete, enrich the hint with the reason that + # made this changeset not visible + if ctx.obsolete(): + reason = obsutil._getfilteredreason(unfilteredrepo, ctx) + msg = _("hidden revision '%s' %s") % (changeid, reason) + 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)