diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -2210,7 +2210,7 @@ treebystage = {} printedtree = None - tree = revsetlang.parse(expr, lookup=repo.__contains__) + tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo)) for n, f in stages: treebystage[n] = tree = f(tree) if n in showalways or (n in showchanged and tree != printedtree): diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2170,6 +2170,9 @@ # hook for extensions to execute code on the optimized tree pass +def lookupfn(repo): + return lambda symbol: scmutil.isrevsymbol(repo, symbol) + def match(ui, spec, repo=None): """Create a matcher for a single revision spec""" return matchany(ui, [spec], repo=repo) @@ -2189,7 +2192,7 @@ raise error.ParseError(_("empty query")) lookup = None if repo: - lookup = repo.__contains__ + lookup = lookupfn(repo) if len(specs) == 1: tree = revsetlang.parse(specs[0], lookup) else: diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -433,6 +433,13 @@ hexfunc = short return '%d:%s' % (rev, hexfunc(node)) +def isrevsymbol(repo, symbol): + try: + revsymbol(repo, symbol) + return True + except error.RepoLookupError: + return False + def revsymbol(repo, symbol): """Returns a context given a single revision symbol (as string). diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -54,7 +54,7 @@ > args = map(nodemod.bin, args) > expr = revsetlang.formatspec(fmt, list(args)) > if ui.verbose: - > tree = revsetlang.parse(expr, lookup=repo.__contains__) + > tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo)) > ui.note(revsetlang.prettyformat(tree), b"\n") > if opts["optimize"]: > opttree = revsetlang.optimize(revsetlang.analyze(tree))