# HG changeset patch # User Martin von Zweigbergk # Date 1523083180 25200 # Node ID 1c09481acdcc5ee9b428f57a66fa659bdabaa60a # Parent f5ffcac66c0240ce7a3f2938b4200a9a59e60df3 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 diff -r f5ffcac66c02 -r 1c09481acdcc mercurial/scmutil.py --- 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)