Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 32414:04baab18d60a
commands: move templates of common command options to cmdutil (API)
The goal is to get rid of the debugcommands -> commands dependency.
Since globalopts is the property of the commands, it's kept in the commands
module.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 14 May 2017 16:19:47 +0900 |
parents | 151cc3b3d799 |
children | b16cb0a27377 |
comparison
equal
deleted
inserted
replaced
32413:194b0f781132 | 32414:04baab18d60a |
---|---|
499 usedots=dots, | 499 usedots=dots, |
500 maxlinewidth=70): | 500 maxlinewidth=70): |
501 ui.write(line) | 501 ui.write(line) |
502 ui.write("\n") | 502 ui.write("\n") |
503 | 503 |
504 @command('debugdata', commands.debugrevlogopts, _('-c|-m|FILE REV')) | 504 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) |
505 def debugdata(ui, repo, file_, rev=None, **opts): | 505 def debugdata(ui, repo, file_, rev=None, **opts): |
506 """dump the contents of a data file revision""" | 506 """dump the contents of a data file revision""" |
507 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): | 507 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
508 if rev is not None: | 508 if rev is not None: |
509 raise error.CommandError('debugdata', _('invalid arguments')) | 509 raise error.CommandError('debugdata', _('invalid arguments')) |
531 if range: | 531 if range: |
532 m = util.matchdate(range) | 532 m = util.matchdate(range) |
533 ui.write(("match: %s\n") % m(d[0])) | 533 ui.write(("match: %s\n") % m(d[0])) |
534 | 534 |
535 @command('debugdeltachain', | 535 @command('debugdeltachain', |
536 commands.debugrevlogopts + commands.formatteropts, | 536 cmdutil.debugrevlogopts + cmdutil.formatteropts, |
537 _('-c|-m|FILE'), | 537 _('-c|-m|FILE'), |
538 optionalrepo=True) | 538 optionalrepo=True) |
539 def debugdeltachain(ui, repo, file_=None, **opts): | 539 def debugdeltachain(ui, repo, file_=None, **opts): |
540 """dump information about delta chains in a revlog | 540 """dump information about delta chains in a revlog |
541 | 541 |
666 | 666 |
667 @command('debugdiscovery', | 667 @command('debugdiscovery', |
668 [('', 'old', None, _('use old-style discovery')), | 668 [('', 'old', None, _('use old-style discovery')), |
669 ('', 'nonheads', None, | 669 ('', 'nonheads', None, |
670 _('use old-style discovery with non-heads included')), | 670 _('use old-style discovery with non-heads included')), |
671 ] + commands.remoteopts, | 671 ] + cmdutil.remoteopts, |
672 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) | 672 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
673 def debugdiscovery(ui, repo, remoteurl="default", **opts): | 673 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
674 """runs the changeset discovery protocol in isolation""" | 674 """runs the changeset discovery protocol in isolation""" |
675 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), | 675 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), |
676 opts.get('branch')) | 676 opts.get('branch')) |
728 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, | 728 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
729 opts.get('remote_head')) | 729 opts.get('remote_head')) |
730 localrevs = opts.get('local_head') | 730 localrevs = opts.get('local_head') |
731 doit(localrevs, remoterevs) | 731 doit(localrevs, remoterevs) |
732 | 732 |
733 @command('debugextensions', commands.formatteropts, [], norepo=True) | 733 @command('debugextensions', cmdutil.formatteropts, [], norepo=True) |
734 def debugextensions(ui, **opts): | 734 def debugextensions(ui, **opts): |
735 '''show information about active extensions''' | 735 '''show information about active extensions''' |
736 exts = extensions.extensions(ui) | 736 exts = extensions.extensions(ui) |
737 hgver = util.version() | 737 hgver = util.version() |
738 fm = ui.formatter('debugextensions', opts) | 738 fm = ui.formatter('debugextensions', opts) |
880 ui.write(_("(ignore rule in %s, line %d: '%s')\n") | 880 ui.write(_("(ignore rule in %s, line %d: '%s')\n") |
881 % (ignorefile, lineno, line)) | 881 % (ignorefile, lineno, line)) |
882 else: | 882 else: |
883 ui.write(_("%s is not ignored\n") % f) | 883 ui.write(_("%s is not ignored\n") % f) |
884 | 884 |
885 @command('debugindex', commands.debugrevlogopts + | 885 @command('debugindex', cmdutil.debugrevlogopts + |
886 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | 886 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
887 _('[-f FORMAT] -c|-m|FILE'), | 887 _('[-f FORMAT] -c|-m|FILE'), |
888 optionalrepo=True) | 888 optionalrepo=True) |
889 def debugindex(ui, repo, file_=None, **opts): | 889 def debugindex(ui, repo, file_=None, **opts): |
890 """dump the contents of an index file""" | 890 """dump the contents of an index file""" |
936 pr = r.parentrevs(i) | 936 pr = r.parentrevs(i) |
937 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( | 937 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( |
938 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), | 938 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
939 base, r.linkrev(i), pr[0], pr[1], shortfn(node))) | 939 base, r.linkrev(i), pr[0], pr[1], shortfn(node))) |
940 | 940 |
941 @command('debugindexdot', commands.debugrevlogopts, | 941 @command('debugindexdot', cmdutil.debugrevlogopts, |
942 _('-c|-m|FILE'), optionalrepo=True) | 942 _('-c|-m|FILE'), optionalrepo=True) |
943 def debugindexdot(ui, repo, file_=None, **opts): | 943 def debugindexdot(ui, repo, file_=None, **opts): |
944 """dump an index DAG as a graphviz dot file""" | 944 """dump an index DAG as a graphviz dot file""" |
945 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) | 945 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) |
946 ui.write(("digraph G {\n")) | 946 ui.write(("digraph G {\n")) |
950 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | 950 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
951 if pp[1] != nullid: | 951 if pp[1] != nullid: |
952 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) | 952 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
953 ui.write("}\n") | 953 ui.write("}\n") |
954 | 954 |
955 @command('debuginstall', [] + commands.formatteropts, '', norepo=True) | 955 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True) |
956 def debuginstall(ui, **opts): | 956 def debuginstall(ui, **opts): |
957 '''test Mercurial installation | 957 '''test Mercurial installation |
958 | 958 |
959 Returns 0 on success. | 959 Returns 0 on success. |
960 ''' | 960 ''' |
1333 ('', 'record-parents', False, | 1333 ('', 'record-parents', False, |
1334 _('record parent information for the precursor')), | 1334 _('record parent information for the precursor')), |
1335 ('r', 'rev', [], _('display markers relevant to REV')), | 1335 ('r', 'rev', [], _('display markers relevant to REV')), |
1336 ('', 'index', False, _('display index of the marker')), | 1336 ('', 'index', False, _('display index of the marker')), |
1337 ('', 'delete', [], _('delete markers specified by indices')), | 1337 ('', 'delete', [], _('delete markers specified by indices')), |
1338 ] + commands.commitopts2 + commands.formatteropts, | 1338 ] + cmdutil.commitopts2 + cmdutil.formatteropts, |
1339 _('[OBSOLETED [REPLACEMENT ...]]')) | 1339 _('[OBSOLETED [REPLACEMENT ...]]')) |
1340 def debugobsolete(ui, repo, precursor=None, *successors, **opts): | 1340 def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
1341 """create arbitrary obsolete marker | 1341 """create arbitrary obsolete marker |
1342 | 1342 |
1343 With no arguments, displays the list of obsolescence markers.""" | 1343 With no arguments, displays the list of obsolescence markers.""" |
1505 ui.write('\n') | 1505 ui.write('\n') |
1506 | 1506 |
1507 @command('debugpickmergetool', | 1507 @command('debugpickmergetool', |
1508 [('r', 'rev', '', _('check for files in this revision'), _('REV')), | 1508 [('r', 'rev', '', _('check for files in this revision'), _('REV')), |
1509 ('', 'changedelete', None, _('emulate merging change and delete')), | 1509 ('', 'changedelete', None, _('emulate merging change and delete')), |
1510 ] + commands.walkopts + commands.mergetoolopts, | 1510 ] + cmdutil.walkopts + cmdutil.mergetoolopts, |
1511 _('[PATTERN]...'), | 1511 _('[PATTERN]...'), |
1512 inferrepo=True) | 1512 inferrepo=True) |
1513 def debugpickmergetool(ui, repo, *pats, **opts): | 1513 def debugpickmergetool(ui, repo, *pats, **opts): |
1514 """examine which merge tool is chosen for specified file | 1514 """examine which merge tool is chosen for specified file |
1515 | 1515 |
1682 if o: | 1682 if o: |
1683 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | 1683 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
1684 else: | 1684 else: |
1685 ui.write(_("%s not renamed\n") % rel) | 1685 ui.write(_("%s not renamed\n") % rel) |
1686 | 1686 |
1687 @command('debugrevlog', commands.debugrevlogopts + | 1687 @command('debugrevlog', cmdutil.debugrevlogopts + |
1688 [('d', 'dump', False, _('dump index data'))], | 1688 [('d', 'dump', False, _('dump index data'))], |
1689 _('-c|-m|FILE'), | 1689 _('-c|-m|FILE'), |
1690 optionalrepo=True) | 1690 optionalrepo=True) |
1691 def debugrevlog(ui, repo, file_=None, **opts): | 1691 def debugrevlog(ui, repo, file_=None, **opts): |
1692 """show data and statistics about a revlog""" | 1692 """show data and statistics about a revlog""" |
2161 should complete almost instantaneously and the chances of a consumer being | 2161 should complete almost instantaneously and the chances of a consumer being |
2162 unable to access the repository should be low. | 2162 unable to access the repository should be low. |
2163 """ | 2163 """ |
2164 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize) | 2164 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize) |
2165 | 2165 |
2166 @command('debugwalk', commands.walkopts, _('[OPTION]... [FILE]...'), | 2166 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), |
2167 inferrepo=True) | 2167 inferrepo=True) |
2168 def debugwalk(ui, repo, *pats, **opts): | 2168 def debugwalk(ui, repo, *pats, **opts): |
2169 """show how files match on given patterns""" | 2169 """show how files match on given patterns""" |
2170 m = scmutil.match(repo[None], pats, opts) | 2170 m = scmutil.match(repo[None], pats, opts) |
2171 items = list(repo[None].walk(m)) | 2171 items = list(repo[None].walk(m)) |
2183 | 2183 |
2184 @command('debugwireargs', | 2184 @command('debugwireargs', |
2185 [('', 'three', '', 'three'), | 2185 [('', 'three', '', 'three'), |
2186 ('', 'four', '', 'four'), | 2186 ('', 'four', '', 'four'), |
2187 ('', 'five', '', 'five'), | 2187 ('', 'five', '', 'five'), |
2188 ] + commands.remoteopts, | 2188 ] + cmdutil.remoteopts, |
2189 _('REPO [OPTIONS]... [ONE [TWO]]'), | 2189 _('REPO [OPTIONS]... [ONE [TWO]]'), |
2190 norepo=True) | 2190 norepo=True) |
2191 def debugwireargs(ui, repopath, *vals, **opts): | 2191 def debugwireargs(ui, repopath, *vals, **opts): |
2192 repo = hg.peer(ui, opts, repopath) | 2192 repo = hg.peer(ui, opts, repopath) |
2193 for opt in commands.remoteopts: | 2193 for opt in cmdutil.remoteopts: |
2194 del opts[opt[1]] | 2194 del opts[opt[1]] |
2195 args = {} | 2195 args = {} |
2196 for k, v in opts.iteritems(): | 2196 for k, v in opts.iteritems(): |
2197 if v: | 2197 if v: |
2198 args[k] = v | 2198 args[k] = v |