D3146: context: handle stringified ints in revsymbol()
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1c09481acdcc: context: handle stringified ints in revsymbol() (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3146?vs=7884=7973 REVISION DETAIL https://phab.mercurial-scm.org/D3146 AFFECTED FILES mercurial/scmutil.py CHANGE DETAILS diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -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) To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3146: context: handle stringified ints in revsymbol()
martinvonz updated this revision to Diff 7884. martinvonz edited the summary of this revision. martinvonz retitled this revision from "context: move handling of stringified ints to revsymbol (API)" to "context: handle stringified ints in revsymbol()". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3146?vs=7757=7884 REVISION DETAIL https://phab.mercurial-scm.org/D3146 AFFECTED FILES mercurial/scmutil.py CHANGE DETAILS diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -457,7 +457,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) To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel