Mercurial > hg
comparison mercurial/commands.py @ 27469:8914296e74a2
commands: use revlog._deltachain in debugdeltachain
We have a nice API now. Use it.
This does mean we introduce an extra index lookup for each revision.
Considering this is a debug command, the overhead should be acceptable.
We could add the chain size to revlog._deltachain(). However, that
feels like avoidable overhead.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Dec 2015 19:02:02 -0800 |
parents | 5df74b2f296d |
children | fe79f86099ae |
comparison
equal
deleted
inserted
replaced
27468:93ac15f03331 | 27469:8914296e74a2 |
---|---|
2540 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) | 2540 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
2541 index = r.index | 2541 index = r.index |
2542 generaldelta = r.version & revlog.REVLOGGENERALDELTA | 2542 generaldelta = r.version & revlog.REVLOGGENERALDELTA |
2543 | 2543 |
2544 def revinfo(rev): | 2544 def revinfo(rev): |
2545 iterrev = rev | 2545 e = index[rev] |
2546 e = index[iterrev] | |
2547 chain = [] | |
2548 compsize = e[1] | 2546 compsize = e[1] |
2549 uncompsize = e[2] | 2547 uncompsize = e[2] |
2550 chainsize = 0 | 2548 chainsize = 0 |
2551 | 2549 |
2552 if generaldelta: | 2550 if generaldelta: |
2564 if e[3] == rev: | 2562 if e[3] == rev: |
2565 deltatype = 'base' | 2563 deltatype = 'base' |
2566 else: | 2564 else: |
2567 deltatype = 'prev' | 2565 deltatype = 'prev' |
2568 | 2566 |
2569 while iterrev != e[3]: | 2567 chain = r._deltachain(rev)[0] |
2570 chain.append(iterrev) | 2568 for iterrev in chain: |
2569 e = index[iterrev] | |
2571 chainsize += e[1] | 2570 chainsize += e[1] |
2572 if generaldelta: | 2571 |
2573 iterrev = e[3] | |
2574 else: | |
2575 iterrev -= 1 | |
2576 e = index[iterrev] | |
2577 else: | |
2578 chainsize += e[1] | |
2579 chain.append(iterrev) | |
2580 | |
2581 chain.reverse() | |
2582 return compsize, uncompsize, deltatype, chain, chainsize | 2572 return compsize, uncompsize, deltatype, chain, chainsize |
2583 | 2573 |
2584 fm = ui.formatter('debugdeltachain', opts) | 2574 fm = ui.formatter('debugdeltachain', opts) |
2585 | 2575 |
2586 fm.plain(' rev chain# chainlen prev delta ' | 2576 fm.plain(' rev chain# chainlen prev delta ' |