diff tests/wireprotosimplecache.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents 2c4f656c8e9f
children 9d2b2df2c2ba
line wrap: on
line diff
--- a/tests/wireprotosimplecache.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/tests/wireprotosimplecache.py	Sun Oct 06 09:45:02 2019 -0400
@@ -19,21 +19,16 @@
     repository,
     util as interfaceutil,
 )
-from mercurial.utils import (
-    stringutil,
-)
+from mercurial.utils import stringutil
 
 CACHE = None
 
 configtable = {}
 configitem = registrar.configitem(configtable)
 
-configitem(b'simplecache', b'cacheapi',
-           default=False)
-configitem(b'simplecache', b'cacheobjects',
-           default=False)
-configitem(b'simplecache', b'redirectsfile',
-           default=None)
+configitem(b'simplecache', b'cacheapi', default=False)
+configitem(b'simplecache', b'cacheobjects', default=False)
+configitem(b'simplecache', b'redirectsfile', default=None)
 
 # API handler that makes cached keys available.
 def handlecacherequest(rctx, req, res, checkperm, urlparts):
@@ -60,19 +55,23 @@
     res.headers[b'Content-Type'] = b'application/mercurial-cbor'
     res.setbodybytes(CACHE[key])
 
+
 def cachedescriptor(req, repo):
     return {}
 
+
 wireprotoserver.API_HANDLERS[b'simplecache'] = {
     b'config': (b'simplecache', b'cacheapi'),
     b'handler': handlecacherequest,
     b'apidescriptor': cachedescriptor,
 }
 
+
 @interfaceutil.implementer(repository.iwireprotocolcommandcacher)
 class memorycacher(object):
-    def __init__(self, ui, command, encodefn, redirecttargets, redirecthashes,
-                 req):
+    def __init__(
+        self, ui, command, encodefn, redirecttargets, redirecthashes, req
+    ):
         self.ui = ui
         self.encodefn = encodefn
         self.redirecttargets = redirecttargets
@@ -131,12 +130,16 @@
 
             url = b'%s/%s' % (self.req.baseurl, b'/'.join(paths))
 
-            #url = b'http://example.com/%s' % self.key
-            self.ui.log(b'simplecache', b'sending content redirect for %s to '
-                                        b'%s\n', self.key, url)
+            # url = b'http://example.com/%s' % self.key
+            self.ui.log(
+                b'simplecache',
+                b'sending content redirect for %s to ' b'%s\n',
+                self.key,
+                url,
+            )
             response = wireprototypes.alternatelocationresponse(
-                url=url,
-                mediatype=b'application/mercurial-cbor')
+                url=url, mediatype=b'application/mercurial-cbor'
+            )
 
             return {b'objs': [response]}
 
@@ -166,10 +169,26 @@
 
         return []
 
-def makeresponsecacher(orig, repo, proto, command, args, objencoderfn,
-                       redirecttargets, redirecthashes):
-    return memorycacher(repo.ui, command, objencoderfn, redirecttargets,
-                        redirecthashes, proto._req)
+
+def makeresponsecacher(
+    orig,
+    repo,
+    proto,
+    command,
+    args,
+    objencoderfn,
+    redirecttargets,
+    redirecthashes,
+):
+    return memorycacher(
+        repo.ui,
+        command,
+        objencoderfn,
+        redirecttargets,
+        redirecthashes,
+        proto._req,
+    )
+
 
 def loadredirecttargets(ui):
     path = ui.config(b'simplecache', b'redirectsfile')
@@ -181,15 +200,21 @@
 
     return stringutil.evalpythonliteral(s)
 
+
 def getadvertisedredirecttargets(orig, repo, proto):
     return loadredirecttargets(repo.ui)
 
+
 def extsetup(ui):
     global CACHE
 
     CACHE = util.lrucachedict(10000)
 
-    extensions.wrapfunction(wireprotov2server, b'makeresponsecacher',
-                            makeresponsecacher)
-    extensions.wrapfunction(wireprotov2server, b'getadvertisedredirecttargets',
-                            getadvertisedredirecttargets)
+    extensions.wrapfunction(
+        wireprotov2server, b'makeresponsecacher', makeresponsecacher
+    )
+    extensions.wrapfunction(
+        wireprotov2server,
+        b'getadvertisedredirecttargets',
+        getadvertisedredirecttargets,
+    )