Patchwork D2420: py3: fix handling of keyword arguments at more places

login
register
mail settings
Submitter phabricator
Date Feb. 24, 2018, 11:19 a.m.
Message ID <differential-rev-PHID-DREV-pmv7feq36nsxspmaubgh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28319/
State Superseded
Headers show

Comments

phabricator - Feb. 24, 2018, 11:19 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The keys of keyword arguments of Python 3 should be str, which is why we need to
  prevent getting the b'' prefix added by the transformer or convert keys to str
  using pycompat.strkwargs()

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2420

AFFECTED FILES
  hgext/largefiles/overrides.py
  hgext/lfs/__init__.py
  hgext/rebase.py
  hgext/split.py
  mercurial/localrepo.py
  mercurial/profiling.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 24, 2018, 12:58 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> rebase.py:597
> +            updatemq(repo, self.state, self.skipped,
> +                     **pycompat.byteskwargs(opts))
>  

strkwargs() ?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2420

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -143,7 +143,7 @@ 
         elif profformat == 'hotpath':
             # inconsistent config: profiling.showmin
             limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
-            kwargs['limit'] = limit
+            kwargs[r'limit'] = limit
 
         statprof.display(fp, data=data, format=displayformat, **kwargs)
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2170,10 +2170,11 @@ 
             hookargs = {}
             if tr is not None:
                 hookargs.update(tr.hookargs)
-            hookargs['namespace'] = namespace
-            hookargs['key'] = key
-            hookargs['old'] = old
-            hookargs['new'] = new
+            hookargs = pycompat.strkwargs(hookargs)
+            hookargs[r'namespace'] = namespace
+            hookargs[r'key'] = key
+            hookargs[r'old'] = old
+            hookargs[r'new'] = new
             self.hook('prepushkey', throw=True, **hookargs)
         except error.HookAbort as exc:
             self.ui.write_err(_("pushkey-abort: %s\n") % exc)
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -24,6 +24,7 @@ 
     hg,
     obsolete,
     phases,
+    pycompat,
     registrar,
     revsetlang,
     scmutil,
@@ -160,7 +161,7 @@ 
             'interactive': True,
             'message': header + ctx.description(),
         })
-        commands.commit(ui, repo, **opts)
+        commands.commit(ui, repo, **pycompat.strkwargs(opts))
         newctx = repo['.']
         committed.append(newctx)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -593,7 +593,8 @@ 
                     self.state[oldrev] = newrev
 
         if 'qtip' in repo.tags():
-            updatemq(repo, self.state, self.skipped, **opts)
+            updatemq(repo, self.state, self.skipped,
+                     **pycompat.byteskwargs(opts))
 
         # restore original working directory
         # (we do this before stripping)
diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -220,12 +220,12 @@ 
     if 'lfs' not in repo.requirements:
         def checkrequireslfs(ui, repo, **kwargs):
             if 'lfs' not in repo.requirements:
-                last = kwargs.get('node_last')
+                last = kwargs.get(r'node_last')
                 _bin = node.bin
                 if last:
-                    s = repo.set('%n:%n', _bin(kwargs['node']), _bin(last))
+                    s = repo.set('%n:%n', _bin(kwargs[r'node']), _bin(last))
                 else:
-                    s = repo.set('%n', _bin(kwargs['node']))
+                    s = repo.set('%n', _bin(kwargs[r'node']))
             for ctx in s:
                 # TODO: is there a way to just walk the files in the commit?
                 if any(ctx[f].islfs() for f in ctx.files() if f in ctx):
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -824,7 +824,7 @@ 
     """Override push command and store --lfrev parameters in opargs"""
     lfrevs = kwargs.pop(r'lfrev', None)
     if lfrevs:
-        opargs = kwargs.setdefault('opargs', {})
+        opargs = kwargs.setdefault(r'opargs', {})
         opargs['lfrevs'] = scmutil.revrange(repo, lfrevs)
     return orig(ui, repo, *args, **kwargs)