author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Fri, 23 Feb 2024 11:30:58 +0100 | |
changeset 51432 | e79c7320605f |
parent 51076 | 786b6225793a |
permissions | -rw-r--r-- |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
1 |
$ hg init empty-repo |
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
2 |
$ cd empty-repo |
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
3 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
4 |
Flags on revlog version 0 are rejected |
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
5 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
6 |
>>> with open('.hg/store/00changelog.i', 'wb') as fh: |
38080
0a10f142299d
py3: suppress the output from .write() calls in few tests
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37283
diff
changeset
|
7 |
... fh.write(b'\x00\x01\x00\x00') and None |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
8 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
9 |
$ hg log |
47157
3a9f3470922c
revlog: use revlog.display_id in format related errors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47150
diff
changeset
|
10 |
abort: unknown flags (0x01) in version 0 revlog 00changelog |
46116
17a695357270
errors: use detailed exit code 50 for StorageError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
11 |
[50] |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
12 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
13 |
Unknown flags on revlog version 1 are rejected |
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
14 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
15 |
>>> with open('.hg/store/00changelog.i', 'wb') as fh: |
38080
0a10f142299d
py3: suppress the output from .write() calls in few tests
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37283
diff
changeset
|
16 |
... fh.write(b'\x00\x04\x00\x01') and None |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
17 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
18 |
$ hg log |
47157
3a9f3470922c
revlog: use revlog.display_id in format related errors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47150
diff
changeset
|
19 |
abort: unknown flags (0x04) in version 1 revlog 00changelog |
46116
17a695357270
errors: use detailed exit code 50 for StorageError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
20 |
[50] |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
21 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
22 |
Unknown version is rejected |
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
23 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
24 |
>>> with open('.hg/store/00changelog.i', 'wb') as fh: |
46704
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46116
diff
changeset
|
25 |
... fh.write(b'\x00\x00\xbe\xef') and None |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
26 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
27 |
$ hg log |
47157
3a9f3470922c
revlog: use revlog.display_id in format related errors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47150
diff
changeset
|
28 |
abort: unknown version (48879) in revlog 00changelog |
46116
17a695357270
errors: use detailed exit code 50 for StorageError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
29 |
[50] |
32391
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
30 |
|
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
31 |
$ cd .. |
3ea1f1e71a0a
tests: tests for revlog version and flags loading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32371
diff
changeset
|
32 |
|
28656
b6ed2505d6cf
parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 |
Test for CVE-2016-3630 |
b6ed2505d6cf
parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 |
|
49209
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
35 |
$ mkdir test2; cd test2 |
28656
b6ed2505d6cf
parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 |
$ hg init |
b6ed2505d6cf
parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 |
|
40281 | 38 |
>>> import codecs |
39 |
>>> open("a.i", "wb").write(codecs.decode(codecs.decode( |
|
36484
71d1bbf1617e
py3: add b'' prefixes in tests/test-revlog.t
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32392
diff
changeset
|
40 |
... b"""eJxjYGZgZIAAYQYGxhgom+k/FMx8YKx9ZUaKSOyqo4cnuKb8mbqHV5cBCVTMWb1Cwqkhe4Gsg9AD |
40281 | 41 |
... Joa3dYtcYYYBAQ8Qr4OqZAYRICPTSr5WKd/42rV36d+8/VmrNpv7NP1jQAXrQE4BqQUARngwVA==""", |
42 |
... "base64"), "zlib")) and None |
|
28656
b6ed2505d6cf
parsers: fix list sizing rounding error (SEC)
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 |
|
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39280
diff
changeset
|
44 |
$ hg debugrevlogindex a.i |
37283
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37282
diff
changeset
|
45 |
rev linkrev nodeid p1 p2 |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37282
diff
changeset
|
46 |
0 2 99e0332bd498 000000000000 000000000000 |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37282
diff
changeset
|
47 |
1 3 6674f57a23d8 99e0332bd498 000000000000 |
39280
da459d426c20
tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38080
diff
changeset
|
48 |
|
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46704
diff
changeset
|
49 |
>>> from mercurial.revlogutils.constants import KIND_OTHER |
39280
da459d426c20
tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38080
diff
changeset
|
50 |
>>> from mercurial import revlog, vfs |
da459d426c20
tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38080
diff
changeset
|
51 |
>>> tvfs = vfs.vfs(b'.') |
da459d426c20
tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38080
diff
changeset
|
52 |
>>> tvfs.options = {b'revlogv1': True} |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
53 |
>>> rl = revlog.revlog(tvfs, target=(KIND_OTHER, b'test'), radix=b'a') |
39280
da459d426c20
tests: use inline Python for revlog test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38080
diff
changeset
|
54 |
>>> rl.revision(1) |
40281 | 55 |
mpatchError(*'patch cannot be decoded'*) (glob) |
49209
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
56 |
|
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
57 |
$ cd .. |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
58 |
|
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
59 |
|
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
60 |
Regression test for support for the old repos with strange diff encoding. |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
61 |
Apparently it used to be possible (maybe it's still possible, but we don't know how) |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
62 |
to create commits whose diffs are encoded relative to a nullrev. |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
63 |
This test checks that a repo with that encoding can still be read. |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
64 |
|
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
65 |
This is what we did to produce the repo in test-revlog-diff-relative-to-nullrev.tar: |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
66 |
|
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
67 |
- tweak the code in mercurial/revlogutils/deltas.py to produce such "trivial" deltas: |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
68 |
> if deltainfo is None: |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
69 |
> - deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev) |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
70 |
> + deltainfo = self._builddeltainfo(revinfo, nullrev, fh) |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
71 |
- hg init |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
72 |
- echo hi > a |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
73 |
- hg commit -Am_ |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
74 |
- remove some cache files |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
75 |
|
49486
58e38c1a2370
tests: fix tar invocation, to address issue 6740
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49458
diff
changeset
|
76 |
$ tar -xf - < "$TESTDIR"/bundles/test-revlog-diff-relative-to-nullrev.tar |
49209
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
77 |
$ cd nullrev-diff |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
78 |
$ hg debugdeltachain a |
51076
786b6225793a
debug-delta-chain: print less data by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49486
diff
changeset
|
79 |
rev p1 p2 chain# chainlen prev delta |
786b6225793a
debug-delta-chain: print less data by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49486
diff
changeset
|
80 |
0 -1 -1 1 2 -1 p1 |
786b6225793a
debug-delta-chain: print less data by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49486
diff
changeset
|
81 |
1 0 -1 1 2 -1 p2 |
786b6225793a
debug-delta-chain: print less data by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49486
diff
changeset
|
82 |
2 -1 -1 1 2 -1 p1 |
49209
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
83 |
$ hg cat --config rhg.cat=true -r 0 a |
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
84 |
hi |
49238
6aae0e1ecdbc
test-revlog: adds a non-root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
85 |
$ hg cat --config rhg.cat=true -r 1 a |
6aae0e1ecdbc
test-revlog: adds a non-root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
86 |
ho |
49239
a94f28be2e6e
test-revlog: adds a new root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49238
diff
changeset
|
87 |
$ hg cat --config rhg.cat=true -r 2 a |
a94f28be2e6e
test-revlog: adds a new root revision with a delta against nullrev
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49238
diff
changeset
|
88 |
ha |
49209
2dd53a33aefa
test-revlog: test a repository that contains a diff against nullrev
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
47157
diff
changeset
|
89 |
$ cd .. |