Clone fails on Windows under Python3
Python 3.7.7 Mercurial 5.4 hg-git 0.9.0a1
Attempting to clone a git repository over SSH fails with the following stack trace:
Traceback (most recent call last):
File "C:\Users\Barret\AppData\Roaming\Python\Python37\Scripts\hg", line 43, in <module>
dispatch.run()
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 112, in run
status = dispatch(req)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 298, in dispatch
ret = _runcatch(req) or 0
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 472, in _runcatch
return _callcatch(ui, _runcatchfunc)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 481, in _callcatch
return scmutil.callcatch(ui, func)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\scmutil.py", line 152, in callcatch
return func()
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 462, in _runcatchfunc
return _dispatch(req)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 1226, in _dispatch
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 910, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 1237, in _runcommand
return cmdfunc()
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\dispatch.py", line 1223, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\util.py", line 1864, in check
return func(*args, **kwargs)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\commands.py", line 1916, in clone
depth=opts.get(b'depth') or None,
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\mercurial\hg.py", line 907, in clone
depth=depth,
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\lib\site-packages\hggit\util.py", line 64, in inner
return f(*args, **kwargs)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\lib\site-packages\hggit\__init__.py", line 366, in exchangepull
pullop.cgresult = repo.githandler.fetch(remote.path, heads)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\lib\site-packages\hggit\git_handler.py", line 283, in fetch
result = self.fetch_pack(remote, heads)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\lib\site-packages\hggit\git_handler.py", line 1224, in fetch_pack
f.write, progress.progress)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\dulwich\client.py", line 910, in fetch_pack
proto, can_read, stderr = self._connect(b'upload-pack', path)
File "C:\Users\Barret\AppData\Roaming\Python\Python37\site-packages\dulwich\client.py", line 1449, in _connect
**kwargs)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\lib\site-packages\hggit\_ssh.py", line 29, in run_command
stdout=subprocess.PIPE)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\Lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\Lib\subprocess.py", line 1148, in _execute_child
args = list2cmdline(args)
File "C:\Users\Barret\AppData\Local\Programs\Python\Python37\Lib\subprocess.py", line 555, in list2cmdline
needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: argument of type 'int' is not iterable
I did some investigation and this is caused by passing a bytestring to subprocess.Popen
, which isn't supported on Windows. It explicitly checks for isinstance(args, str)
and if that is false, it assumes args
is a sequence and passes it to list2cmdline
, which chokes.