D5259: py3: fix keyword arguments handling in hgext/remotefilelog/

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Tue Nov 13 13:49:51 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG13d4ad8d7801: py3: fix keyword arguments handling in hgext/remotefilelog/ (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5259?vs=12516&id=12522

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/basestore.py
  hgext/remotefilelog/contentstore.py
  hgext/remotefilelog/debugcommands.py
  hgext/remotefilelog/fileserverclient.py
  hgext/remotefilelog/metadatastore.py
  hgext/remotefilelog/remotefilectx.py
  hgext/remotefilelog/shallowbundle.py
  hgext/remotefilelog/shallowutil.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowutil.py b/hgext/remotefilelog/shallowutil.py
--- a/hgext/remotefilelog/shallowutil.py
+++ b/hgext/remotefilelog/shallowutil.py
@@ -105,7 +105,7 @@
 def reportpackmetrics(ui, prefix, *stores):
     dicts = [s.getmetrics() for s in stores]
     dict = prefixkeys(sumdicts(*dicts), prefix + '_')
-    ui.log(prefix + "_packsizes", "", **dict)
+    ui.log(prefix + "_packsizes", "", **pycompat.strkwargs(dict))
 
 def _parsepackmeta(metabuf):
     """parse datapack meta, bytes (<metadata-list>) -> dict
diff --git a/hgext/remotefilelog/shallowbundle.py b/hgext/remotefilelog/shallowbundle.py
--- a/hgext/remotefilelog/shallowbundle.py
+++ b/hgext/remotefilelog/shallowbundle.py
@@ -146,7 +146,7 @@
     try:
         # if serving, only send files the clients has patterns for
         if source == 'serve':
-            bundlecaps = kwargs.get('bundlecaps')
+            bundlecaps = kwargs.get(r'bundlecaps')
             includepattern = None
             excludepattern = None
             for cap in (bundlecaps or []):
diff --git a/hgext/remotefilelog/remotefilectx.py b/hgext/remotefilelog/remotefilectx.py
--- a/hgext/remotefilelog/remotefilectx.py
+++ b/hgext/remotefilelog/remotefilectx.py
@@ -15,6 +15,7 @@
     context,
     error,
     phases,
+    pycompat,
     util,
 )
 from . import shallowutil
@@ -218,11 +219,11 @@
             return linknode
 
         commonlogkwargs = {
-            'revs': ' '.join([hex(cl.node(rev)) for rev in revs]),
-            'fnode': hex(fnode),
-            'filepath': path,
-            'user': shallowutil.getusername(repo.ui),
-            'reponame': shallowutil.getreponame(repo.ui),
+            r'revs': ' '.join([hex(cl.node(rev)) for rev in revs]),
+            r'fnode': hex(fnode),
+            r'filepath': path,
+            r'user': shallowutil.getusername(repo.ui),
+            r'reponame': shallowutil.getreponame(repo.ui),
         }
 
         repo.ui.log('linkrevfixup', 'adjusting linknode', **commonlogkwargs)
@@ -315,7 +316,7 @@
         finally:
             elapsed = time.time() - start
             repo.ui.log('linkrevfixup', logmsg, elapsed=elapsed * 1000,
-                        **commonlogkwargs)
+                        **pycompat.strkwargs(commonlogkwargs))
 
     def _verifylinknode(self, revs, linknode):
         """
@@ -408,7 +409,7 @@
 
     def annotate(self, *args, **kwargs):
         introctx = self
-        prefetchskip = kwargs.pop('prefetchskip', None)
+        prefetchskip = kwargs.pop(r'prefetchskip', None)
         if prefetchskip:
             # use introrev so prefetchskip can be accurately tested
             introrev = self.introrev()
diff --git a/hgext/remotefilelog/metadatastore.py b/hgext/remotefilelog/metadatastore.py
--- a/hgext/remotefilelog/metadatastore.py
+++ b/hgext/remotefilelog/metadatastore.py
@@ -11,12 +11,12 @@
         super(unionmetadatastore, self).__init__(*args, **kwargs)
 
         self.stores = args
-        self.writestore = kwargs.get('writestore')
+        self.writestore = kwargs.get(r'writestore')
 
         # If allowincomplete==True then the union store can return partial
         # ancestor lists, otherwise it will throw a KeyError if a full
         # history can't be found.
-        self.allowincomplete = kwargs.get('allowincomplete', False)
+        self.allowincomplete = kwargs.get(r'allowincomplete', False)
 
     def getancestors(self, name, node, known=None):
         """Returns as many ancestors as we're aware of.
diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py
--- a/hgext/remotefilelog/fileserverclient.py
+++ b/hgext/remotefilelog/fileserverclient.py
@@ -18,6 +18,7 @@
 from mercurial.node import bin, hex, nullid
 from mercurial import (
     error,
+    pycompat,
     revlog,
     sshpeer,
     util,
@@ -119,7 +120,7 @@
         def _callstream(self, command, **opts):
             supertype = super(remotefilepeer, self)
             if not util.safehasattr(supertype, '_sendrequest'):
-                self._updatecallstreamopts(command, opts)
+                self._updatecallstreamopts(command, pycompat.byteskwargs(opts))
             return super(remotefilepeer, self)._callstream(command, **opts)
 
     peer.__class__ = remotefilepeer
diff --git a/hgext/remotefilelog/debugcommands.py b/hgext/remotefilelog/debugcommands.py
--- a/hgext/remotefilelog/debugcommands.py
+++ b/hgext/remotefilelog/debugcommands.py
@@ -28,7 +28,7 @@
 )
 
 def debugremotefilelog(ui, path, **opts):
-    decompress = opts.get('decompress')
+    decompress = opts.get(r'decompress')
 
     size, firstnode, mapping = parsefileblob(path, decompress)
 
@@ -89,9 +89,9 @@
 
 def debugindex(orig, ui, repo, file_=None, **opts):
     """dump the contents of an index file"""
-    if (opts.get('changelog') or
-        opts.get('manifest') or
-        opts.get('dir') or
+    if (opts.get(r'changelog') or
+        opts.get(r'manifest') or
+        opts.get(r'dir') or
         not shallowutil.isenabled(repo) or
         not repo.shallowmatch(file_)):
         return orig(ui, repo, file_, **opts)
@@ -154,7 +154,7 @@
     ui.write("}\n")
 
 def verifyremotefilelog(ui, path, **opts):
-    decompress = opts.get('decompress')
+    decompress = opts.get(r'decompress')
 
     for root, dirs, files in os.walk(path):
         for file in files:
@@ -213,13 +213,13 @@
             path = path[:path.index('.data')]
         ui.write("%s:\n" % path)
         dpack = datapack.datapack(path)
-        node = opts.get('node')
+        node = opts.get(r'node')
         if node:
             deltachain = dpack.getdeltachain('', bin(node))
             dumpdeltachain(ui, deltachain, **opts)
             return
 
-        if opts.get('long'):
+        if opts.get(r'long'):
             hashformatter = hex
             hashlen = 42
         else:
diff --git a/hgext/remotefilelog/contentstore.py b/hgext/remotefilelog/contentstore.py
--- a/hgext/remotefilelog/contentstore.py
+++ b/hgext/remotefilelog/contentstore.py
@@ -36,12 +36,12 @@
         super(unioncontentstore, self).__init__(*args, **kwargs)
 
         self.stores = args
-        self.writestore = kwargs.get('writestore')
+        self.writestore = kwargs.get(r'writestore')
 
         # If allowincomplete==True then the union store can return partial
         # delta chains, otherwise it will throw a KeyError if a full
         # deltachain can't be found.
-        self.allowincomplete = kwargs.get('allowincomplete', False)
+        self.allowincomplete = kwargs.get(r'allowincomplete', False)
 
     def get(self, name, node):
         """Fetches the full text revision contents of the given name+node pair.
diff --git a/hgext/remotefilelog/basestore.py b/hgext/remotefilelog/basestore.py
--- a/hgext/remotefilelog/basestore.py
+++ b/hgext/remotefilelog/basestore.py
@@ -392,10 +392,10 @@
         # throw a KeyError, try this many times with a full refresh between
         # attempts. A repack operation may have moved data from one store to
         # another while we were running.
-        self.numattempts = kwargs.get('numretries', 0) + 1
+        self.numattempts = kwargs.get(r'numretries', 0) + 1
         # If not-None, call this function on every retry and if the attempts are
         # exhausted.
-        self.retrylog = kwargs.get('retrylog', None)
+        self.retrylog = kwargs.get(r'retrylog', None)
 
     def markforrefresh(self):
         for store in self.stores:
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -151,6 +151,7 @@
     merge,
     node as nodemod,
     patch,
+    pycompat,
     registrar,
     repair,
     repoview,
@@ -272,7 +273,7 @@
 
     # Prevent 'hg manifest --all'
     def _manifest(orig, ui, repo, *args, **opts):
-        if (isenabled(repo) and opts.get('all')):
+        if (isenabled(repo) and opts.get(r'all')):
             raise error.Abort(_("--all is not supported in a shallow repo"))
 
         return orig(ui, repo, *args, **opts)
@@ -294,7 +295,7 @@
     extensions.wrapcommand(commands.table, 'debugdata', debugdatashallow)
 
 def cloneshallow(orig, ui, repo, *args, **opts):
-    if opts.get('shallow'):
+    if opts.get(r'shallow'):
         repos = []
         def pull_shallow(orig, self, *args, **kwargs):
             if not isenabled(self):
@@ -327,9 +328,9 @@
                 if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps:
                     opts = {}
                     if repo.includepattern:
-                        opts['includepattern'] = '\0'.join(repo.includepattern)
+                        opts[r'includepattern'] = '\0'.join(repo.includepattern)
                     if repo.excludepattern:
-                        opts['excludepattern'] = '\0'.join(repo.excludepattern)
+                        opts[r'excludepattern'] = '\0'.join(repo.excludepattern)
                     return remote._callstream('stream_out_shallow', **opts)
                 else:
                     return orig()
@@ -360,7 +361,7 @@
     try:
         orig(ui, repo, *args, **opts)
     finally:
-        if opts.get('shallow'):
+        if opts.get(r'shallow'):
             for r in repos:
                 if util.safehasattr(r, 'fileservice'):
                     r.fileservice.close()
@@ -888,19 +889,20 @@
     if not isenabled(repo):
         return orig(ui, repo, *pats, **opts)
 
-    follow = opts.get('follow')
-    revs = opts.get('rev')
+    follow = opts.get(r'follow')
+    revs = opts.get(r'rev')
     if pats:
         # Force slowpath for non-follow patterns and follows that start from
         # non-working-copy-parent revs.
         if not follow or revs:
             # This forces the slowpath
-            opts['removed'] = True
+            opts[r'removed'] = True
 
         # If this is a non-follow log without any revs specified, recommend that
         # the user add -f to speed it up.
         if not follow and not revs:
-            match, pats = scmutil.matchandpats(repo['.'], pats, opts)
+            match, pats = scmutil.matchandpats(repo['.'], pats,
+                                               pycompat.byteskwargs(opts))
             isfile = not match.anypats()
             if isfile:
                 for file in match.files():
@@ -1104,6 +1106,7 @@
 
     Return 0 on success.
     """
+    opts = pycompat.byteskwargs(opts)
     if not isenabled(repo):
         raise error.Abort(_("repo is not shallow"))
 
@@ -1121,15 +1124,15 @@
      ('', 'packsonly', None, _('only repack packs (skip loose objects)'), None),
     ], _('hg repack [OPTIONS]'))
 def repack_(ui, repo, *pats, **opts):
-    if opts.get('background'):
-        repackmod.backgroundrepack(repo, incremental=opts.get('incremental'),
-                                   packsonly=opts.get('packsonly', False))
+    if opts.get(r'background'):
+        repackmod.backgroundrepack(repo, incremental=opts.get(r'incremental'),
+                                   packsonly=opts.get(r'packsonly', False))
         return
 
-    options = {'packsonly': opts.get('packsonly')}
+    options = {'packsonly': opts.get(r'packsonly')}
 
     try:
-        if opts.get('incremental'):
+        if opts.get(r'incremental'):
             repackmod.incrementalrepack(repo, options=options)
         else:
             repackmod.fullrepack(repo, options=options)



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


More information about the Mercurial-devel mailing list