# HG changeset patch # User Martin von Zweigbergk # Date 2018-04-07 06:43:52 # Node ID d2b484eed1ecc06117dfaf46725701e80318f894 # Parent 1c09481acdcc5ee9b428f57a66fa659bdabaa60a scmutil: handle full hex nodeids in revsymbol() This is a bit unfortunate, but it enables moving other pieces out of changectx's constructor without affecting the order in which we look up things (e.g. hex nodeid before bookmark). We convert nodeid to revnum before calling repo.__getitem__, even though that will result in converting back to nodeid later. This is so we can handle the LookupError and attempt to interpret the string as something else (e.g. a bookmark). We also need to start handling WdirUnsupported now, since the full hex nodeid "ffff..." represents the working directory. The exception is raised by the revlog layer. Differential Revision: https://phab.mercurial-scm.org/D3193 diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -18,6 +18,7 @@ import weakref from .i18n import _ from .node import ( + bin, hex, nullid, short, @@ -479,8 +480,20 @@ def revsymbol(repo, symbol): except (ValueError, OverflowError, IndexError): pass + if len(symbol) == 40: + try: + node = bin(symbol) + rev = repo.changelog.rev(node) + return repo[rev] + except error.FilteredLookupError: + raise + except (TypeError, LookupError): + pass + return repo[symbol] + except error.WdirUnsupported: + return repo[None] except (error.FilteredIndexError, error.FilteredLookupError, error.FilteredRepoLookupError): raise _filterederror(repo, symbol)