##// END OF EJS Templates
commands: add debugdeltachain command...
Gregory Szorc -
r27263:4efb36ec default
parent child Browse files
Show More
@@ -2501,6 +2501,117 b' def debugindexdot(ui, repo, file_=None, '
2501 2501 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2502 2502 ui.write("}\n")
2503 2503
2504 @command('debugdeltachain',
2505 debugrevlogopts + formatteropts,
2506 _('-c|-m|FILE'),
2507 optionalrepo=True)
2508 def debugdeltachain(ui, repo, file_=None, **opts):
2509 """dump information about delta chains in a revlog
2510
2511 Output can be templatized. Available template keywords are:
2512
2513 rev revision number
2514 chainid delta chain identifier (numbered by unique base)
2515 chainlen delta chain length to this revision
2516 prevrev previous revision in delta chain
2517 deltatype role of delta / how it was computed
2518 compsize compressed size of revision
2519 uncompsize uncompressed size of revision
2520 chainsize total size of compressed revisions in chain
2521 chainratio total chain size divided by uncompressed revision size
2522 (new delta chains typically start at ratio 2.00)
2523 lindist linear distance from base revision in delta chain to end
2524 of this revision
2525 extradist total size of revisions not part of this delta chain from
2526 base of delta chain to end of this revision; a measurement
2527 of how much extra data we need to read/seek across to read
2528 the delta chain for this revision
2529 extraratio extradist divided by chainsize; another representation of
2530 how much unrelated data is needed to load this delta chain
2531 """
2532 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
2533 index = r.index
2534 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2535
2536 def revinfo(rev):
2537 iterrev = rev
2538 e = index[iterrev]
2539 chain = []
2540 compsize = e[1]
2541 uncompsize = e[2]
2542 chainsize = 0
2543
2544 if generaldelta:
2545 if e[3] == e[5]:
2546 deltatype = 'p1'
2547 elif e[3] == e[6]:
2548 deltatype = 'p2'
2549 elif e[3] == rev - 1:
2550 deltatype = 'prev'
2551 elif e[3] == rev:
2552 deltatype = 'base'
2553 else:
2554 deltatype = 'other'
2555 else:
2556 if e[3] == rev:
2557 deltatype = 'base'
2558 else:
2559 deltatype = 'prev'
2560
2561 while iterrev != e[3]:
2562 chain.append(iterrev)
2563 chainsize += e[1]
2564 if generaldelta:
2565 iterrev = e[3]
2566 else:
2567 iterrev -= 1
2568 e = index[iterrev]
2569 else:
2570 chainsize += e[1]
2571 chain.append(iterrev)
2572
2573 chain.reverse()
2574 return compsize, uncompsize, deltatype, chain, chainsize
2575
2576 fm = ui.formatter('debugdeltachain', opts)
2577
2578 fm.plain(' rev chain# chainlen prev delta '
2579 'size rawsize chainsize ratio lindist extradist '
2580 'extraratio\n')
2581
2582 chainbases = {}
2583 for rev in r:
2584 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
2585 chainbase = chain[0]
2586 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
2587 basestart = r.start(chainbase)
2588 revstart = r.start(rev)
2589 lineardist = revstart + comp - basestart
2590 extradist = lineardist - chainsize
2591 try:
2592 prevrev = chain[-2]
2593 except IndexError:
2594 prevrev = -1
2595
2596 chainratio = float(chainsize) / float(uncomp)
2597 extraratio = float(extradist) / float(chainsize)
2598
2599 fm.startitem()
2600 fm.write('rev chainid chainlen prevrev deltatype compsize '
2601 'uncompsize chainsize chainratio lindist extradist '
2602 'extraratio',
2603 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n',
2604 rev, chainid, len(chain), prevrev, deltatype, comp,
2605 uncomp, chainsize, chainratio, lineardist, extradist,
2606 extraratio,
2607 rev=rev, chainid=chainid, chainlen=len(chain),
2608 prevrev=prevrev, deltatype=deltatype, compsize=comp,
2609 uncompsize=uncomp, chainsize=chainsize,
2610 chainratio=chainratio, lindist=lineardist,
2611 extradist=extradist, extraratio=extraratio)
2612
2613 fm.end()
2614
2504 2615 @command('debuginstall', [], '', norepo=True)
2505 2616 def debuginstall(ui):
2506 2617 '''test Mercurial installation
@@ -80,6 +80,7 b' Show debug commands if there are no othe'
80 80 debugdag
81 81 debugdata
82 82 debugdate
83 debugdeltachain
83 84 debugdirstate
84 85 debugdiscovery
85 86 debugextensions
@@ -243,6 +244,7 b' Show all commands + options'
243 244 debugdag: tags, branches, dots, spaces
244 245 debugdata: changelog, manifest, dir
245 246 debugdate: extended
247 debugdeltachain: changelog, manifest, dir, template
246 248 debugdirstate: nodates, datesort
247 249 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
248 250 debugextensions: template
@@ -44,6 +44,32 b' Test debugindex, with and without the --'
44 44 rev flag offset length size ..... link p1 p2 nodeid (re)
45 45 0 0000 0 3 2 .... 0 -1 -1 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 (re)
46 46
47 debugdelta chain basic output
48
49 $ hg debugdeltachain -m
50 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
51 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000
52
53 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen}\n'
54 0 1 1
55
56 $ hg debugdeltachain -m -Tjson
57 [
58 {
59 "chainid": 1,
60 "chainlen": 1,
61 "chainratio": 1.02325581395,
62 "chainsize": 44,
63 "compsize": 44,
64 "deltatype": "base",
65 "extradist": 0,
66 "extraratio": 0.0,
67 "lindist": 44,
68 "prevrev": -1,
69 "rev": 0,
70 "uncompsize": 43
71 }
72 ]
47 73
48 74 Test max chain len
49 75 $ cat >> $HGRCPATH << EOF
@@ -812,6 +812,8 b' Test list of internal help commands'
812 812 description
813 813 debugdata dump the contents of a data file revision
814 814 debugdate parse and display a date
815 debugdeltachain
816 dump information about delta chains in a revlog
815 817 debugdirstate
816 818 show the contents of the current dirstate
817 819 debugdiscovery
General Comments 0
You need to be logged in to leave comments. Login now