Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 30538:bd5c4320b5a8
debugcommands: move 'debugdeltachain' in the new module
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 17 Aug 2016 21:01:02 -0700 |
parents | 22683f2f8100 |
children | 342d0cb4f446 |
comparison
equal
deleted
inserted
replaced
30537:22683f2f8100 | 30538:bd5c4320b5a8 |
---|---|
746 pp = r.parents(node) | 746 pp = r.parents(node) |
747 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | 747 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
748 if pp[1] != nullid: | 748 if pp[1] != nullid: |
749 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) | 749 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
750 ui.write("}\n") | 750 ui.write("}\n") |
751 | |
752 @command('debugdeltachain', | |
753 commands.debugrevlogopts + commands.formatteropts, | |
754 _('-c|-m|FILE'), | |
755 optionalrepo=True) | |
756 def debugdeltachain(ui, repo, file_=None, **opts): | |
757 """dump information about delta chains in a revlog | |
758 | |
759 Output can be templatized. Available template keywords are: | |
760 | |
761 :``rev``: revision number | |
762 :``chainid``: delta chain identifier (numbered by unique base) | |
763 :``chainlen``: delta chain length to this revision | |
764 :``prevrev``: previous revision in delta chain | |
765 :``deltatype``: role of delta / how it was computed | |
766 :``compsize``: compressed size of revision | |
767 :``uncompsize``: uncompressed size of revision | |
768 :``chainsize``: total size of compressed revisions in chain | |
769 :``chainratio``: total chain size divided by uncompressed revision size | |
770 (new delta chains typically start at ratio 2.00) | |
771 :``lindist``: linear distance from base revision in delta chain to end | |
772 of this revision | |
773 :``extradist``: total size of revisions not part of this delta chain from | |
774 base of delta chain to end of this revision; a measurement | |
775 of how much extra data we need to read/seek across to read | |
776 the delta chain for this revision | |
777 :``extraratio``: extradist divided by chainsize; another representation of | |
778 how much unrelated data is needed to load this delta chain | |
779 """ | |
780 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) | |
781 index = r.index | |
782 generaldelta = r.version & revlog.REVLOGGENERALDELTA | |
783 | |
784 def revinfo(rev): | |
785 e = index[rev] | |
786 compsize = e[1] | |
787 uncompsize = e[2] | |
788 chainsize = 0 | |
789 | |
790 if generaldelta: | |
791 if e[3] == e[5]: | |
792 deltatype = 'p1' | |
793 elif e[3] == e[6]: | |
794 deltatype = 'p2' | |
795 elif e[3] == rev - 1: | |
796 deltatype = 'prev' | |
797 elif e[3] == rev: | |
798 deltatype = 'base' | |
799 else: | |
800 deltatype = 'other' | |
801 else: | |
802 if e[3] == rev: | |
803 deltatype = 'base' | |
804 else: | |
805 deltatype = 'prev' | |
806 | |
807 chain = r._deltachain(rev)[0] | |
808 for iterrev in chain: | |
809 e = index[iterrev] | |
810 chainsize += e[1] | |
811 | |
812 return compsize, uncompsize, deltatype, chain, chainsize | |
813 | |
814 fm = ui.formatter('debugdeltachain', opts) | |
815 | |
816 fm.plain(' rev chain# chainlen prev delta ' | |
817 'size rawsize chainsize ratio lindist extradist ' | |
818 'extraratio\n') | |
819 | |
820 chainbases = {} | |
821 for rev in r: | |
822 comp, uncomp, deltatype, chain, chainsize = revinfo(rev) | |
823 chainbase = chain[0] | |
824 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) | |
825 basestart = r.start(chainbase) | |
826 revstart = r.start(rev) | |
827 lineardist = revstart + comp - basestart | |
828 extradist = lineardist - chainsize | |
829 try: | |
830 prevrev = chain[-2] | |
831 except IndexError: | |
832 prevrev = -1 | |
833 | |
834 chainratio = float(chainsize) / float(uncomp) | |
835 extraratio = float(extradist) / float(chainsize) | |
836 | |
837 fm.startitem() | |
838 fm.write('rev chainid chainlen prevrev deltatype compsize ' | |
839 'uncompsize chainsize chainratio lindist extradist ' | |
840 'extraratio', | |
841 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n', | |
842 rev, chainid, len(chain), prevrev, deltatype, comp, | |
843 uncomp, chainsize, chainratio, lineardist, extradist, | |
844 extraratio, | |
845 rev=rev, chainid=chainid, chainlen=len(chain), | |
846 prevrev=prevrev, deltatype=deltatype, compsize=comp, | |
847 uncompsize=uncomp, chainsize=chainsize, | |
848 chainratio=chainratio, lindist=lineardist, | |
849 extradist=extradist, extraratio=extraratio) | |
850 | |
851 fm.end() |