comparison tests/test-revlog.t @ 32392:36d3559c69a6

revlog: tweak wording and logic for flags validation First, the logic around the if..elif..elif was subtly wrong and sub-optimal because all branches would be tested as long as the revlog was valid. This patch changes things so it behaves like a switch statement over the revlog version. While I was here, I also tweaked error strings to make them consistent and to read better.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 19 May 2017 20:10:50 -0700
parents 3ea1f1e71a0a
children 71d1bbf1617e
comparison
equal deleted inserted replaced
32391:3ea1f1e71a0a 32392:36d3559c69a6
5 5
6 >>> with open('.hg/store/00changelog.i', 'wb') as fh: 6 >>> with open('.hg/store/00changelog.i', 'wb') as fh:
7 ... fh.write('\x00\x01\x00\x00') 7 ... fh.write('\x00\x01\x00\x00')
8 8
9 $ hg log 9 $ hg log
10 abort: index 00changelog.i unknown flags 0x01 for format v0! 10 abort: unknown flags (0x01) in version 0 revlog 00changelog.i!
11 [255] 11 [255]
12 12
13 Unknown flags on revlog version 1 are rejected 13 Unknown flags on revlog version 1 are rejected
14 14
15 >>> with open('.hg/store/00changelog.i', 'wb') as fh: 15 >>> with open('.hg/store/00changelog.i', 'wb') as fh:
16 ... fh.write('\x00\x04\x00\x01') 16 ... fh.write('\x00\x04\x00\x01')
17 17
18 $ hg log 18 $ hg log
19 abort: index 00changelog.i unknown flags 0x04 for revlogng! 19 abort: unknown flags (0x04) in version 1 revlog 00changelog.i!
20 [255] 20 [255]
21 21
22 Unknown version is rejected 22 Unknown version is rejected
23 23
24 >>> with open('.hg/store/00changelog.i', 'wb') as fh: 24 >>> with open('.hg/store/00changelog.i', 'wb') as fh:
25 ... fh.write('\x00\x00\x00\x02') 25 ... fh.write('\x00\x00\x00\x02')
26 26
27 $ hg log 27 $ hg log
28 abort: index 00changelog.i unknown format 2! 28 abort: unknown version (2) in revlog 00changelog.i!
29 [255] 29 [255]
30 30
31 $ cd .. 31 $ cd ..
32 32
33 Test for CVE-2016-3630 33 Test for CVE-2016-3630