| 1 |
$ hg init empty-repo |
| 2 |
$ cd empty-repo |
| 3 |
|
| 4 |
Flags on revlog version 0 are rejected |
| 5 |
|
| 6 |
>>> with open('.hg/store/00changelog.i', 'wb') as fh: |
| 7 |
... fh.write(b'\x00\x01\x00\x00') and None |
| 8 |
|
| 9 |
$ hg log |
| 10 |
abort: unknown flags (0x01) in version 0 revlog 00changelog |
| 11 |
[50] |
| 12 |
|
| 13 |
Unknown flags on revlog version 1 are rejected |
| 14 |
|
| 15 |
>>> with open('.hg/store/00changelog.i', 'wb') as fh: |
| 16 |
... fh.write(b'\x00\x10\x00\x01') and None |
| 17 |
|
| 18 |
$ hg log |
| 19 |
abort: unknown flags (0x10) in version 1 revlog 00changelog |
| 20 |
[50] |
| 21 |
|
| 22 |
Unknown version is rejected |
| 23 |
|
| 24 |
>>> with open('.hg/store/00changelog.i', 'wb') as fh: |
| 25 |
... fh.write(b'\x00\x00\xbe\xef') and None |
| 26 |
|
| 27 |
$ hg log |
| 28 |
abort: unknown version (48879) in revlog 00changelog |
| 29 |
[50] |
| 30 |
|
| 31 |
$ cd .. |
| 32 |
|
| 33 |
Test for CVE-2016-3630 |
| 34 |
|
| 35 |
$ mkdir test2; cd test2 |
| 36 |
$ hg init |
| 37 |
|
| 38 |
>>> import codecs |
| 39 |
>>> open("a.i", "wb").write(codecs.decode(codecs.decode( |
| 40 |
... b"""eJxjYGZgZIAAYQYGxhgom+k/FMx8YKx9ZUaKSOyqo4cnuKb8mbqHV5cBCVTMWb1Cwqkhe4Gsg9AD |
| 41 |
... Joa3dYtcYYYBAQ8Qr4OqZAYRICPTSr5WKd/42rV36d+8/VmrNpv7NP1jQAXrQE4BqQUARngwVA==""", |
| 42 |
... "base64"), "zlib")) and None |
| 43 |
|
| 44 |
$ hg debugrevlogindex a.i |
| 45 |
rev linkrev nodeid p1 p2 |
| 46 |
0 2 99e0332bd498 000000000000 000000000000 |
| 47 |
1 3 6674f57a23d8 99e0332bd498 000000000000 |
| 48 |
|
| 49 |
>>> from mercurial.revlogutils.constants import KIND_OTHER |
| 50 |
>>> from mercurial import revlog, vfs |
| 51 |
>>> tvfs = vfs.vfs(b'.') |
| 52 |
>>> tvfs.options = {b'revlogv1': True} |
| 53 |
>>> rl = revlog.revlog(tvfs, target=(KIND_OTHER, b'test'), radix=b'a') |
| 54 |
>>> rl.revision(1) |
| 55 |
mpatchError(*'patch cannot be decoded'*) (glob) (no-rust !) |
| 56 |
RevlogError(b'abort: corrupted revlog, patch insert more data than available: 4294967295 < 0') (rust !) |
| 57 |
|
| 58 |
$ cd .. |
| 59 |
|
| 60 |
|
| 61 |
Regression test for support for the old repos with strange diff encoding. |
| 62 |
Apparently it used to be possible (maybe it's still possible, but we don't know how) |
| 63 |
to create commits whose diffs are encoded relative to a nullrev. |
| 64 |
This test checks that a repo with that encoding can still be read. |
| 65 |
|
| 66 |
This is what we did to produce the repo in test-revlog-diff-relative-to-nullrev.tar: |
| 67 |
|
| 68 |
- tweak the code in mercurial/revlogutils/deltas.py to produce such "trivial" deltas: |
| 69 |
> if deltainfo is None: |
| 70 |
> - deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev) |
| 71 |
> + deltainfo = self._builddeltainfo(revinfo, nullrev, fh) |
| 72 |
- hg init |
| 73 |
- echo hi > a |
| 74 |
- hg commit -Am_ |
| 75 |
- remove some cache files |
| 76 |
|
| 77 |
$ tar -xf - < "$TESTDIR"/bundles/test-revlog-diff-relative-to-nullrev.tar |
| 78 |
$ cd nullrev-diff |
| 79 |
$ hg debugdeltachain a |
| 80 |
rev p1 p2 chain# chainlen prev delta |
| 81 |
0 -1 -1 1 2 -1 p1 |
| 82 |
1 0 -1 1 2 -1 p2 |
| 83 |
2 -1 -1 1 2 -1 p1 |
| 84 |
$ hg cat --config rhg.cat=true -r 0 a |
| 85 |
hi |
| 86 |
$ hg cat --config rhg.cat=true -r 1 a |
| 87 |
ho |
| 88 |
$ hg cat --config rhg.cat=true -r 2 a |
| 89 |
ha |
| 90 |
$ cd .. |
| 91 |
|
| 92 |
Check 'delta-compression' config |
| 93 |
================================ |
| 94 |
|
| 95 |
$ cat << EOF >> ./test2/.hg/hgrc |
| 96 |
> [storage] |
| 97 |
> revlog.exchange-compressed-delta=yes |
| 98 |
> EOF |
| 99 |
$ hg debugcapabilities ./test2 --bundle2-cap="delta-compression" |
| 100 |
delta-compression |
| 101 |
none |
| 102 |
zlib |
| 103 |
zstd (zstd !) |
| 104 |
|
| 105 |
$ cat << EOF >> ./test2/.hg/hgrc |
| 106 |
> [storage] |
| 107 |
> revlog.exchange-compressed-delta=no |
| 108 |
> EOF |
| 109 |
$ hg debugcapabilities ./test2 --bundle2-cap="delta-compression" |