mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
hiddenerror: fix out of bounds error
Summary: The current code checks if the filter error reports a rev number, and if it does tries to convert it to a node. If the 'number' is actually just a short form of a hash that happens to be all digits, then it may be a number greater than the size of the changelog, so we need to not attempt to access it in the changelog, otherwise we get an IndexError. Test Plan: Added a test, it failed before with a weird error Reviewers: #mercurial, kulshrax Reviewed By: kulshrax Subscribers: mjpieters Differential Revision: https://phabricator.intern.facebook.com/D4613988 Signature: t1:4613988:1488027938:4f5ffcb07aeecbaf59cad20fb3a592dd92ed2beb
This commit is contained in:
parent
7ced159e51
commit
2bc65bd9db
@ -41,7 +41,14 @@ def uisetup(ui):
|
||||
raise
|
||||
|
||||
rev = int(match.group(1))
|
||||
node = repo.unfiltered().changelog.node(rev)
|
||||
cl = repo.unfiltered().changelog
|
||||
|
||||
# If the number is beyond the changelog, it's a short hash that
|
||||
# just happened to be a number.
|
||||
if rev >= len(cl):
|
||||
raise
|
||||
|
||||
node = cl.node(rev)
|
||||
shorthash = short(node)
|
||||
|
||||
# Get the error messages from the user's configuration and
|
||||
|
@ -39,6 +39,12 @@ Test custom error message with hash.
|
||||
(hint with hash 1ea73414a91b)
|
||||
[255]
|
||||
|
||||
Test accessing a rev beyond the end of the repo
|
||||
$ hg log -r 1
|
||||
abort: hidden revision '1'!
|
||||
(use --hidden to access hidden revisions)
|
||||
[255]
|
||||
|
||||
Test that basic operations like `status` don't throw an exception due
|
||||
to the wrapped context constructor.
|
||||
$ hg status
|
||||
|
Loading…
Reference in New Issue
Block a user