mercurial/scmutil.py
changeset 37271 0194dac77c93
parent 37269 14cd5290c4e6
child 37306 6942c73f0733
--- a/mercurial/scmutil.py	Mon Apr 02 23:52:43 2018 -0700
+++ b/mercurial/scmutil.py	Mon Apr 02 16:18:33 2018 -0700
@@ -433,6 +433,19 @@
         hexfunc = short
     return '%d:%s' % (rev, hexfunc(node))
 
+def revsymbol(repo, symbol):
+    """Returns a context given a single revision symbol (as string).
+
+    This is similar to revsingle(), but accepts only a single revision symbol,
+    i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but
+    not "max(public())".
+    """
+    if not isinstance(symbol, bytes):
+        msg = ("symbol (%s of type %s) was not a string, did you mean "
+               "repo[symbol]?" % (symbol, type(symbol)))
+        raise error.ProgrammingError(msg)
+    return repo[symbol]
+
 def revsingle(repo, revspec, default='.', localalias=None):
     if not revspec and revspec != 0:
         return repo[default]