comparison 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
comparison
equal deleted inserted replaced
35570:3e3f4c03876b 35571:265cd9e19d26
34 error, 34 error,
35 fileset, 35 fileset,
36 match as matchmod, 36 match as matchmod,
37 mdiff, 37 mdiff,
38 obsolete as obsmod, 38 obsolete as obsmod,
39 obsutil,
39 patch, 40 patch,
40 pathutil, 41 pathutil,
41 phases, 42 phases,
42 pycompat, 43 pycompat,
43 repoview, 44 repoview,
431 """build an exception to be raised about a filtered changeid 432 """build an exception to be raised about a filtered changeid
432 433
433 This is extracted in a function to help extensions (eg: evolve) to 434 This is extracted in a function to help extensions (eg: evolve) to
434 experiment with various message variants.""" 435 experiment with various message variants."""
435 if repo.filtername.startswith('visible'): 436 if repo.filtername.startswith('visible'):
436 msg = _("hidden revision '%s'") % changeid 437
438 # Check if the changeset is obsolete
439 unfilteredrepo = repo.unfiltered()
440 ctx = unfilteredrepo[changeid]
441
442 # If the changeset is obsolete, enrich the hint with the reason that
443 # made this changeset not visible
444 if ctx.obsolete():
445 reason = obsutil._getfilteredreason(unfilteredrepo, ctx)
446 msg = _("hidden revision '%s' %s") % (changeid, reason)
447 else:
448 msg = _("hidden revision '%s'") % changeid
449
437 hint = _('use --hidden to access hidden revisions') 450 hint = _('use --hidden to access hidden revisions')
451
438 return error.FilteredRepoLookupError(msg, hint=hint) 452 return error.FilteredRepoLookupError(msg, hint=hint)
439 msg = _("filtered revision '%s' (not in '%s' subset)") 453 msg = _("filtered revision '%s' (not in '%s' subset)")
440 msg %= (changeid, repo.filtername) 454 msg %= (changeid, repo.filtername)
441 return error.FilteredRepoLookupError(msg) 455 return error.FilteredRepoLookupError(msg)
442 456