Patchwork [5,of,6] py3: use r'' to access values from kwargs where keys are str

login
register
mail settings
Submitter Pulkit Goyal
Date June 20, 2017, 11:31 p.m.
Message ID <41cfbb320dd387e96fdf.1498001491@workspace>
Download mbox | patch
Permalink /patch/21552/
State Accepted
Headers show

Comments

Pulkit Goyal - June 20, 2017, 11:31 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1497991414 -19800
#      Wed Jun 21 02:13:34 2017 +0530
# Node ID 41cfbb320dd387e96fdf44b114cbaa8053a892cb
# Parent  4b07a8a4b8560edf9ec3cbe593d211171d10bf38
py3: use r'' to access values from kwargs where keys are str

These are the cases where either args is again passed as keyword argument or 1
or 2 elements are accessed. So it's better to add an r'' to prevent it
converting to bytes rather than doing the conversion of args.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -286,7 +286,7 @@ 
     """String. The name of the branch on which the changeset was
     committed.
     """
-    return args['ctx'].branch()
+    return args[r'ctx'].branch()
 
 @templatekeyword('branches')
 def showbranches(**args):
@@ -332,8 +332,8 @@ 
 def showactivebookmark(**args):
     """String. The active bookmark, if it is
     associated with the changeset"""
-    active = args['repo']._activebookmark
-    if active and active in args['ctx'].bookmarks():
+    active = args[r'repo']._activebookmark
+    if active and active in args[r'ctx'].bookmarks():
         return active
     return ''
 
@@ -516,7 +516,7 @@ 
 def _showchangessincetag(repo, ctx, **args):
     offset = 0
     revs = [ctx.rev()]
-    tag = args['tag']
+    tag = args[r'tag']
 
     # The only() revset doesn't currently support wdir()
     if ctx.rev() is None:
@@ -527,14 +527,14 @@ 
 
 @templatekeyword('manifest')
 def showmanifest(**args):
-    repo, ctx, templ = args['repo'], args['ctx'], args['templ']
+    repo, ctx, templ = args[r'repo'], args[r'ctx'], args[r'templ']
     mnode = ctx.manifestnode()
     if mnode is None:
         # just avoid crash, we might want to use the 'ff...' hash in future
         return
     args = args.copy()
-    args.update({'rev': repo.manifestlog._revlog.rev(mnode),
-                 'node': hex(mnode)})
+    args.update({r'rev': repo.manifestlog._revlog.rev(mnode),
+                 r'node': hex(mnode)})
     return templ('manifest', **args)
 
 def shownames(namespace, **args):