Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 33112:05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
This is used where ever required like where kwargs are passed into
ui.formatter(), scmutil.match() or cmdutil.openrevlog() which expects bytes.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 27 Jun 2017 00:20:55 +0530 |
parents | e21b750c9b9e |
children | b257aaa0743a |
comparison
equal
deleted
inserted
replaced
33111:4a8db3538c39 | 33112:05906b8e1d23 |
---|---|
289 ui.write("%s%s\n" % (indent_string, hex(node))) | 289 ui.write("%s%s\n" % (indent_string, hex(node))) |
290 chain = node | 290 chain = node |
291 | 291 |
292 def _debugobsmarkers(ui, part, indent=0, **opts): | 292 def _debugobsmarkers(ui, part, indent=0, **opts): |
293 """display version and markers contained in 'data'""" | 293 """display version and markers contained in 'data'""" |
294 opts = pycompat.byteskwargs(opts) | |
294 data = part.read() | 295 data = part.read() |
295 indent_string = ' ' * indent | 296 indent_string = ' ' * indent |
296 try: | 297 try: |
297 version, markers = obsolete._readmarkers(data) | 298 version, markers = obsolete._readmarkers(data) |
298 except error.UnknownVersion as exc: | 299 except error.UnknownVersion as exc: |
509 ui.write("\n") | 510 ui.write("\n") |
510 | 511 |
511 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) | 512 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) |
512 def debugdata(ui, repo, file_, rev=None, **opts): | 513 def debugdata(ui, repo, file_, rev=None, **opts): |
513 """dump the contents of a data file revision""" | 514 """dump the contents of a data file revision""" |
515 opts = pycompat.byteskwargs(opts) | |
514 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): | 516 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
515 if rev is not None: | 517 if rev is not None: |
516 raise error.CommandError('debugdata', _('invalid arguments')) | 518 raise error.CommandError('debugdata', _('invalid arguments')) |
517 file_, rev = None, file_ | 519 file_, rev = None, file_ |
518 elif rev is None: | 520 elif rev is None: |
565 of how much extra data we need to read/seek across to read | 567 of how much extra data we need to read/seek across to read |
566 the delta chain for this revision | 568 the delta chain for this revision |
567 :``extraratio``: extradist divided by chainsize; another representation of | 569 :``extraratio``: extradist divided by chainsize; another representation of |
568 how much unrelated data is needed to load this delta chain | 570 how much unrelated data is needed to load this delta chain |
569 """ | 571 """ |
572 opts = pycompat.byteskwargs(opts) | |
570 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) | 573 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
571 index = r.index | 574 index = r.index |
572 generaldelta = r.version & revlog.FLAG_GENERALDELTA | 575 generaldelta = r.version & revlog.FLAG_GENERALDELTA |
573 | 576 |
574 def revinfo(rev): | 577 def revinfo(rev): |
677 _('use old-style discovery with non-heads included')), | 680 _('use old-style discovery with non-heads included')), |
678 ] + cmdutil.remoteopts, | 681 ] + cmdutil.remoteopts, |
679 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) | 682 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
680 def debugdiscovery(ui, repo, remoteurl="default", **opts): | 683 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
681 """runs the changeset discovery protocol in isolation""" | 684 """runs the changeset discovery protocol in isolation""" |
685 opts = pycompat.byteskwargs(opts) | |
682 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), | 686 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), |
683 opts.get('branch')) | 687 opts.get('branch')) |
684 remote = hg.peer(repo, opts, remoteurl) | 688 remote = hg.peer(repo, opts, remoteurl) |
685 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) | 689 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
686 | 690 |
738 doit(localrevs, remoterevs) | 742 doit(localrevs, remoterevs) |
739 | 743 |
740 @command('debugextensions', cmdutil.formatteropts, [], norepo=True) | 744 @command('debugextensions', cmdutil.formatteropts, [], norepo=True) |
741 def debugextensions(ui, **opts): | 745 def debugextensions(ui, **opts): |
742 '''show information about active extensions''' | 746 '''show information about active extensions''' |
747 opts = pycompat.byteskwargs(opts) | |
743 exts = extensions.extensions(ui) | 748 exts = extensions.extensions(ui) |
744 hgver = util.version() | 749 hgver = util.version() |
745 fm = ui.formatter('debugextensions', opts) | 750 fm = ui.formatter('debugextensions', opts) |
746 for extname, extmod in sorted(exts, key=operator.itemgetter(0)): | 751 for extname, extmod in sorted(exts, key=operator.itemgetter(0)): |
747 isinternal = extensions.ismoduleinternal(extmod) | 752 isinternal = extensions.ismoduleinternal(extmod) |
820 """retrieves a bundle from a repo | 825 """retrieves a bundle from a repo |
821 | 826 |
822 Every ID must be a full-length hex node id string. Saves the bundle to the | 827 Every ID must be a full-length hex node id string. Saves the bundle to the |
823 given file. | 828 given file. |
824 """ | 829 """ |
830 opts = pycompat.byteskwargs(opts) | |
825 repo = hg.peer(ui, opts, repopath) | 831 repo = hg.peer(ui, opts, repopath) |
826 if not repo.capable('getbundle'): | 832 if not repo.capable('getbundle'): |
827 raise error.Abort("getbundle() not supported by target repository") | 833 raise error.Abort("getbundle() not supported by target repository") |
828 args = {} | 834 args = {} |
829 if common: | 835 if common: |
889 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | 895 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
890 _('[-f FORMAT] -c|-m|FILE'), | 896 _('[-f FORMAT] -c|-m|FILE'), |
891 optionalrepo=True) | 897 optionalrepo=True) |
892 def debugindex(ui, repo, file_=None, **opts): | 898 def debugindex(ui, repo, file_=None, **opts): |
893 """dump the contents of an index file""" | 899 """dump the contents of an index file""" |
900 opts = pycompat.byteskwargs(opts) | |
894 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) | 901 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) |
895 format = opts.get('format', 0) | 902 format = opts.get('format', 0) |
896 if format not in (0, 1): | 903 if format not in (0, 1): |
897 raise error.Abort(_("unknown format %d") % format) | 904 raise error.Abort(_("unknown format %d") % format) |
898 | 905 |
943 | 950 |
944 @command('debugindexdot', cmdutil.debugrevlogopts, | 951 @command('debugindexdot', cmdutil.debugrevlogopts, |
945 _('-c|-m|FILE'), optionalrepo=True) | 952 _('-c|-m|FILE'), optionalrepo=True) |
946 def debugindexdot(ui, repo, file_=None, **opts): | 953 def debugindexdot(ui, repo, file_=None, **opts): |
947 """dump an index DAG as a graphviz dot file""" | 954 """dump an index DAG as a graphviz dot file""" |
955 opts = pycompat.byteskwargs(opts) | |
948 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) | 956 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) |
949 ui.write(("digraph G {\n")) | 957 ui.write(("digraph G {\n")) |
950 for i in r: | 958 for i in r: |
951 node = r.node(i) | 959 node = r.node(i) |
952 pp = r.parents(node) | 960 pp = r.parents(node) |
959 def debuginstall(ui, **opts): | 967 def debuginstall(ui, **opts): |
960 '''test Mercurial installation | 968 '''test Mercurial installation |
961 | 969 |
962 Returns 0 on success. | 970 Returns 0 on success. |
963 ''' | 971 ''' |
972 opts = pycompat.byteskwargs(opts) | |
964 | 973 |
965 def writetemp(contents): | 974 def writetemp(contents): |
966 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") | 975 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
967 f = os.fdopen(fd, pycompat.sysstr("wb")) | 976 f = os.fdopen(fd, pycompat.sysstr("wb")) |
968 f.write(contents) | 977 f.write(contents) |
1127 """test whether node ids are known to a repo | 1136 """test whether node ids are known to a repo |
1128 | 1137 |
1129 Every ID must be a full-length hex node id string. Returns a list of 0s | 1138 Every ID must be a full-length hex node id string. Returns a list of 0s |
1130 and 1s indicating unknown/known. | 1139 and 1s indicating unknown/known. |
1131 """ | 1140 """ |
1141 opts = pycompat.byteskwargs(opts) | |
1132 repo = hg.peer(ui, opts, repopath) | 1142 repo = hg.peer(ui, opts, repopath) |
1133 if not repo.capable('known'): | 1143 if not repo.capable('known'): |
1134 raise error.Abort("known() not supported by target repository") | 1144 raise error.Abort("known() not supported by target repository") |
1135 flags = repo.known([bin(s) for s in ids]) | 1145 flags = repo.known([bin(s) for s in ids]) |
1136 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) | 1146 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
1344 _('[OBSOLETED [REPLACEMENT ...]]')) | 1354 _('[OBSOLETED [REPLACEMENT ...]]')) |
1345 def debugobsolete(ui, repo, precursor=None, *successors, **opts): | 1355 def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
1346 """create arbitrary obsolete marker | 1356 """create arbitrary obsolete marker |
1347 | 1357 |
1348 With no arguments, displays the list of obsolescence markers.""" | 1358 With no arguments, displays the list of obsolescence markers.""" |
1359 | |
1360 opts = pycompat.byteskwargs(opts) | |
1349 | 1361 |
1350 def parsenodeid(s): | 1362 def parsenodeid(s): |
1351 try: | 1363 try: |
1352 # We do not use revsingle/revrange functions here to accept | 1364 # We do not use revsingle/revrange functions here to accept |
1353 # arbitrary node identifiers, possibly not present in the | 1365 # arbitrary node identifiers, possibly not present in the |
1556 If merge tool is chosen before matching against | 1568 If merge tool is chosen before matching against |
1557 ``merge-patterns``, this command can't show any helpful | 1569 ``merge-patterns``, this command can't show any helpful |
1558 information, even with --debug. In such case, information above is | 1570 information, even with --debug. In such case, information above is |
1559 useful to know why a merge tool is chosen. | 1571 useful to know why a merge tool is chosen. |
1560 """ | 1572 """ |
1573 opts = pycompat.byteskwargs(opts) | |
1561 overrides = {} | 1574 overrides = {} |
1562 if opts['tool']: | 1575 if opts['tool']: |
1563 overrides[('ui', 'forcemerge')] = opts['tool'] | 1576 overrides[('ui', 'forcemerge')] = opts['tool'] |
1564 ui.note(('with --tool %r\n') % (opts['tool'])) | 1577 ui.note(('with --tool %r\n') % (opts['tool'])) |
1565 | 1578 |
1677 [('r', 'rev', '', _('revision to debug'), _('REV'))], | 1690 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
1678 _('[-r REV] FILE')) | 1691 _('[-r REV] FILE')) |
1679 def debugrename(ui, repo, file1, *pats, **opts): | 1692 def debugrename(ui, repo, file1, *pats, **opts): |
1680 """dump rename information""" | 1693 """dump rename information""" |
1681 | 1694 |
1695 opts = pycompat.byteskwargs(opts) | |
1682 ctx = scmutil.revsingle(repo, opts.get('rev')) | 1696 ctx = scmutil.revsingle(repo, opts.get('rev')) |
1683 m = scmutil.match(ctx, (file1,) + pats, opts) | 1697 m = scmutil.match(ctx, (file1,) + pats, opts) |
1684 for abs in ctx.walk(m): | 1698 for abs in ctx.walk(m): |
1685 fctx = ctx[abs] | 1699 fctx = ctx[abs] |
1686 o = fctx.filelog().renamed(fctx.filenode()) | 1700 o = fctx.filelog().renamed(fctx.filenode()) |
1694 [('d', 'dump', False, _('dump index data'))], | 1708 [('d', 'dump', False, _('dump index data'))], |
1695 _('-c|-m|FILE'), | 1709 _('-c|-m|FILE'), |
1696 optionalrepo=True) | 1710 optionalrepo=True) |
1697 def debugrevlog(ui, repo, file_=None, **opts): | 1711 def debugrevlog(ui, repo, file_=None, **opts): |
1698 """show data and statistics about a revlog""" | 1712 """show data and statistics about a revlog""" |
1713 opts = pycompat.byteskwargs(opts) | |
1699 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) | 1714 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
1700 | 1715 |
1701 if opts.get("dump"): | 1716 if opts.get("dump"): |
1702 numrevs = len(r) | 1717 numrevs = len(r) |
1703 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" | 1718 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
1941 representation or the parsed tree respectively. | 1956 representation or the parsed tree respectively. |
1942 | 1957 |
1943 Use --verify-optimized to compare the optimized result with the unoptimized | 1958 Use --verify-optimized to compare the optimized result with the unoptimized |
1944 one. Returns 1 if the optimized result differs. | 1959 one. Returns 1 if the optimized result differs. |
1945 """ | 1960 """ |
1961 opts = pycompat.byteskwargs(opts) | |
1946 stages = [ | 1962 stages = [ |
1947 ('parsed', lambda tree: tree), | 1963 ('parsed', lambda tree: tree), |
1948 ('expanded', lambda tree: revsetlang.expandaliases(ui, tree)), | 1964 ('expanded', lambda tree: revsetlang.expandaliases(ui, tree)), |
1949 ('concatenated', revsetlang.foldconcat), | 1965 ('concatenated', revsetlang.foldconcat), |
1950 ('analyzed', revsetlang.analyze), | 1966 ('analyzed', revsetlang.analyze), |
2186 | 2202 |
2187 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), | 2203 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), |
2188 inferrepo=True) | 2204 inferrepo=True) |
2189 def debugwalk(ui, repo, *pats, **opts): | 2205 def debugwalk(ui, repo, *pats, **opts): |
2190 """show how files match on given patterns""" | 2206 """show how files match on given patterns""" |
2207 opts = pycompat.byteskwargs(opts) | |
2191 m = scmutil.match(repo[None], pats, opts) | 2208 m = scmutil.match(repo[None], pats, opts) |
2192 ui.write(('matcher: %r\n' % m)) | 2209 ui.write(('matcher: %r\n' % m)) |
2193 items = list(repo[None].walk(m)) | 2210 items = list(repo[None].walk(m)) |
2194 if not items: | 2211 if not items: |
2195 return | 2212 return |
2209 ('', 'five', '', 'five'), | 2226 ('', 'five', '', 'five'), |
2210 ] + cmdutil.remoteopts, | 2227 ] + cmdutil.remoteopts, |
2211 _('REPO [OPTIONS]... [ONE [TWO]]'), | 2228 _('REPO [OPTIONS]... [ONE [TWO]]'), |
2212 norepo=True) | 2229 norepo=True) |
2213 def debugwireargs(ui, repopath, *vals, **opts): | 2230 def debugwireargs(ui, repopath, *vals, **opts): |
2231 opts = pycompat.byteskwargs(opts) | |
2214 repo = hg.peer(ui, opts, repopath) | 2232 repo = hg.peer(ui, opts, repopath) |
2215 for opt in cmdutil.remoteopts: | 2233 for opt in cmdutil.remoteopts: |
2216 del opts[opt[1]] | 2234 del opts[opt[1]] |
2217 args = {} | 2235 args = {} |
2218 for k, v in opts.iteritems(): | 2236 for k, v in opts.iteritems(): |