diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -118,7 +118,7 @@ def stringset(repo, subset, x, order): if not x: raise error.ParseError(_("empty string is not a valid revision")) - x = scmutil.intrev(repo[x]) + x = scmutil.intrev(scmutil.revsymbol(repo, x)) if (x in subset or x == node.nullrev and isinstance(subset, fullreposet)): return baseset([x]) diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -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]