##// END OF EJS Templates
debug-delta-find: add a --source option...
marmoute -
r50484:266bb5c8 default
parent child Browse files
Show More
@@ -59,6 +59,7 b' from . import ('
59 localrepo,
59 localrepo,
60 lock as lockmod,
60 lock as lockmod,
61 logcmdutil,
61 logcmdutil,
62 mdiff,
62 mergestate as mergestatemod,
63 mergestate as mergestatemod,
63 metadata,
64 metadata,
64 obsolete,
65 obsolete,
@@ -990,17 +991,29 b' def debugdeltachain(ui, repo, file_=None'
990
991
991 @command(
992 @command(
992 b'debug-delta-find',
993 b'debug-delta-find',
993 cmdutil.debugrevlogopts + cmdutil.formatteropts,
994 cmdutil.debugrevlogopts
995 + cmdutil.formatteropts
996 + [
997 (
998 b'',
999 b'source',
1000 b'full',
1001 _(b'input data feed to the process (full, storage, p1, p2, prev)'),
1002 ),
1003 ],
994 _(b'-c|-m|FILE REV'),
1004 _(b'-c|-m|FILE REV'),
995 optionalrepo=True,
1005 optionalrepo=True,
996 )
1006 )
997 def debugdeltafind(ui, repo, arg_1, arg_2=None, **opts):
1007 def debugdeltafind(ui, repo, arg_1, arg_2=None, source=b'full', **opts):
998 """display the computation to get to a valid delta for storing REV
1008 """display the computation to get to a valid delta for storing REV
999
1009
1000 This command will replay the process used to find the "best" delta to store
1010 This command will replay the process used to find the "best" delta to store
1001 a revision and display information about all the steps used to get to that
1011 a revision and display information about all the steps used to get to that
1002 result.
1012 result.
1003
1013
1014 By default, the process is fed with a the full-text for the revision. This
1015 can be controlled with the --source flag.
1016
1004 The revision use the revision number of the target storage (not changelog
1017 The revision use the revision number of the target storage (not changelog
1005 revision number).
1018 revision number).
1006
1019
@@ -1028,11 +1041,31 b' def debugdeltafind(ui, repo, arg_1, arg_'
1028 p1r, p2r = revlog.parentrevs(rev)
1041 p1r, p2r = revlog.parentrevs(rev)
1029 p1 = revlog.node(p1r)
1042 p1 = revlog.node(p1r)
1030 p2 = revlog.node(p2r)
1043 p2 = revlog.node(p2r)
1031 btext = [revlog.revision(rev)]
1044 full_text = revlog.revision(rev)
1045 btext = [full_text]
1032 textlen = len(btext[0])
1046 textlen = len(btext[0])
1033 cachedelta = None
1047 cachedelta = None
1034 flags = revlog.flags(rev)
1048 flags = revlog.flags(rev)
1035
1049
1050 if source != b'full':
1051 if source == b'storage':
1052 base_rev = revlog.deltaparent(rev)
1053 elif source == b'p1':
1054 base_rev = p1r
1055 elif source == b'p2':
1056 base_rev = p2r
1057 elif source == b'prev':
1058 base_rev = rev - 1
1059 else:
1060 raise error.InputError(b"invalid --source value: %s" % source)
1061
1062 if base_rev != nullrev:
1063 base_text = revlog.revision(base_rev)
1064 delta = mdiff.textdiff(base_text, full_text)
1065
1066 cachedelta = (base_rev, delta)
1067 btext = [None]
1068
1036 revinfo = revlogutils.revisioninfo(
1069 revinfo = revlogutils.revisioninfo(
1037 node,
1070 node,
1038 p1,
1071 p1,
@@ -268,7 +268,7 b' Show all commands + options'
268 config: untrusted, exp-all-known, edit, local, source, shared, non-shared, global, template
268 config: untrusted, exp-all-known, edit, local, source, shared, non-shared, global, template
269 continue: dry-run
269 continue: dry-run
270 copy: forget, after, at-rev, force, include, exclude, dry-run
270 copy: forget, after, at-rev, force, include, exclude, dry-run
271 debug-delta-find: changelog, manifest, dir, template
271 debug-delta-find: changelog, manifest, dir, template, source
272 debug-repair-issue6528: to-report, from-report, paranoid, dry-run
272 debug-repair-issue6528: to-report, from-report, paranoid, dry-run
273 debug-revlog-index: changelog, manifest, dir, template
273 debug-revlog-index: changelog, manifest, dir, template
274 debugancestor:
274 debugancestor:
@@ -191,4 +191,156 b' Test `debug-delta-find`'
191 DBG-DELTAS-SEARCH: DELTA: length=49132 (BAD)
191 DBG-DELTAS-SEARCH: DELTA: length=49132 (BAD)
192 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
192 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
193
193
194 $ cat << EOF >>.hg/hgrc
195 > [storage]
196 > revlog.optimize-delta-parent-choice = no
197 > revlog.reuse-external-delta = yes
198 > EOF
199
200 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --quiet
201 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
202 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --source full
203 DBG-DELTAS-SEARCH: SEARCH rev=4971
204 DBG-DELTAS-SEARCH: ROUND #1 - 2 candidates - search-down
205 DBG-DELTAS-SEARCH: CANDIDATE: rev=4962
206 DBG-DELTAS-SEARCH: type=snapshot-4
207 DBG-DELTAS-SEARCH: size=18296
208 DBG-DELTAS-SEARCH: base=4930
209 DBG-DELTAS-SEARCH: uncompressed-delta-size=30377
210 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
211 DBG-DELTAS-SEARCH: DELTA: length=16872 (BAD)
212 DBG-DELTAS-SEARCH: CANDIDATE: rev=4971
213 DBG-DELTAS-SEARCH: type=snapshot-4
214 DBG-DELTAS-SEARCH: size=19179
215 DBG-DELTAS-SEARCH: base=4930
216 DBG-DELTAS-SEARCH: TOO-HIGH
217 DBG-DELTAS-SEARCH: ROUND #2 - 1 candidates - search-down
218 DBG-DELTAS-SEARCH: CANDIDATE: rev=4930
219 DBG-DELTAS-SEARCH: type=snapshot-3
220 DBG-DELTAS-SEARCH: size=39228
221 DBG-DELTAS-SEARCH: base=4799
222 DBG-DELTAS-SEARCH: uncompressed-delta-size=33050
223 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
224 DBG-DELTAS-SEARCH: DELTA: length=19179 (GOOD)
225 DBG-DELTAS-SEARCH: ROUND #3 - 1 candidates - refine-down
226 DBG-DELTAS-SEARCH: CONTENDER: rev=4930 - length=19179
227 DBG-DELTAS-SEARCH: CANDIDATE: rev=4799
228 DBG-DELTAS-SEARCH: type=snapshot-2
229 DBG-DELTAS-SEARCH: size=50213
230 DBG-DELTAS-SEARCH: base=4623
231 DBG-DELTAS-SEARCH: uncompressed-delta-size=82661
232 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
233 DBG-DELTAS-SEARCH: DELTA: length=49132 (BAD)
234 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
235 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --source storage
236 DBG-DELTAS-SEARCH: SEARCH rev=4971
237 DBG-DELTAS-SEARCH: ROUND #1 - 1 candidates - search-down
238 DBG-DELTAS-SEARCH: CANDIDATE: rev=4930
239 DBG-DELTAS-SEARCH: type=snapshot-3
240 DBG-DELTAS-SEARCH: size=39228
241 DBG-DELTAS-SEARCH: base=4799
242 DBG-DELTAS-SEARCH: uncompressed-delta-size=33050
243 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
244 DBG-DELTAS-SEARCH: DELTA: length=19179 (GOOD)
245 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=1 try-count=1 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
246 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --source p1
247 DBG-DELTAS-SEARCH: SEARCH rev=4971
248 DBG-DELTAS-SEARCH: ROUND #1 - 2 candidates - search-down
249 DBG-DELTAS-SEARCH: CANDIDATE: rev=4962
250 DBG-DELTAS-SEARCH: type=snapshot-4
251 DBG-DELTAS-SEARCH: size=18296
252 DBG-DELTAS-SEARCH: base=4930
253 DBG-DELTAS-SEARCH: uncompressed-delta-size=30377
254 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
255 DBG-DELTAS-SEARCH: DELTA: length=16872 (BAD)
256 DBG-DELTAS-SEARCH: CANDIDATE: rev=4971
257 DBG-DELTAS-SEARCH: type=snapshot-4
258 DBG-DELTAS-SEARCH: size=19179
259 DBG-DELTAS-SEARCH: base=4930
260 DBG-DELTAS-SEARCH: TOO-HIGH
261 DBG-DELTAS-SEARCH: ROUND #2 - 1 candidates - search-down
262 DBG-DELTAS-SEARCH: CANDIDATE: rev=4930
263 DBG-DELTAS-SEARCH: type=snapshot-3
264 DBG-DELTAS-SEARCH: size=39228
265 DBG-DELTAS-SEARCH: base=4799
266 DBG-DELTAS-SEARCH: uncompressed-delta-size=33050
267 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
268 DBG-DELTAS-SEARCH: DELTA: length=19179 (GOOD)
269 DBG-DELTAS-SEARCH: ROUND #3 - 1 candidates - refine-down
270 DBG-DELTAS-SEARCH: CONTENDER: rev=4930 - length=19179
271 DBG-DELTAS-SEARCH: CANDIDATE: rev=4799
272 DBG-DELTAS-SEARCH: type=snapshot-2
273 DBG-DELTAS-SEARCH: size=50213
274 DBG-DELTAS-SEARCH: base=4623
275 DBG-DELTAS-SEARCH: uncompressed-delta-size=82661
276 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
277 DBG-DELTAS-SEARCH: DELTA: length=49132 (BAD)
278 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
279 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --source p2
280 DBG-DELTAS-SEARCH: SEARCH rev=4971
281 DBG-DELTAS-SEARCH: ROUND #1 - 2 candidates - search-down
282 DBG-DELTAS-SEARCH: CANDIDATE: rev=4962
283 DBG-DELTAS-SEARCH: type=snapshot-4
284 DBG-DELTAS-SEARCH: size=18296
285 DBG-DELTAS-SEARCH: base=4930
286 DBG-DELTAS-SEARCH: uncompressed-delta-size=30377
287 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
288 DBG-DELTAS-SEARCH: DELTA: length=16872 (BAD)
289 DBG-DELTAS-SEARCH: CANDIDATE: rev=4971
290 DBG-DELTAS-SEARCH: type=snapshot-4
291 DBG-DELTAS-SEARCH: size=19179
292 DBG-DELTAS-SEARCH: base=4930
293 DBG-DELTAS-SEARCH: TOO-HIGH
294 DBG-DELTAS-SEARCH: ROUND #2 - 1 candidates - search-down
295 DBG-DELTAS-SEARCH: CANDIDATE: rev=4930
296 DBG-DELTAS-SEARCH: type=snapshot-3
297 DBG-DELTAS-SEARCH: size=39228
298 DBG-DELTAS-SEARCH: base=4799
299 DBG-DELTAS-SEARCH: uncompressed-delta-size=33050
300 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
301 DBG-DELTAS-SEARCH: DELTA: length=19179 (GOOD)
302 DBG-DELTAS-SEARCH: ROUND #3 - 1 candidates - refine-down
303 DBG-DELTAS-SEARCH: CONTENDER: rev=4930 - length=19179
304 DBG-DELTAS-SEARCH: CANDIDATE: rev=4799
305 DBG-DELTAS-SEARCH: type=snapshot-2
306 DBG-DELTAS-SEARCH: size=50213
307 DBG-DELTAS-SEARCH: base=4623
308 DBG-DELTAS-SEARCH: uncompressed-delta-size=82661
309 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
310 DBG-DELTAS-SEARCH: DELTA: length=49132 (BAD)
311 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
312 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --source prev
313 DBG-DELTAS-SEARCH: SEARCH rev=4971
314 DBG-DELTAS-SEARCH: ROUND #1 - 2 candidates - search-down
315 DBG-DELTAS-SEARCH: CANDIDATE: rev=4962
316 DBG-DELTAS-SEARCH: type=snapshot-4
317 DBG-DELTAS-SEARCH: size=18296
318 DBG-DELTAS-SEARCH: base=4930
319 DBG-DELTAS-SEARCH: uncompressed-delta-size=30377
320 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
321 DBG-DELTAS-SEARCH: DELTA: length=16872 (BAD)
322 DBG-DELTAS-SEARCH: CANDIDATE: rev=4971
323 DBG-DELTAS-SEARCH: type=snapshot-4
324 DBG-DELTAS-SEARCH: size=19179
325 DBG-DELTAS-SEARCH: base=4930
326 DBG-DELTAS-SEARCH: TOO-HIGH
327 DBG-DELTAS-SEARCH: ROUND #2 - 1 candidates - search-down
328 DBG-DELTAS-SEARCH: CANDIDATE: rev=4930
329 DBG-DELTAS-SEARCH: type=snapshot-3
330 DBG-DELTAS-SEARCH: size=39228
331 DBG-DELTAS-SEARCH: base=4799
332 DBG-DELTAS-SEARCH: uncompressed-delta-size=33050
333 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
334 DBG-DELTAS-SEARCH: DELTA: length=19179 (GOOD)
335 DBG-DELTAS-SEARCH: ROUND #3 - 1 candidates - refine-down
336 DBG-DELTAS-SEARCH: CONTENDER: rev=4930 - length=19179
337 DBG-DELTAS-SEARCH: CANDIDATE: rev=4799
338 DBG-DELTAS-SEARCH: type=snapshot-2
339 DBG-DELTAS-SEARCH: size=50213
340 DBG-DELTAS-SEARCH: base=4623
341 DBG-DELTAS-SEARCH: uncompressed-delta-size=82661
342 DBG-DELTAS-SEARCH: delta-search-time=* (glob)
343 DBG-DELTAS-SEARCH: DELTA: length=49132 (BAD)
344 DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: search-rounds=3 try-count=3 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob)
345
194 $ cd ..
346 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now