##// END OF EJS Templates
context: move handling of filtering error to revsymbol() (API)...
Martin von Zweigbergk -
r37403:ecd3f690 default
parent child Browse files
Show More
@@ -33,7 +33,6 b' from . import ('
33 fileset,
33 fileset,
34 match as matchmod,
34 match as matchmod,
35 obsolete as obsmod,
35 obsolete as obsmod,
36 obsutil,
37 patch,
36 patch,
38 pathutil,
37 pathutil,
39 phases,
38 phases,
@@ -378,31 +377,6 b' class basectx(object):'
378
377
379 return r
378 return r
380
379
381 def _filterederror(repo, changeid):
382 """build an exception to be raised about a filtered changeid
383
384 This is extracted in a function to help extensions (eg: evolve) to
385 experiment with various message variants."""
386 if repo.filtername.startswith('visible'):
387
388 # Check if the changeset is obsolete
389 unfilteredrepo = repo.unfiltered()
390 ctx = unfilteredrepo[changeid]
391
392 # If the changeset is obsolete, enrich the message with the reason
393 # that made this changeset not visible
394 if ctx.obsolete():
395 msg = obsutil._getfilteredreason(repo, changeid, ctx)
396 else:
397 msg = _("hidden revision '%s'") % changeid
398
399 hint = _('use --hidden to access hidden revisions')
400
401 return error.FilteredRepoLookupError(msg, hint=hint)
402 msg = _("filtered revision '%s' (not in '%s' subset)")
403 msg %= (changeid, repo.filtername)
404 return error.FilteredRepoLookupError(msg)
405
406 class changectx(basectx):
380 class changectx(basectx):
407 """A changecontext object makes access to data related to a particular
381 """A changecontext object makes access to data related to a particular
408 changeset convenient. It represents a read-only context already present in
382 changeset convenient. It represents a read-only context already present in
@@ -501,7 +475,7 b' class changectx(basectx):'
501 pass
475 pass
502 except (error.FilteredIndexError, error.FilteredLookupError,
476 except (error.FilteredIndexError, error.FilteredLookupError,
503 error.FilteredRepoLookupError):
477 error.FilteredRepoLookupError):
504 raise _filterederror(repo, changeid)
478 raise
505 except IndexError:
479 except IndexError:
506 pass
480 pass
507 raise error.RepoLookupError(
481 raise error.RepoLookupError(
@@ -802,7 +802,8 b' class localrepository(object):'
802 try:
802 try:
803 self[changeid]
803 self[changeid]
804 return True
804 return True
805 except error.RepoLookupError:
805 except (error.RepoLookupError, error.FilteredIndexError,
806 error.FilteredLookupError):
806 return False
807 return False
807
808
808 def __nonzero__(self):
809 def __nonzero__(self):
@@ -451,7 +451,36 b' def revsymbol(repo, symbol):'
451 msg = ("symbol (%s of type %s) was not a string, did you mean "
451 msg = ("symbol (%s of type %s) was not a string, did you mean "
452 "repo[symbol]?" % (symbol, type(symbol)))
452 "repo[symbol]?" % (symbol, type(symbol)))
453 raise error.ProgrammingError(msg)
453 raise error.ProgrammingError(msg)
454 try:
454 return repo[symbol]
455 return repo[symbol]
456 except (error.FilteredIndexError, error.FilteredLookupError,
457 error.FilteredRepoLookupError):
458 raise _filterederror(repo, symbol)
459
460 def _filterederror(repo, changeid):
461 """build an exception to be raised about a filtered changeid
462
463 This is extracted in a function to help extensions (eg: evolve) to
464 experiment with various message variants."""
465 if repo.filtername.startswith('visible'):
466
467 # Check if the changeset is obsolete
468 unfilteredrepo = repo.unfiltered()
469 ctx = revsymbol(unfilteredrepo, changeid)
470
471 # If the changeset is obsolete, enrich the message with the reason
472 # that made this changeset not visible
473 if ctx.obsolete():
474 msg = obsutil._getfilteredreason(repo, changeid, ctx)
475 else:
476 msg = _("hidden revision '%s'") % changeid
477
478 hint = _('use --hidden to access hidden revisions')
479
480 return error.FilteredRepoLookupError(msg, hint=hint)
481 msg = _("filtered revision '%s' (not in '%s' subset)")
482 msg %= (changeid, repo.filtername)
483 return error.FilteredRepoLookupError(msg)
455
484
456 def revsingle(repo, revspec, default='.', localalias=None):
485 def revsingle(repo, revspec, default='.', localalias=None):
457 if not revspec and revspec != 0:
486 if not revspec and revspec != 0:
General Comments 0
You need to be logged in to leave comments. Login now