comparison tests/test-revlog-delta-find.t @ 49764:e300f445ca77

delta-find: add a test checking various simple behavior There are enough work happening in this area that it is worth having a dedicated test for it. So far we add to small test checking that the "best" parent is picked as the delta base and that this behavior can be controlled during commit and unbundle.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 05 Dec 2022 03:23:46 +0100
parents
children f1887500f3ec
comparison
equal deleted inserted replaced
49762:c4d587fa161c 49764:e300f445ca77
1 ==========================================================
2 Test various things around delta computation within revlog
3 ==========================================================
4
5
6 basic setup
7 -----------
8
9 $ cat << EOF >> $HGRCPATH
10 > [debug]
11 > revlog.debug-delta=yes
12 > EOF
13 $ cat << EOF >> sha256line.py
14 > # a way to quickly produce file of significant size and poorly compressable content.
15 > import hashlib
16 > import sys
17 > for line in sys.stdin:
18 > print(hashlib.sha256(line.encode('utf8')).hexdigest())
19 > EOF
20
21 $ hg init base-repo
22 $ cd base-repo
23
24 create a "large" file
25
26 $ $TESTDIR/seq.py 1000 | $PYTHON $TESTTMP/sha256line.py > my-file.txt
27 $ hg add my-file.txt
28 $ hg commit -m initial-commit
29 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
30 DBG-DELTAS: MANIFESTLOG: * (glob)
31 DBG-DELTAS: CHANGELOG: * (glob)
32
33 Add more change at the end of the file
34
35 $ $TESTDIR/seq.py 1001 1200 | $PYTHON $TESTTMP/sha256line.py >> my-file.txt
36 $ hg commit -m "large-change"
37 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
38 DBG-DELTAS: MANIFESTLOG: * (glob)
39 DBG-DELTAS: CHANGELOG: * (glob)
40
41 Add small change at the start
42
43 $ hg up 'desc("initial-commit")' --quiet
44 $ mv my-file.txt foo
45 $ echo "small change at the start" > my-file.txt
46 $ cat foo >> my-file.txt
47 $ rm foo
48 $ hg commit -m "small-change"
49 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
50 DBG-DELTAS: MANIFESTLOG: * (glob)
51 DBG-DELTAS: CHANGELOG: * (glob)
52 created new head
53
54
55 $ hg log -r 'head()' -T '{node}\n' >> ../base-heads.nodes
56 $ hg log -r 'desc("initial-commit")' -T '{node}\n' >> ../initial.node
57 $ hg log -r 'desc("small-change")' -T '{node}\n' >> ../small.node
58 $ hg log -r 'desc("large-change")' -T '{node}\n' >> ../large.node
59 $ cd ..
60
61 Check delta find policy and result for merge on commit
62 ======================================================
63
64 Check that delta of merge pick best of the two parents
65 ------------------------------------------------------
66
67 As we check against both parents, the one with the largest change should
68 produce the smallest delta and be picked.
69
70 $ hg clone base-repo test-parents --quiet
71 $ hg -R test-parents update 'nodefromfile("small.node")' --quiet
72 $ hg -R test-parents merge 'nodefromfile("large.node")' --quiet
73
74 The delta base is the "large" revision as it produce a smaller delta.
75
76 $ hg -R test-parents commit -m "merge from small change"
77 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=1 * (glob)
78 DBG-DELTAS: MANIFESTLOG: * (glob)
79 DBG-DELTAS: CHANGELOG: * (glob)
80
81 Check that the behavior tested above can we disabled
82 ----------------------------------------------------
83
84 We disable the checking of both parent at the same time. The `small` change,
85 that produce a less optimal delta, should be picked first as it is "closer" to
86 the new commit.
87
88 $ hg clone base-repo test-no-parents --quiet
89 $ hg -R test-no-parents update 'nodefromfile("small.node")' --quiet
90 $ hg -R test-no-parents merge 'nodefromfile("large.node")' --quiet
91
92 The delta base is the "large" revision as it produce a smaller delta.
93
94 $ hg -R test-no-parents commit -m "merge from small change" \
95 > --config storage.revlog.optimize-delta-parent-choice=no
96 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
97 DBG-DELTAS: MANIFESTLOG: * (glob)
98 DBG-DELTAS: CHANGELOG: * (glob)
99
100
101 Check delta-find policy and result when unbundling
102 ==================================================
103
104 Build a bundle with all delta built against p1
105
106 $ hg bundle -R test-parents --all --config devel.bundle.delta=p1 all-p1.hg
107 4 changesets found
108
109 Default policy of trusting delta from the bundle
110 ------------------------------------------------
111
112 Keeping the `p1` delta used in the bundle is sub-optimal for storage, but
113 strusting in-bundle delta is faster to apply.
114
115 $ hg init bundle-default
116 $ hg -R bundle-default unbundle all-p1.hg --quiet
117 DBG-DELTAS: CHANGELOG: * (glob)
118 DBG-DELTAS: CHANGELOG: * (glob)
119 DBG-DELTAS: CHANGELOG: * (glob)
120 DBG-DELTAS: CHANGELOG: * (glob)
121 DBG-DELTAS: MANIFESTLOG: * (glob)
122 DBG-DELTAS: MANIFESTLOG: * (glob)
123 DBG-DELTAS: MANIFESTLOG: * (glob)
124 DBG-DELTAS: MANIFESTLOG: * (glob)
125 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
126 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
127 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
128 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
129
130 (confirm the file revision are in the same order, 2 should be smaller than 1)
131
132 $ hg -R bundle-default debugdata my-file.txt 2 | wc -l
133 \s*1001 (re)
134 $ hg -R bundle-default debugdata my-file.txt 1 | wc -l
135 \s*1200 (re)
136
137 explicitly enabled
138 ------------------
139
140 Keeping the `p1` delta used in the bundle is sub-optimal for storage, but
141 strusting in-bundle delta is faster to apply.
142
143 $ hg init bundle-reuse-enabled
144 $ hg -R bundle-reuse-enabled unbundle all-p1.hg --quiet \
145 > --config storage.revlog.reuse-external-delta-parent=yes
146 DBG-DELTAS: CHANGELOG: * (glob)
147 DBG-DELTAS: CHANGELOG: * (glob)
148 DBG-DELTAS: CHANGELOG: * (glob)
149 DBG-DELTAS: CHANGELOG: * (glob)
150 DBG-DELTAS: MANIFESTLOG: * (glob)
151 DBG-DELTAS: MANIFESTLOG: * (glob)
152 DBG-DELTAS: MANIFESTLOG: * (glob)
153 DBG-DELTAS: MANIFESTLOG: * (glob)
154 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
155 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
156 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
157 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
158
159 (confirm the file revision are in the same order, 2 should be smaller than 1)
160
161 $ hg -R bundle-reuse-enabled debugdata my-file.txt 2 | wc -l
162 \s*1001 (re)
163 $ hg -R bundle-reuse-enabled debugdata my-file.txt 1 | wc -l
164 \s*1200 (re)
165
166 explicitly disabled
167 -------------------
168
169 Not reusing the delta-base from the parent means we the delta will be made
170 against the "best" parent. (so not the same as the previous two)
171
172 $ hg init bundle-reuse-disabled
173 $ hg -R bundle-reuse-disabled unbundle all-p1.hg --quiet \
174 > --config storage.revlog.reuse-external-delta-parent=no
175 DBG-DELTAS: CHANGELOG: * (glob)
176 DBG-DELTAS: CHANGELOG: * (glob)
177 DBG-DELTAS: CHANGELOG: * (glob)
178 DBG-DELTAS: CHANGELOG: * (glob)
179 DBG-DELTAS: MANIFESTLOG: * (glob)
180 DBG-DELTAS: MANIFESTLOG: * (glob)
181 DBG-DELTAS: MANIFESTLOG: * (glob)
182 DBG-DELTAS: MANIFESTLOG: * (glob)
183 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
184 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
185 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
186 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=1 * (glob)
187
188 (confirm the file revision are in the same order, 2 should be smaller than 1)
189
190 $ hg -R bundle-reuse-disabled debugdata my-file.txt 2 | wc -l
191 \s*1001 (re)
192 $ hg -R bundle-reuse-disabled debugdata my-file.txt 1 | wc -l
193 \s*1200 (re)