mercurial/scmutil.py
changeset 37271 0194dac77c93
parent 37269 14cd5290c4e6
child 37306 6942c73f0733
equal deleted inserted replaced
37270:6ff8bd691fb8 37271:0194dac77c93
   431         hexfunc = hex
   431         hexfunc = hex
   432     else:
   432     else:
   433         hexfunc = short
   433         hexfunc = short
   434     return '%d:%s' % (rev, hexfunc(node))
   434     return '%d:%s' % (rev, hexfunc(node))
   435 
   435 
       
   436 def revsymbol(repo, symbol):
       
   437     """Returns a context given a single revision symbol (as string).
       
   438 
       
   439     This is similar to revsingle(), but accepts only a single revision symbol,
       
   440     i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but
       
   441     not "max(public())".
       
   442     """
       
   443     if not isinstance(symbol, bytes):
       
   444         msg = ("symbol (%s of type %s) was not a string, did you mean "
       
   445                "repo[symbol]?" % (symbol, type(symbol)))
       
   446         raise error.ProgrammingError(msg)
       
   447     return repo[symbol]
       
   448 
   436 def revsingle(repo, revspec, default='.', localalias=None):
   449 def revsingle(repo, revspec, default='.', localalias=None):
   437     if not revspec and revspec != 0:
   450     if not revspec and revspec != 0:
   438         return repo[default]
   451         return repo[default]
   439 
   452 
   440     l = revrange(repo, [revspec], localalias=localalias)
   453     l = revrange(repo, [revspec], localalias=localalias)