comparison mercurial/scmutil.py @ 37527:1c09481acdcc

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
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 06 Apr 2018 23:39:40 -0700
parents 901e749ca0e1
children d2b484eed1ec
comparison
equal deleted inserted replaced
37526:f5ffcac66c02 37527:1c09481acdcc
459 if not isinstance(symbol, bytes): 459 if not isinstance(symbol, bytes):
460 msg = ("symbol (%s of type %s) was not a string, did you mean " 460 msg = ("symbol (%s of type %s) was not a string, did you mean "
461 "repo[symbol]?" % (symbol, type(symbol))) 461 "repo[symbol]?" % (symbol, type(symbol)))
462 raise error.ProgrammingError(msg) 462 raise error.ProgrammingError(msg)
463 try: 463 try:
464 if symbol in ('.', 'tip', 'null'):
465 return repo[symbol]
466
467 try:
468 r = int(symbol)
469 if '%d' % r != symbol:
470 raise ValueError
471 l = len(repo.changelog)
472 if r < 0:
473 r += l
474 if r < 0 or r >= l and r != wdirrev:
475 raise ValueError
476 return repo[r]
477 except error.FilteredIndexError:
478 raise
479 except (ValueError, OverflowError, IndexError):
480 pass
481
464 return repo[symbol] 482 return repo[symbol]
483
465 except (error.FilteredIndexError, error.FilteredLookupError, 484 except (error.FilteredIndexError, error.FilteredLookupError,
466 error.FilteredRepoLookupError): 485 error.FilteredRepoLookupError):
467 raise _filterederror(repo, symbol) 486 raise _filterederror(repo, symbol)
468 487
469 def _filterederror(repo, changeid): 488 def _filterederror(repo, changeid):