# HG changeset patch # User Matt Harbison # Date 2022-01-10 23:04:41 # Node ID f98d4d0a299a6a3bbaf71d12183d408dcdc2f2ac # Parent ca0c6d8c456b3e6b03ba48bd518f82e17e5be4af 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 diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -10,6 +10,7 @@ from __future__ import absolute_import import errno import os +import posixpath import shutil import stat import weakref @@ -1292,7 +1293,11 @@ def _incoming( 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 @@ def _outgoing(ui, repo, dests, opts, sub 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 []