context: handle stringified ints in revsymbol()
This patch copies the handling of stringified ints from changectx's
constructor. It then calls repo.__getitem__ with the int. Since that
method only interprets integers as revnums the first thing it does,
this will not be redoing any of the work already done. We leave the
old code in place so we can later deprecate it instead of breaking
extensions.
Differential Revision: https://phab.mercurial-scm.org/D3146
--- a/mercurial/scmutil.py Tue Apr 10 19:32:08 2018 +0530
+++ b/mercurial/scmutil.py Fri Apr 06 23:39:40 2018 -0700
@@ -461,7 +461,26 @@
"repo[symbol]?" % (symbol, type(symbol)))
raise error.ProgrammingError(msg)
try:
+ if symbol in ('.', 'tip', 'null'):
+ return repo[symbol]
+
+ try:
+ r = int(symbol)
+ if '%d' % r != symbol:
+ raise ValueError
+ l = len(repo.changelog)
+ if r < 0:
+ r += l
+ if r < 0 or r >= l and r != wdirrev:
+ raise ValueError
+ return repo[r]
+ except error.FilteredIndexError:
+ raise
+ except (ValueError, OverflowError, IndexError):
+ pass
+
return repo[symbol]
+
except (error.FilteredIndexError, error.FilteredLookupError,
error.FilteredRepoLookupError):
raise _filterederror(repo, symbol)