Show More
@@ -0,0 +1,23 b'' | |||||
|
1 | #!/bin/bash | |||
|
2 | # | |||
|
3 | # Make sure to patch mercurial to create the delta against nullrev | |||
|
4 | # if deltainfo is None: | |||
|
5 | #- deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev) | |||
|
6 | #+ deltainfo = self._builddeltainfo(revinfo, nullrev, fh) | |||
|
7 | ||||
|
8 | cd "`dirname \"$0\"`" | |||
|
9 | export HGRCPATH= | |||
|
10 | export HGMODULEPOLICY=py | |||
|
11 | ||||
|
12 | rm -rf nullrev-diff | |||
|
13 | ../../hg init nullrev-diff --config format.revlog-compression=zlib | |||
|
14 | cd nullrev-diff | |||
|
15 | echo hi > a | |||
|
16 | ../../../hg commit -Am root-B | |||
|
17 | ../../../hg debugdeltachain a | |||
|
18 | rm -rf .hg/cache/ .hg/wcache/ | |||
|
19 | cd .. | |||
|
20 | ||||
|
21 | tar cf test-revlog-diff-relative-to-nullrev.tar nullrev-diff | |||
|
22 | ||||
|
23 | rm -rf nullrev-diff |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -32,6 +32,7 b' Unknown version is rejected' | |||||
32 |
|
32 | |||
33 | Test for CVE-2016-3630 |
|
33 | Test for CVE-2016-3630 | |
34 |
|
34 | |||
|
35 | $ mkdir test2; cd test2 | |||
35 | $ hg init |
|
36 | $ hg init | |
36 |
|
37 | |||
37 | >>> import codecs |
|
38 | >>> import codecs | |
@@ -52,3 +53,37 b' Test for CVE-2016-3630' | |||||
52 | >>> rl = revlog.revlog(tvfs, target=(KIND_OTHER, b'test'), radix=b'a') |
|
53 | >>> rl = revlog.revlog(tvfs, target=(KIND_OTHER, b'test'), radix=b'a') | |
53 | >>> rl.revision(1) |
|
54 | >>> rl.revision(1) | |
54 | mpatchError(*'patch cannot be decoded'*) (glob) |
|
55 | mpatchError(*'patch cannot be decoded'*) (glob) | |
|
56 | ||||
|
57 | $ cd .. | |||
|
58 | ||||
|
59 | ||||
|
60 | Regression test for support for the old repos with strange diff encoding. | |||
|
61 | Apparently it used to be possible (maybe it's still possible, but we don't know how) | |||
|
62 | to create commits whose diffs are encoded relative to a nullrev. | |||
|
63 | This test checks that a repo with that encoding can still be read. | |||
|
64 | ||||
|
65 | This is what we did to produce the repo in test-revlog-diff-relative-to-nullrev.tar: | |||
|
66 | ||||
|
67 | - tweak the code in mercurial/revlogutils/deltas.py to produce such "trivial" deltas: | |||
|
68 | > if deltainfo is None: | |||
|
69 | > - deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev) | |||
|
70 | > + deltainfo = self._builddeltainfo(revinfo, nullrev, fh) | |||
|
71 | - hg init | |||
|
72 | - echo hi > a | |||
|
73 | - hg commit -Am_ | |||
|
74 | - remove some cache files | |||
|
75 | ||||
|
76 | $ tar --force-local -xf "$TESTDIR"/bundles/test-revlog-diff-relative-to-nullrev.tar | |||
|
77 | $ cd nullrev-diff | |||
|
78 | $ hg debugdeltachain a | |||
|
79 | rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks | |||
|
80 | 0 1 2 -1 p1 15 3 15 5.00000 15 0 0.00000 15 15 1.00000 1 | |||
|
81 | #if rhg | |||
|
82 | $ hg cat --config rhg.cat=true -r 0 a | |||
|
83 | abort: corrupted revlog | |||
|
84 | [255] | |||
|
85 | #else | |||
|
86 | $ hg cat --config rhg.cat=true -r 0 a | |||
|
87 | hi | |||
|
88 | #endif | |||
|
89 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now