Patchwork [02,of,10] py3: convert kwargs' keys to str using pycompat.strkwargs

login
register
mail settings
Submitter Pulkit Goyal
Date May 6, 2017, 3:01 a.m.
Message ID <2ed3b0dfc16ab5eb77fd.1494039674@pulkit-goyal>
Download mbox | patch
Permalink /patch/20470/
State Accepted
Headers show

Comments

Pulkit Goyal - May 6, 2017, 3:01 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493837661 -19800
#      Thu May 04 00:24:21 2017 +0530
# Node ID 2ed3b0dfc16ab5eb77fd95d4b09d312d43d76b4b
# Parent  72a79c82aa8913f1661af3d7dc3b14d856679bd9
py3: convert kwargs' keys to str using pycompat.strkwargs
Yuya Nishihara - May 7, 2017, 2:04 a.m.
On Sat, 06 May 2017 08:31:14 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1493837661 -19800
> #      Thu May 04 00:24:21 2017 +0530
> # Node ID 2ed3b0dfc16ab5eb77fd95d4b09d312d43d76b4b
> # Parent  72a79c82aa8913f1661af3d7dc3b14d856679bd9
> py3: convert kwargs' keys to str using pycompat.strkwargs
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1499,7 +1499,8 @@
>  
>          # write header
>          if self._parts['header']:
> -            h = templater.stringify(self.t(self._parts['header'], **props))
> +            h = templater.stringify(self.t(self._parts['header'],
> +                    **pycompat.strkwargs(props)))
>              if self.buffered:
>                  self.header[ctx.rev()] = h
>              else:
> @@ -1509,13 +1510,14 @@
>  
>          # write changeset metadata, then patch if requested
>          key = self._parts['changeset']
> -        self.ui.write(templater.stringify(self.t(key, **props)))
> +        self.ui.write(templater.stringify(self.t(key,
> +                                    **pycompat.strkwargs(props))))
>          self.showpatch(ctx, matchfn)
>  
>          if self._parts['footer']:
>              if not self.footer:
>                  self.footer = templater.stringify(
> -                    self.t(self._parts['footer'], **props))
> +                    self.t(self._parts['footer'], **pycompat.strkwargs(props)))

This is okay, but can't we reuse the result of pycompat.strkwargs(props)?
I think that's good for code readability.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1499,7 +1499,8 @@ 
 
         # write header
         if self._parts['header']:
-            h = templater.stringify(self.t(self._parts['header'], **props))
+            h = templater.stringify(self.t(self._parts['header'],
+                    **pycompat.strkwargs(props)))
             if self.buffered:
                 self.header[ctx.rev()] = h
             else:
@@ -1509,13 +1510,14 @@ 
 
         # write changeset metadata, then patch if requested
         key = self._parts['changeset']
-        self.ui.write(templater.stringify(self.t(key, **props)))
+        self.ui.write(templater.stringify(self.t(key,
+                                    **pycompat.strkwargs(props))))
         self.showpatch(ctx, matchfn)
 
         if self._parts['footer']:
             if not self.footer:
                 self.footer = templater.stringify(
-                    self.t(self._parts['footer'], **props))
+                    self.t(self._parts['footer'], **pycompat.strkwargs(props)))
 
 def gettemplate(ui, tmpl, style):
     """