comparison mercurial/debugcommands.py @ 30550:342d0cb4f446

debugcommands: sort command order The diff is a bit large but it is straight code moving without any logical modifications.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 25 Nov 2016 09:59:39 -0800
parents bd5c4320b5a8
children 2df983125d37
comparison
equal deleted inserted replaced
30549:d955cebd8d6a 30550:342d0cb4f446
66 else: 66 else:
67 raise error.Abort(_('either two or three arguments required')) 67 raise error.Abort(_('either two or three arguments required'))
68 a = r.ancestor(lookup(rev1), lookup(rev2)) 68 a = r.ancestor(lookup(rev1), lookup(rev2))
69 ui.write('%d:%s\n' % (r.rev(a), hex(a))) 69 ui.write('%d:%s\n' % (r.rev(a), hex(a)))
70 70
71 @command('debugapplystreamclonebundle', [], 'FILE')
72 def debugapplystreamclonebundle(ui, repo, fname):
73 """apply a stream clone bundle file"""
74 f = hg.openpath(ui, fname)
75 gen = exchange.readbundle(ui, f, fname)
76 gen.apply(repo)
77
71 @command('debugbuilddag', 78 @command('debugbuilddag',
72 [('m', 'mergeable-file', None, _('add single file mergeable changes')), 79 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
73 ('o', 'overwritten-file', None, _('add single file all revs overwrite')), 80 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
74 ('n', 'new-file', None, _('add new file at each rev'))], 81 ('n', 'new-file', None, _('add new file at each rev'))],
75 _('[OPTION]... [TEXT]')) 82 _('[OPTION]... [TEXT]'))
218 repo.vfs.write("localtags", "".join(tags)) 225 repo.vfs.write("localtags", "".join(tags))
219 finally: 226 finally:
220 ui.progress(_('building'), None) 227 ui.progress(_('building'), None)
221 release(tr, lock, wlock) 228 release(tr, lock, wlock)
222 229
223 @command('debugbundle',
224 [('a', 'all', None, _('show all details')),
225 ('', 'spec', None, _('print the bundlespec of the bundle'))],
226 _('FILE'),
227 norepo=True)
228 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
229 """lists the contents of a bundle"""
230 with hg.openpath(ui, bundlepath) as f:
231 if spec:
232 spec = exchange.getbundlespec(ui, f)
233 ui.write('%s\n' % spec)
234 return
235
236 gen = exchange.readbundle(ui, f, bundlepath)
237 if isinstance(gen, bundle2.unbundle20):
238 return _debugbundle2(ui, gen, all=all, **opts)
239 _debugchangegroup(ui, gen, all=all, **opts)
240
241 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): 230 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
242 indent_string = ' ' * indent 231 indent_string = ' ' * indent
243 if all: 232 if all:
244 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") 233 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n")
245 % indent_string) 234 % indent_string)
286 if part.type == 'changegroup': 275 if part.type == 'changegroup':
287 version = part.params.get('version', '01') 276 version = part.params.get('version', '01')
288 cg = changegroup.getunbundler(version, part, 'UN') 277 cg = changegroup.getunbundler(version, part, 'UN')
289 _debugchangegroup(ui, cg, all=all, indent=4, **opts) 278 _debugchangegroup(ui, cg, all=all, indent=4, **opts)
290 279
291 @command('debugcreatestreamclonebundle', [], 'FILE') 280 @command('debugbundle',
292 def debugcreatestreamclonebundle(ui, repo, fname): 281 [('a', 'all', None, _('show all details')),
293 """create a stream clone bundle file 282 ('', 'spec', None, _('print the bundlespec of the bundle'))],
294 283 _('FILE'),
295 Stream bundles are special bundles that are essentially archives of 284 norepo=True)
296 revlog files. They are commonly used for cloning very quickly. 285 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
297 """ 286 """lists the contents of a bundle"""
298 requirements, gen = streamclone.generatebundlev1(repo) 287 with hg.openpath(ui, bundlepath) as f:
299 changegroup.writechunks(ui, gen, fname) 288 if spec:
300 289 spec = exchange.getbundlespec(ui, f)
301 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) 290 ui.write('%s\n' % spec)
302 291 return
303 @command('debugapplystreamclonebundle', [], 'FILE') 292
304 def debugapplystreamclonebundle(ui, repo, fname): 293 gen = exchange.readbundle(ui, f, bundlepath)
305 """apply a stream clone bundle file""" 294 if isinstance(gen, bundle2.unbundle20):
306 f = hg.openpath(ui, fname) 295 return _debugbundle2(ui, gen, all=all, **opts)
307 gen = exchange.readbundle(ui, f, fname) 296 _debugchangegroup(ui, gen, all=all, **opts)
308 gen.apply(repo)
309 297
310 @command('debugcheckstate', [], '') 298 @command('debugcheckstate', [], '')
311 def debugcheckstate(ui, repo): 299 def debugcheckstate(ui, repo):
312 """validate the correctness of the current dirstate""" 300 """validate the correctness of the current dirstate"""
313 parent1, parent2 = repo.dirstate.parents() 301 parent1, parent2 = repo.dirstate.parents()
368 356
369 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, commands.table) 357 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, commands.table)
370 if ui.verbose: 358 if ui.verbose:
371 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] 359 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
372 ui.write("%s\n" % "\n".join(sorted(cmdlist))) 360 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
361
362 @command('debugcreatestreamclonebundle', [], 'FILE')
363 def debugcreatestreamclonebundle(ui, repo, fname):
364 """create a stream clone bundle file
365
366 Stream bundles are special bundles that are essentially archives of
367 revlog files. They are commonly used for cloning very quickly.
368 """
369 requirements, gen = streamclone.generatebundlev1(repo)
370 changegroup.writechunks(ui, gen, fname)
371
372 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
373 373
374 @command('debugdag', 374 @command('debugdag',
375 [('t', 'tags', None, _('use tags as labels')), 375 [('t', 'tags', None, _('use tags as labels')),
376 ('b', 'branches', None, _('annotate with branch names')), 376 ('b', 'branches', None, _('annotate with branch names')),
377 ('', 'dots', None, _('use dots for runs')), 377 ('', 'dots', None, _('use dots for runs')),
463 ui.write(("standard: %s\n") % util.datestr(d)) 463 ui.write(("standard: %s\n") % util.datestr(d))
464 if range: 464 if range:
465 m = util.matchdate(range) 465 m = util.matchdate(range)
466 ui.write(("match: %s\n") % m(d[0])) 466 ui.write(("match: %s\n") % m(d[0]))
467 467
468 @command('debugdeltachain',
469 commands.debugrevlogopts + commands.formatteropts,
470 _('-c|-m|FILE'),
471 optionalrepo=True)
472 def debugdeltachain(ui, repo, file_=None, **opts):
473 """dump information about delta chains in a revlog
474
475 Output can be templatized. Available template keywords are:
476
477 :``rev``: revision number
478 :``chainid``: delta chain identifier (numbered by unique base)
479 :``chainlen``: delta chain length to this revision
480 :``prevrev``: previous revision in delta chain
481 :``deltatype``: role of delta / how it was computed
482 :``compsize``: compressed size of revision
483 :``uncompsize``: uncompressed size of revision
484 :``chainsize``: total size of compressed revisions in chain
485 :``chainratio``: total chain size divided by uncompressed revision size
486 (new delta chains typically start at ratio 2.00)
487 :``lindist``: linear distance from base revision in delta chain to end
488 of this revision
489 :``extradist``: total size of revisions not part of this delta chain from
490 base of delta chain to end of this revision; a measurement
491 of how much extra data we need to read/seek across to read
492 the delta chain for this revision
493 :``extraratio``: extradist divided by chainsize; another representation of
494 how much unrelated data is needed to load this delta chain
495 """
496 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
497 index = r.index
498 generaldelta = r.version & revlog.REVLOGGENERALDELTA
499
500 def revinfo(rev):
501 e = index[rev]
502 compsize = e[1]
503 uncompsize = e[2]
504 chainsize = 0
505
506 if generaldelta:
507 if e[3] == e[5]:
508 deltatype = 'p1'
509 elif e[3] == e[6]:
510 deltatype = 'p2'
511 elif e[3] == rev - 1:
512 deltatype = 'prev'
513 elif e[3] == rev:
514 deltatype = 'base'
515 else:
516 deltatype = 'other'
517 else:
518 if e[3] == rev:
519 deltatype = 'base'
520 else:
521 deltatype = 'prev'
522
523 chain = r._deltachain(rev)[0]
524 for iterrev in chain:
525 e = index[iterrev]
526 chainsize += e[1]
527
528 return compsize, uncompsize, deltatype, chain, chainsize
529
530 fm = ui.formatter('debugdeltachain', opts)
531
532 fm.plain(' rev chain# chainlen prev delta '
533 'size rawsize chainsize ratio lindist extradist '
534 'extraratio\n')
535
536 chainbases = {}
537 for rev in r:
538 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
539 chainbase = chain[0]
540 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
541 basestart = r.start(chainbase)
542 revstart = r.start(rev)
543 lineardist = revstart + comp - basestart
544 extradist = lineardist - chainsize
545 try:
546 prevrev = chain[-2]
547 except IndexError:
548 prevrev = -1
549
550 chainratio = float(chainsize) / float(uncomp)
551 extraratio = float(extradist) / float(chainsize)
552
553 fm.startitem()
554 fm.write('rev chainid chainlen prevrev deltatype compsize '
555 'uncompsize chainsize chainratio lindist extradist '
556 'extraratio',
557 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n',
558 rev, chainid, len(chain), prevrev, deltatype, comp,
559 uncomp, chainsize, chainratio, lineardist, extradist,
560 extraratio,
561 rev=rev, chainid=chainid, chainlen=len(chain),
562 prevrev=prevrev, deltatype=deltatype, compsize=comp,
563 uncompsize=uncomp, chainsize=chainsize,
564 chainratio=chainratio, lindist=lineardist,
565 extradist=extradist, extraratio=extraratio)
566
567 fm.end()
568
468 @command('debugdiscovery', 569 @command('debugdiscovery',
469 [('', 'old', None, _('use old-style discovery')), 570 [('', 'old', None, _('use old-style discovery')),
470 ('', 'nonheads', None, 571 ('', 'nonheads', None,
471 _('use old-style discovery with non-heads included')), 572 _('use old-style discovery with non-heads included')),
472 ] + commands.remoteopts, 573 ] + commands.remoteopts,
746 pp = r.parents(node) 847 pp = r.parents(node)
747 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) 848 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
748 if pp[1] != nullid: 849 if pp[1] != nullid:
749 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) 850 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
750 ui.write("}\n") 851 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()