contrib/hgclient.py
changeset 43076 2372284d9457
parent 40984 6a372f943e49
child 43506 9f70512ae2cf
--- a/contrib/hgclient.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/contrib/hgclient.py	Sun Oct 06 09:45:02 2019 -0400
@@ -16,17 +16,22 @@
     stdout = sys.stdout.buffer
     stderr = sys.stderr.buffer
     stringio = io.BytesIO
+
     def bprint(*args):
         # remove b'' as well for ease of test migration
         pargs = [re.sub(br'''\bb(['"])''', br'\1', b'%s' % a) for a in args]
         stdout.write(b' '.join(pargs) + b'\n')
+
+
 else:
     import cStringIO
+
     stdout = sys.stdout
     stderr = sys.stderr
     stringio = cStringIO.StringIO
     bprint = print
 
+
 def connectpipe(path=None, extraargs=()):
     cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe']
     if path:
@@ -38,11 +43,13 @@
             return cmdline
         return [arg.decode("utf-8") for arg in cmdline]
 
-    server = subprocess.Popen(tonative(cmdline), stdin=subprocess.PIPE,
-                              stdout=subprocess.PIPE)
+    server = subprocess.Popen(
+        tonative(cmdline), stdin=subprocess.PIPE, stdout=subprocess.PIPE
+    )
 
     return server
 
+
 class unixconnection(object):
     def __init__(self, sockpath):
         self.sock = sock = socket.socket(socket.AF_UNIX)
@@ -55,6 +62,7 @@
         self.stdout.close()
         self.sock.close()
 
+
 class unixserver(object):
     def __init__(self, sockpath, logpath=None, repopath=None):
         self.sockpath = sockpath
@@ -80,11 +88,13 @@
         os.kill(self.server.pid, signal.SIGTERM)
         self.server.wait()
 
+
 def writeblock(server, data):
     server.stdin.write(struct.pack(b'>I', len(data)))
     server.stdin.write(data)
     server.stdin.flush()
 
+
 def readchannel(server):
     data = server.stdout.read(5)
     if not data:
@@ -95,11 +105,14 @@
     else:
         return channel, server.stdout.read(length)
 
+
 def sep(text):
     return text.replace(b'\\', b'/')
 
-def runcommand(server, args, output=stdout, error=stderr, input=None,
-               outfilter=lambda x: x):
+
+def runcommand(
+    server, args, output=stdout, error=stderr, input=None, outfilter=lambda x: x
+):
     bprint(b'*** runcommand', b' '.join(args))
     stdout.flush()
     server.stdin.write(b'runcommand\n')
@@ -123,7 +136,7 @@
         elif ch == b'm':
             bprint(b"message: %r" % data)
         elif ch == b'r':
-            ret, = struct.unpack('>i', data)
+            (ret,) = struct.unpack('>i', data)
             if ret != 0:
                 bprint(b' [%d]' % ret)
             return ret
@@ -132,6 +145,7 @@
             if ch.isupper():
                 return
 
+
 def check(func, connect=connectpipe):
     stdout.flush()
     server = connect()
@@ -141,7 +155,9 @@
         server.stdin.close()
         server.wait()
 
+
 def checkwith(connect=connectpipe, **kwargs):
     def wrap(func):
         return check(func, lambda: connect(**kwargs))
+
     return wrap