Mercurial > hg
annotate tests/test-parseindex2.py @ 51990:4b347e9429e7
tests: stabilize `test-split-legacy-inline-changelog.t` on Windows
The `tar` command is unable to process "C:\path\to\foo.tar" style paths, which
is how `$TESTDIR` is constructed. It also didn't work with
`$TESTDIR_FORWARD_SLASH`- both failed with:
tar: Cannot connect to C: resolve failed
[128]
But `cat` can handle it if the path is quoted, and `tar` can read from stdin.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 07 Oct 2024 21:48:36 -0400 |
parents | ca7bde5dbafb |
children | e08c878b5571 |
rev | line source |
---|---|
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
1 """This unit test primarily tests parsers.parse_index2(). |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
2 |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
3 It also checks certain aspects of the parsers module as a whole. |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
4 """ |
20166
7eda5bb9ec8f
parsers: clarify documentation of test-parseindex2.py
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20159
diff
changeset
|
5 |
28841
e155b8d5e3b7
tests: move stdlib imports before mercurial modules in test-parseindex2
Yuya Nishihara <yuya@tcha.org>
parents:
28754
diff
changeset
|
6 |
45829
e7a4c018b563
tests: use python from environment in test-parseindex2.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
43946
diff
changeset
|
7 import os |
28841
e155b8d5e3b7
tests: move stdlib imports before mercurial modules in test-parseindex2
Yuya Nishihara <yuya@tcha.org>
parents:
28754
diff
changeset
|
8 import struct |
e155b8d5e3b7
tests: move stdlib imports before mercurial modules in test-parseindex2
Yuya Nishihara <yuya@tcha.org>
parents:
28754
diff
changeset
|
9 import subprocess |
e155b8d5e3b7
tests: move stdlib imports before mercurial modules in test-parseindex2
Yuya Nishihara <yuya@tcha.org>
parents:
28754
diff
changeset
|
10 import sys |
38989
01966d45b45e
tests: start moving test-parseindex2.py to a unittest
Augie Fackler <augie@google.com>
parents:
38852
diff
changeset
|
11 import unittest |
28841
e155b8d5e3b7
tests: move stdlib imports before mercurial modules in test-parseindex2
Yuya Nishihara <yuya@tcha.org>
parents:
28754
diff
changeset
|
12 |
28753
0c2295384eea
py3: use absolute_import in test-parseindex2.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
27637
diff
changeset
|
13 from mercurial.node import ( |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45829
diff
changeset
|
14 bin, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45829
diff
changeset
|
15 hex, |
28753
0c2295384eea
py3: use absolute_import in test-parseindex2.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
27637
diff
changeset
|
16 nullrev, |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46704
diff
changeset
|
17 sha1nodeconstants, |
28753
0c2295384eea
py3: use absolute_import in test-parseindex2.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
27637
diff
changeset
|
18 ) |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28841
diff
changeset
|
19 from mercurial import ( |
32372
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
29205
diff
changeset
|
20 policy, |
38095
3de58f50afa2
tests: fix test-parseindex2 on Python 3
Augie Fackler <augie@google.com>
parents:
37894
diff
changeset
|
21 pycompat, |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28841
diff
changeset
|
22 ) |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
23 from mercurial.revlogutils import ( |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
24 constants, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
25 ) |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
26 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
27 parsers = policy.importmod('parsers') |
32372
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
29205
diff
changeset
|
28 |
51703
ca7bde5dbafb
black: format the codebase with 23.3.0
Raphaël Gomès <rgomes@octobus.net>
parents:
51700
diff
changeset
|
29 |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
30 # original python implementation |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
31 def gettype(q): |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
32 return int(q & 0xFFFF) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
33 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
34 |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
35 def offset_type(offset, type): |
37894
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
36 return int(int(offset) << 16 | type) |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
37 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
38 |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
39 indexformatng = ">Qiiiiii20s12x" |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
40 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
41 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
42 def py_parseindex(data, inline): |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
43 s = 64 |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
44 cache = None |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
45 index = [] |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46704
diff
changeset
|
46 nodemap = {sha1nodeconstants.nullid: nullrev} |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
47 n = off = 0 |
13253 | 48 |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
49 l = len(data) - s |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
50 append = index.append |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
51 if inline: |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
52 cache = (0, data) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
53 while off <= l: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
54 e = struct.unpack(indexformatng, data[off : off + s]) |
47256
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
55 e = e + ( |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
56 0, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
57 0, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
58 constants.COMP_MODE_INLINE, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
59 constants.COMP_MODE_INLINE, |
48499
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47256
diff
changeset
|
60 constants.RANK_UNKNOWN, |
47256
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
61 ) |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
62 nodemap[e[7]] = n |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
63 append(e) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
64 n += 1 |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
65 if e[1] < 0: |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
66 break |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
67 off += e[1] + s |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
68 else: |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
69 while off <= l: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
70 e = struct.unpack(indexformatng, data[off : off + s]) |
47256
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
71 e = e + ( |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
72 0, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
73 0, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
74 constants.COMP_MODE_INLINE, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
75 constants.COMP_MODE_INLINE, |
48499
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47256
diff
changeset
|
76 constants.RANK_UNKNOWN, |
47256
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
77 ) |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
78 nodemap[e[7]] = n |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
79 append(e) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
80 n += 1 |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
81 off += s |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
82 |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
83 e = list(index[0]) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
84 type = gettype(e[0]) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
85 e[0] = offset_type(0, type) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
86 index[0] = tuple(e) |
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
87 |
13254
5ef5eb1f3515
revlog: only build the nodemap on demand
Matt Mackall <mpm@selenic.com>
parents:
13253
diff
changeset
|
88 return index, cache |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
89 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
90 |
37893
b4e42a9bd12e
tests: prefer string concatenation with () instead of \ in parseindex2 tests
Augie Fackler <augie@google.com>
parents:
32372
diff
changeset
|
91 data_inlined = ( |
37894
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
92 b'\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x01\x8c' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
93 b'\x00\x00\x04\x07\x00\x00\x00\x00\x00\x00\x15\x15\xff\xff\xff' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
94 b'\xff\xff\xff\xff\xff\xebG\x97\xb7\x1fB\x04\xcf\x13V\x81\tw\x1b' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
95 b'w\xdduR\xda\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
96 b'x\x9c\x9d\x93?O\xc30\x10\xc5\xf7|\x8a\xdb\x9a\xa8m\x06\xd8*\x95' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
97 b'\x81B\xa1\xa2\xa2R\xcb\x86Pd\x9a\x0b5$vd_\x04\xfd\xf6\x9c\xff@' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
98 b'\x11!\x0b\xd9\xec\xf7\xbbw\xe7gG6\xad6\x04\xdaN\xc0\x92\xa0$)' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
99 b'\xb1\x82\xa2\xd1%\x16\xa4\x8b7\xa9\xca\xd4-\xb2Y\x02\xfc\xc9' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
100 b'\xcaS\xf9\xaeX\xed\xb6\xd77Q\x02\x83\xd4\x19\xf5--Y\xea\xe1W' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
101 b'\xab\xed\x10\xceR\x0f_\xdf\xdf\r\xe1,\xf5\xf0\xcb\xf5 \xceR\x0f' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
102 b'_\xdc\x0e\x0e\xc3R\x0f_\xae\x96\x9b!\x9e\xa5\x1e\xbf\xdb,\x06' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
103 b'\xc7q\x9a/\x88\x82\xc3B\xea\xb5\xb4TJ\x93\xb6\x82\x0e\xe16\xe6' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
104 b'KQ\xdb\xaf\xecG\xa3\xd1 \x01\xd3\x0b_^\xe8\xaa\xa0\xae\xad\xd1' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
105 b'&\xbef\x1bz\x08\xb0|\xc9Xz\x06\xf6Z\x91\x90J\xaa\x17\x90\xaa' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
106 b'\xd2\xa6\x11$5C\xcf\xba#\xa0\x03\x02*2\x92-\xfc\xb1\x94\xdf\xe2' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
107 b'\xae\xb8\'m\x8ey0^\x85\xd3\x82\xb4\xf0`:\x9c\x00\x8a\xfd\x01' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
108 b'\xb0\xc6\x86\x8b\xdd\xae\x80\xf3\xa9\x9fd\x16\n\x00R%\x1a\x06' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
109 b'\xe9\xd8b\x98\x1d\xf4\xf3+\x9bf\x01\xd8p\x1b\xf3.\xed\x9f^g\xc3' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
110 b'^\xd9W81T\xdb\xd5\x04sx|\xf2\xeb\xd6`%?x\xed"\x831\xbf\xf3\xdc' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
111 b'b\xeb%gaY\xe1\xad\x9f\xb9f\'1w\xa9\xa5a\x83s\x82J\xb98\xbc4\x8b' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
112 b'\x83\x00\x9f$z\xb8#\xa5\xb1\xdf\x98\xd9\xec\x1b\x89O\xe3Ts\x9a4' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
113 b'\x17m\x8b\xfc\x8f\xa5\x95\x9a\xfc\xfa\xed,\xe5|\xa1\xfe\x15\xb9' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
114 b'\xbc\xb2\x93\x1f\xf2\x95\xff\xdf,\x1a\xc5\xe7\x17*\x93Oz:>\x0e' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
115 ) |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
116 |
37893
b4e42a9bd12e
tests: prefer string concatenation with () instead of \ in parseindex2 tests
Augie Fackler <augie@google.com>
parents:
32372
diff
changeset
|
117 data_non_inlined = ( |
37894
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
118 b'\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01D\x19' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
119 b'\x00\x07e\x12\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
120 b'\xff\xff\xff\xff\xd1\xf4\xbb\xb0\xbe\xfc\x13\xbd\x8c\xd3\x9d' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
121 b'\x0f\xcd\xd9;\x8c\x07\x8cJ/\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
122 b'\x00\x00\x00\x00\x00\x00\x01D\x19\x00\x00\x00\x00\x00\xdf\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
123 b'\x00\x01q\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\xff' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
124 b'\xff\xff\xff\xc1\x12\xb9\x04\x96\xa4Z1t\x91\xdfsJ\x90\xf0\x9bh' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
125 b'\x07l&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
126 b'\x00\x01D\xf8\x00\x00\x00\x00\x01\x1b\x00\x00\x01\xb8\x00\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
127 b'\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\xff\xff\xff\xff\x02\n' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
128 b'\x0e\xc6&\xa1\x92\xae6\x0b\x02i\xfe-\xe5\xbao\x05\xd1\xe7\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
129 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01F' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
130 b'\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
131 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
132 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00' |
2f00c6e8f6a1
tests: port test-parseindex2.py to Python 3
Augie Fackler <augie@google.com>
parents:
37893
diff
changeset
|
133 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
134 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
135 |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
136 |
48769
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48499
diff
changeset
|
137 def parse_index2(data, inline, format=constants.REVLOGV1): |
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48499
diff
changeset
|
138 index, chunkcache = parsers.parse_index2(data, inline, format=format) |
16363
2cdd7e63211b
parsers: incrementally parse the revlog index in C
Bryan O'Sullivan <bryano@fb.com>
parents:
13254
diff
changeset
|
139 return list(index), chunkcache |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
140 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
141 |
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
142 def importparsers(hexversion): |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
143 """Import mercurial.parsers with the given sys.hexversion.""" |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
144 # The file parsers.c inspects sys.hexversion to determine the version |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
145 # of the currently-running Python interpreter, so we monkey-patch |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
146 # sys.hexversion to simulate using different versions. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
147 code = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
148 "import sys; sys.hexversion=%s; " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
149 "import mercurial.cext.parsers" % hexversion |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
150 ) |
45829
e7a4c018b563
tests: use python from environment in test-parseindex2.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
43946
diff
changeset
|
151 cmd = "\"%s\" -c \"%s\"" % (os.environ['PYTHON'], code) |
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
152 # We need to do these tests inside a subprocess because parser.c's |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
153 # version-checking code happens inside the module init function, and |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
154 # when using reload() to reimport an extension module, "The init function |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
155 # of extension modules is not called a second time" |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
156 # (from http://docs.python.org/2/library/functions.html?#reload). |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
157 p = subprocess.Popen( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
158 cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
159 ) |
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
160 return p.communicate() # returns stdout, stderr |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
161 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
162 |
39045
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
163 def hexfailmsg(testnumber, hexversion, stdout, expected): |
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
164 try: |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
165 hexstring = hex(hexversion) |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
166 except TypeError: |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
167 hexstring = None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
168 return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
169 "FAILED: version test #%s with Python %s and patched " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
170 "sys.hexversion %r (%r):\n Expected %s but got:\n-->'%s'\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
171 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
172 testnumber, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
173 sys.version_info, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
174 hexversion, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
175 hexstring, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
176 expected, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
177 stdout, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
178 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
179 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
180 |
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
181 |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
182 def makehex(major, minor, micro): |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
183 return int("%x%02x%02x00" % (major, minor, micro), 16) |
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
184 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
185 |
38989
01966d45b45e
tests: start moving test-parseindex2.py to a unittest
Augie Fackler <augie@google.com>
parents:
38852
diff
changeset
|
186 class parseindex2tests(unittest.TestCase): |
39045
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
187 def assertversionokay(self, testnumber, hexversion): |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
188 stdout, stderr = importparsers(hexversion) |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
189 self.assertFalse( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
190 stdout, hexfailmsg(testnumber, hexversion, stdout, 'no stdout') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
191 ) |
39045
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
192 |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
193 def assertversionfail(self, testnumber, hexversion): |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
194 stdout, stderr = importparsers(hexversion) |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
195 # We include versionerrortext to distinguish from other ImportErrors. |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
196 errtext = b"ImportError: %s" % pycompat.sysbytes( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
197 parsers.versionerrortext |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
198 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
199 self.assertIn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
200 errtext, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
201 stdout, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
202 hexfailmsg( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
203 testnumber, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
204 hexversion, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
205 stdout, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
206 expected="stdout to contain %r" % errtext, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
207 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
208 ) |
39045
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
209 |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
210 def testversiondetection(self): |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
211 """Check the version-detection logic when importing parsers.""" |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
212 # Only test the version-detection logic if it is present. |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
213 try: |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
214 parsers.versionerrortext |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
215 except AttributeError: |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
216 return |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
217 info = sys.version_info |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
218 major, minor, micro = info[0], info[1], info[2] |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
219 # Test same major-minor versions. |
39045
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
220 self.assertversionokay(1, makehex(major, minor, micro)) |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
221 self.assertversionokay(2, makehex(major, minor, micro + 1)) |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
222 # Test different major-minor versions. |
39045
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
223 self.assertversionfail(3, makehex(major + 1, minor, micro)) |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
224 self.assertversionfail(4, makehex(major, minor + 1, micro)) |
88b04bd2cbb4
tests: port remaining bits of test-parseindex2 to unittest asserts
Augie Fackler <augie@google.com>
parents:
38993
diff
changeset
|
225 self.assertversionfail(5, "'foo'") |
20742
3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20166
diff
changeset
|
226 |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
227 def testbadargs(self): |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
228 # Check that parse_index2() raises TypeError on bad arguments. |
38991
22216c4607bb
tests: move chunks of test-parseindex2.py to use unittest properly
Augie Fackler <augie@google.com>
parents:
38990
diff
changeset
|
229 with self.assertRaises(TypeError): |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
230 parse_index2(0, True) |
20109
e57c532c3835
parse_index2: fix crash on bad argument type (issue4110)
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
16620
diff
changeset
|
231 |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
232 def testparseindexfile(self): |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
233 # Check parsers.parse_index2() on an index file against the |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
234 # original Python implementation of parseindex, both with and |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
235 # without inlined data. |
20166
7eda5bb9ec8f
parsers: clarify documentation of test-parseindex2.py
Chris Jerdonek <chris.jerdonek@gmail.com>
parents:
20159
diff
changeset
|
236 |
38993
ee0720e82257
tests: rename variables in revlog index parse test for clarity
Augie Fackler <augie@google.com>
parents:
38992
diff
changeset
|
237 want = py_parseindex(data_inlined, True) |
ee0720e82257
tests: rename variables in revlog index parse test for clarity
Augie Fackler <augie@google.com>
parents:
38992
diff
changeset
|
238 got = parse_index2(data_inlined, True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
239 self.assertEqual(want, got) # inline data |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
240 |
38993
ee0720e82257
tests: rename variables in revlog index parse test for clarity
Augie Fackler <augie@google.com>
parents:
38992
diff
changeset
|
241 want = py_parseindex(data_non_inlined, False) |
ee0720e82257
tests: rename variables in revlog index parse test for clarity
Augie Fackler <augie@google.com>
parents:
38992
diff
changeset
|
242 got = parse_index2(data_non_inlined, False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
243 self.assertEqual(want, got) # no inline data |
7110
75fdc39b6172
Add parseindex2.py test case
Bernhard Leiner <bleiner@gmail.com>
parents:
diff
changeset
|
244 |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
245 ix = parsers.parse_index2(data_inlined, True)[0] |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
246 for i, r in enumerate(ix): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46704
diff
changeset
|
247 if r[7] == sha1nodeconstants.nullid: |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
248 i = -1 |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
249 try: |
38991
22216c4607bb
tests: move chunks of test-parseindex2.py to use unittest properly
Augie Fackler <augie@google.com>
parents:
38990
diff
changeset
|
250 self.assertEqual( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
251 ix[r[7]], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
252 i, |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45829
diff
changeset
|
253 'Reverse lookup inconsistent for %r' % hex(r[7]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
254 ) |
38990
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
255 except TypeError: |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
256 # pure version doesn't support this |
087a755310c3
tests: fix up indent width in test-parseindex2.py
Augie Fackler <augie@google.com>
parents:
38989
diff
changeset
|
257 break |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16363
diff
changeset
|
258 |
39067
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
259 def testminusone(self): |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
260 want = ( |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
261 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
262 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
263 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
264 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
265 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
266 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
267 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
268 sha1nodeconstants.nullid, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
269 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
270 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
271 constants.COMP_MODE_INLINE, |
47256
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
272 constants.COMP_MODE_INLINE, |
48499
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47256
diff
changeset
|
273 constants.RANK_UNKNOWN, |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
274 ) |
39067
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
275 index, junk = parsers.parse_index2(data_inlined, True) |
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
276 got = index[-1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
277 self.assertEqual(want, got) # inline data |
39067
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
278 |
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
279 index, junk = parsers.parse_index2(data_non_inlined, False) |
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
280 got = index[-1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
281 self.assertEqual(want, got) # no inline data |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
282 |
43847
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
283 def testdelitemwithoutnodetree(self): |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
284 index, _junk = parsers.parse_index2(data_non_inlined, False) |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
285 |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
286 def hexrev(rev): |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
287 if rev == nullrev: |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
288 return b'\xff\xff\xff\xff' |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
289 else: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45829
diff
changeset
|
290 return bin('%08x' % rev) |
43847
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
291 |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
292 def appendrev(p1, p2=nullrev): |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
293 # node won't matter for this test, let's just make sure |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
294 # they don't collide. Other data don't matter either. |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
295 node = hexrev(p1) + hexrev(p2) + b'.' * 12 |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
296 e = ( |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
297 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
298 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
299 12, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
300 1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
301 34, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
302 p1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
303 p2, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
304 node, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
305 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
306 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
307 constants.COMP_MODE_INLINE, |
47256
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
308 constants.COMP_MODE_INLINE, |
48499
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47256
diff
changeset
|
309 constants.RANK_UNKNOWN, |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
310 ) |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47143
diff
changeset
|
311 index.append(e) |
43847
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
312 |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
313 appendrev(4) |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
314 appendrev(5) |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
315 appendrev(6) |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
316 self.assertEqual(len(index), 7) |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
317 |
43946
ac627ed8a911
tests-pure: fixing test-parseindex2
Georges Racinet <georges.racinet@octobus.net>
parents:
43847
diff
changeset
|
318 del index[1:-1] |
43847
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
319 |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
320 # assertions that failed before correction |
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
321 self.assertEqual(len(index), 1) # was 4 |
43946
ac627ed8a911
tests-pure: fixing test-parseindex2
Georges Racinet <georges.racinet@octobus.net>
parents:
43847
diff
changeset
|
322 headrevs = getattr(index, 'headrevs', None) |
ac627ed8a911
tests-pure: fixing test-parseindex2
Georges Racinet <georges.racinet@octobus.net>
parents:
43847
diff
changeset
|
323 if headrevs is not None: # not implemented in pure |
ac627ed8a911
tests-pure: fixing test-parseindex2
Georges Racinet <georges.racinet@octobus.net>
parents:
43847
diff
changeset
|
324 self.assertEqual(index.headrevs(), [0]) # gave ValueError |
43847
49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
Georges Racinet <georges.racinet@octobus.net>
parents:
43506
diff
changeset
|
325 |
39067
daedb70fd467
tests: add test coverage for revlogindex[-1] which was previously missing
Augie Fackler <augie@google.com>
parents:
39048
diff
changeset
|
326 |
38989
01966d45b45e
tests: start moving test-parseindex2.py to a unittest
Augie Fackler <augie@google.com>
parents:
38852
diff
changeset
|
327 if __name__ == '__main__': |
01966d45b45e
tests: start moving test-parseindex2.py to a unittest
Augie Fackler <augie@google.com>
parents:
38852
diff
changeset
|
328 import silenttestrunner |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39067
diff
changeset
|
329 |
38989
01966d45b45e
tests: start moving test-parseindex2.py to a unittest
Augie Fackler <augie@google.com>
parents:
38852
diff
changeset
|
330 silenttestrunner.main(__name__) |