[PATCH 5 of 7] py3: workaround to prevent switching kwargs keys between str and bytes

Pulkit Goyal 7895pulkit at gmail.com
Sat Jun 17 08:45:23 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1497692808 -19800
#      Sat Jun 17 15:16:48 2017 +0530
# Node ID 48ef02400b59a6d9d250627d0e5f60e85c90cb06
# Parent  e95901baf03f983af8163a1d848233b29629d97b
py3: workaround to prevent switching kwargs keys between str and bytes

We are getting kwargs variable as keyword argument here, hence it keys must be
str. Also we need to pass that as keyword argument again, so its better to add
a r'' at few places instead of converting first to bytes and then to str.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1585,12 +1585,12 @@
     usebundle2 = bundle2requested(bundlecaps)
     # bundle10 case
     if not usebundle2:
-        if bundlecaps and not kwargs.get('cg', True):
+        if bundlecaps and not kwargs.get(r'cg', True):
             raise ValueError(_('request for bundle10 must include changegroup'))
 
         if kwargs:
-            raise ValueError(_('unsupported getbundle arguments: %s')
-                             % ', '.join(sorted(kwargs.keys())))
+            raise ValueError(_(r'unsupported getbundle arguments: %s')
+                             % r', '.join(sorted(kwargs.keys())))
         outgoing = _computeoutgoing(repo, heads, common)
         bundler = changegroup.getbundler('01', repo, bundlecaps)
         return changegroup.getsubsetraw(repo, outgoing, bundler, source)
@@ -1603,8 +1603,8 @@
             b2caps.update(bundle2.decodecaps(blob))
     bundler = bundle2.bundle20(repo.ui, b2caps)
 
-    kwargs['heads'] = heads
-    kwargs['common'] = common
+    kwargs[r'heads'] = heads
+    kwargs[r'common'] = common
 
     for name in getbundle2partsorder:
         func = getbundle2partsmapping[name]


More information about the Mercurial-devel mailing list