comparison mercurial/context.py @ 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 3e47a40d7a7a
children befefdd34cf8
comparison
equal deleted inserted replaced
32005:2406dbba49bd 32006:c84c83b5df0f
404 if branch: 404 if branch:
405 extra['branch'] = encoding.fromlocal(branch) 405 extra['branch'] = encoding.fromlocal(branch)
406 ctx = memctx(repo, parents, text, files, getfilectx, user, 406 ctx = memctx(repo, parents, text, files, getfilectx, user,
407 date, extra, editor) 407 date, extra, editor)
408 return ctx 408 return ctx
409
410 def _filterederror(repo, changeid):
411 """build an exception to be raised about a filtered changeid
412
413 This is extracted in a function to help extensions (eg: evolve) to
414 experiment with various message variants."""
415 if repo.filtername.startswith('visible'):
416 msg = _("hidden revision '%s'") % changeid
417 hint = _('use --hidden to access hidden revisions')
418 return error.FilteredRepoLookupError(msg, hint=hint)
419 msg = _("filtered revision '%s' (not in '%s' subset)")
420 msg %= (changeid, repo.filtername)
421 return error.FilteredRepoLookupError(msg)
409 422
410 class changectx(basectx): 423 class changectx(basectx):
411 """A changecontext object makes access to data related to a particular 424 """A changecontext object makes access to data related to a particular
412 changeset convenient. It represents a read-only context already present in 425 changeset convenient. It represents a read-only context already present in
413 the repo.""" 426 the repo."""
511 changeid = hex(changeid) 524 changeid = hex(changeid)
512 except TypeError: 525 except TypeError:
513 pass 526 pass
514 except (error.FilteredIndexError, error.FilteredLookupError, 527 except (error.FilteredIndexError, error.FilteredLookupError,
515 error.FilteredRepoLookupError): 528 error.FilteredRepoLookupError):
516 if repo.filtername.startswith('visible'): 529 raise _filterederror(repo, changeid)
517 msg = _("hidden revision '%s'") % changeid
518 hint = _('use --hidden to access hidden revisions')
519 raise error.FilteredRepoLookupError(msg, hint=hint)
520 msg = _("filtered revision '%s' (not in '%s' subset)")
521 msg %= (changeid, repo.filtername)
522 raise error.FilteredRepoLookupError(msg)
523 except IndexError: 530 except IndexError:
524 pass 531 pass
525 raise error.RepoLookupError( 532 raise error.RepoLookupError(
526 _("unknown revision '%s'") % changeid) 533 _("unknown revision '%s'") % changeid)
527 534