py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 27 Jun 2017 00:20:55 +0530
changeset 33112 05906b8e1d23
parent 33111 4a8db3538c39
child 33113 b257aaa0743a
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.
mercurial/cmdutil.py
mercurial/debugcommands.py
mercurial/sshpeer.py
--- a/mercurial/cmdutil.py	Tue Jun 27 02:24:38 2017 +0900
+++ b/mercurial/cmdutil.py	Tue Jun 27 00:20:55 2017 +0530
@@ -1332,6 +1332,7 @@
             self.ui.write(self.footer)
 
     def show(self, ctx, copies=None, matchfn=None, **props):
+        props = pycompat.byteskwargs(props)
         if self.buffered:
             self.ui.pushbuffer(labeled=True)
             self._show(ctx, copies, matchfn, props)
--- a/mercurial/debugcommands.py	Tue Jun 27 02:24:38 2017 +0900
+++ b/mercurial/debugcommands.py	Tue Jun 27 00:20:55 2017 +0530
@@ -291,6 +291,7 @@
 
 def _debugobsmarkers(ui, part, indent=0, **opts):
     """display version and markers contained in 'data'"""
+    opts = pycompat.byteskwargs(opts)
     data = part.read()
     indent_string = ' ' * indent
     try:
@@ -511,6 +512,7 @@
 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV'))
 def debugdata(ui, repo, file_, rev=None, **opts):
     """dump the contents of a data file revision"""
+    opts = pycompat.byteskwargs(opts)
     if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
         if rev is not None:
             raise error.CommandError('debugdata', _('invalid arguments'))
@@ -567,6 +569,7 @@
     :``extraratio``: extradist divided by chainsize; another representation of
                     how much unrelated data is needed to load this delta chain
     """
+    opts = pycompat.byteskwargs(opts)
     r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
     index = r.index
     generaldelta = r.version & revlog.FLAG_GENERALDELTA
@@ -679,6 +682,7 @@
     _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
 def debugdiscovery(ui, repo, remoteurl="default", **opts):
     """runs the changeset discovery protocol in isolation"""
+    opts = pycompat.byteskwargs(opts)
     remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
                                       opts.get('branch'))
     remote = hg.peer(repo, opts, remoteurl)
@@ -740,6 +744,7 @@
 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
 def debugextensions(ui, **opts):
     '''show information about active extensions'''
+    opts = pycompat.byteskwargs(opts)
     exts = extensions.extensions(ui)
     hgver = util.version()
     fm = ui.formatter('debugextensions', opts)
@@ -822,6 +827,7 @@
     Every ID must be a full-length hex node id string. Saves the bundle to the
     given file.
     """
+    opts = pycompat.byteskwargs(opts)
     repo = hg.peer(ui, opts, repopath)
     if not repo.capable('getbundle'):
         raise error.Abort("getbundle() not supported by target repository")
@@ -891,6 +897,7 @@
     optionalrepo=True)
 def debugindex(ui, repo, file_=None, **opts):
     """dump the contents of an index file"""
+    opts = pycompat.byteskwargs(opts)
     r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
     format = opts.get('format', 0)
     if format not in (0, 1):
@@ -945,6 +952,7 @@
     _('-c|-m|FILE'), optionalrepo=True)
 def debugindexdot(ui, repo, file_=None, **opts):
     """dump an index DAG as a graphviz dot file"""
+    opts = pycompat.byteskwargs(opts)
     r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts)
     ui.write(("digraph G {\n"))
     for i in r:
@@ -961,6 +969,7 @@
 
     Returns 0 on success.
     '''
+    opts = pycompat.byteskwargs(opts)
 
     def writetemp(contents):
         (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
@@ -1129,6 +1138,7 @@
     Every ID must be a full-length hex node id string. Returns a list of 0s
     and 1s indicating unknown/known.
     """
+    opts = pycompat.byteskwargs(opts)
     repo = hg.peer(ui, opts, repopath)
     if not repo.capable('known'):
         raise error.Abort("known() not supported by target repository")
@@ -1347,6 +1357,8 @@
 
     With no arguments, displays the list of obsolescence markers."""
 
+    opts = pycompat.byteskwargs(opts)
+
     def parsenodeid(s):
         try:
             # We do not use revsingle/revrange functions here to accept
@@ -1558,6 +1570,7 @@
     information, even with --debug. In such case, information above is
     useful to know why a merge tool is chosen.
     """
+    opts = pycompat.byteskwargs(opts)
     overrides = {}
     if opts['tool']:
         overrides[('ui', 'forcemerge')] = opts['tool']
@@ -1679,6 +1692,7 @@
 def debugrename(ui, repo, file1, *pats, **opts):
     """dump rename information"""
 
+    opts = pycompat.byteskwargs(opts)
     ctx = scmutil.revsingle(repo, opts.get('rev'))
     m = scmutil.match(ctx, (file1,) + pats, opts)
     for abs in ctx.walk(m):
@@ -1696,6 +1710,7 @@
     optionalrepo=True)
 def debugrevlog(ui, repo, file_=None, **opts):
     """show data and statistics about a revlog"""
+    opts = pycompat.byteskwargs(opts)
     r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
 
     if opts.get("dump"):
@@ -1943,6 +1958,7 @@
     Use --verify-optimized to compare the optimized result with the unoptimized
     one. Returns 1 if the optimized result differs.
     """
+    opts = pycompat.byteskwargs(opts)
     stages = [
         ('parsed', lambda tree: tree),
         ('expanded', lambda tree: revsetlang.expandaliases(ui, tree)),
@@ -2188,6 +2204,7 @@
          inferrepo=True)
 def debugwalk(ui, repo, *pats, **opts):
     """show how files match on given patterns"""
+    opts = pycompat.byteskwargs(opts)
     m = scmutil.match(repo[None], pats, opts)
     ui.write(('matcher: %r\n' % m))
     items = list(repo[None].walk(m))
@@ -2211,6 +2228,7 @@
     _('REPO [OPTIONS]... [ONE [TWO]]'),
     norepo=True)
 def debugwireargs(ui, repopath, *vals, **opts):
+    opts = pycompat.byteskwargs(opts)
     repo = hg.peer(ui, opts, repopath)
     for opt in cmdutil.remoteopts:
         del opts[opt[1]]
--- a/mercurial/sshpeer.py	Tue Jun 27 02:24:38 2017 +0900
+++ b/mercurial/sshpeer.py	Tue Jun 27 00:20:55 2017 +0530
@@ -12,6 +12,7 @@
 from .i18n import _
 from . import (
     error,
+    pycompat,
     util,
     wireproto,
 )
@@ -259,6 +260,7 @@
         yield wireproto.unescapearg(work)
 
     def _callstream(self, cmd, **args):
+        args = pycompat.byteskwargs(args)
         self.ui.debug("sending %s command\n" % cmd)
         self.pipeo.write("%s\n" % cmd)
         _func, names = wireproto.commands[cmd]