py3: use pycompat.fsencode to convert path to bytes
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 20 May 2018 17:35:57 +0530
changeset 46283 666d90ace0bb4a8f9a03ff1476d7b3a7b6fe4d20
parent 46282 e69628f361966858e13b199aa217a8bfe867cb22
child 46284 b0144fc8b681351f65f48af4b3903be33004e9fa
push id811
push usergszorc@mozilla.com
push dateWed, 23 May 2018 02:22:04 +0000
py3: use pycompat.fsencode to convert path to bytes Differential Revision: https://phab.mercurial-scm.org/D3631
contrib/hg-ssh
--- a/contrib/hg-ssh
+++ b/contrib/hg-ssh
@@ -34,16 +34,17 @@ import os
 import shlex
 import sys
 
 # enable importing on demand to reduce startup time
 import hgdemandimport ; hgdemandimport.enable()
 
 from mercurial import (
     dispatch,
+    pycompat,
     ui as uimod,
 )
 
 def main():
     # Prevent insertion/deletion of CRs
     dispatch.initstdio()
 
     cwd = os.getcwd()
@@ -64,17 +65,17 @@ def main():
     except ValueError as e:
         sys.stderr.write('Illegal command "%s": %s\n' % (orig_cmd, e))
         sys.exit(255)
 
     if cmdargv[:2] == ['hg', '-R'] and cmdargv[3:] == ['serve', '--stdio']:
         path = cmdargv[2]
         repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))
         if repo in allowed_paths:
-            cmd = [b'-R', repo, b'serve', b'--stdio']
+            cmd = [b'-R', pycompat.fsencode(repo), b'serve', b'--stdio']
             req = dispatch.request(cmd)
             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')