subrepo: make -S work again on Windows for incoming/outgoing to remote repos
While it worked fine for the top level repo, the remote path for the subrepo got
mangled to something like "https://server/prefix\repo\subrepo", which I've seen
result in both a 400 and a 404, depending on the server. We need to `normpath`
at least the `subpath` because of "http://user:***@localhost:$HGPORT/main/../sub"
in `test-subrepo-relative-path.t`. Keep the `os.path` flavor for handling
filesystem based remote repos, since this string is also displayed.
This is one case where the automatic substitution of '\' for '/' and rematching
done by the test runner is unfortunate- I don't see how to write a test to catch
this.
Differential Revision: https://phab.mercurial-scm.org/D11971
--- a/mercurial/hg.py Wed Jan 05 17:53:57 2022 +0100
+++ b/mercurial/hg.py Mon Jan 10 18:04:41 2022 -0500
@@ -10,6 +10,7 @@
import errno
import os
+import posixpath
import shutil
import stat
import weakref
@@ -1292,7 +1293,11 @@
source = bytes(subpath)
else:
p = urlutil.url(source)
- p.path = os.path.normpath(b'%s/%s' % (p.path, subpath))
+ if p.islocal():
+ normpath = os.path.normpath
+ else:
+ normpath = posixpath.normpath
+ p.path = normpath(b'%s/%s' % (p.path, subpath))
source = bytes(p)
other = peer(repo, opts, source)
cleanupfn = other.close
@@ -1363,7 +1368,11 @@
dest = bytes(subpath)
else:
p = urlutil.url(dest)
- p.path = os.path.normpath(b'%s/%s' % (p.path, subpath))
+ if p.islocal():
+ normpath = os.path.normpath
+ else:
+ normpath = posixpath.normpath
+ p.path = normpath(b'%s/%s' % (p.path, subpath))
dest = bytes(p)
branches = path.branch, opts.get(b'branch') or []