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
--- a/mercurial/scmutil.py Fri Apr 06 23:39:40 2018 -0700
+++ b/mercurial/scmutil.py Fri Apr 06 23:43:52 2018 -0700
@@ -18,6 +18,7 @@
from .i18n import _
from .node import (
+ bin,
hex,
nullid,
short,
@@ -479,8 +480,20 @@
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)