mercurial/context.py
changeset 37385 ecd3f6909184
parent 37354 a6014392837e
child 37386 167b22a906f3
equal deleted inserted replaced
37384:5c9d0af7b02e 37385:ecd3f6909184
    31     encoding,
    31     encoding,
    32     error,
    32     error,
    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,
    40     pycompat,
    39     pycompat,
    41     repoview,
    40     repoview,
   376         for l in r:
   375         for l in r:
   377             l.sort()
   376             l.sort()
   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
   409     the repo."""
   383     the repo."""
   410     def __init__(self, repo, changeid='.'):
   384     def __init__(self, repo, changeid='.'):
   499                     changeid = hex(changeid)
   473                     changeid = hex(changeid)
   500             except TypeError:
   474             except TypeError:
   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(
   508             _("unknown revision '%s'") % changeid)
   482             _("unknown revision '%s'") % changeid)
   509 
   483