diff contrib/hg-ssh @ 43659:99e231afc29c

black: blacken scripts test-check-format.t doesn't appear to detect Python scripts with shebangs. But my editor which is configured to auto run black on Python files does and it appears some files are not blackened. This commit blackens scripts that need it. # skip-blame reformatting Differential Revision: https://phab.mercurial-scm.org/D7420
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 14 Nov 2019 20:35:11 -0800
parents 666d90ace0bb
children c102b704edb5
line wrap: on
line diff
--- a/contrib/hg-ssh	Tue Nov 12 10:17:59 2019 -0500
+++ b/contrib/hg-ssh	Thu Nov 14 20:35:11 2019 -0800
@@ -35,7 +35,9 @@
 import sys
 
 # enable importing on demand to reduce startup time
-import hgdemandimport ; hgdemandimport.enable()
+import hgdemandimport
+
+hgdemandimport.enable()
 
 from mercurial import (
     dispatch,
@@ -43,6 +45,7 @@
     ui as uimod,
 )
 
+
 def main():
     # Prevent insertion/deletion of CRs
     dispatch.initstdio()
@@ -56,9 +59,10 @@
             args.pop(0)
         else:
             break
-    allowed_paths = [os.path.normpath(os.path.join(cwd,
-                                                   os.path.expanduser(path)))
-                     for path in args]
+    allowed_paths = [
+        os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))
+        for path in args
+    ]
     orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?')
     try:
         cmdargv = shlex.split(orig_cmd)
@@ -75,10 +79,18 @@
             if readonly:
                 if not req.ui:
                     req.ui = uimod.ui.load()
-                req.ui.setconfig(b'hooks', b'pretxnopen.hg-ssh',
-                                 b'python:__main__.rejectpush', b'hg-ssh')
-                req.ui.setconfig(b'hooks', b'prepushkey.hg-ssh',
-                                 b'python:__main__.rejectpush', b'hg-ssh')
+                req.ui.setconfig(
+                    b'hooks',
+                    b'pretxnopen.hg-ssh',
+                    b'python:__main__.rejectpush',
+                    b'hg-ssh',
+                )
+                req.ui.setconfig(
+                    b'hooks',
+                    b'prepushkey.hg-ssh',
+                    b'python:__main__.rejectpush',
+                    b'hg-ssh',
+                )
             dispatch.dispatch(req)
         else:
             sys.stderr.write('Illegal repository "%s"\n' % repo)
@@ -87,11 +99,13 @@
         sys.stderr.write('Illegal command "%s"\n' % orig_cmd)
         sys.exit(255)
 
+
 def rejectpush(ui, **kwargs):
     ui.warn((b"Permission denied\n"))
     # mercurial hooks use unix process conventions for hook return values
     # so a truthy return means failure
     return True
 
+
 if __name__ == '__main__':
     main()