From patchwork Tue Jan 11 04:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11971: subrepo: make -S work again on Windows for incoming/outgoing to remote repos From: phabricator X-Patchwork-Id: 50297 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 11 Jan 2022 04:51:46 +0000 mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY 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. REPOSITORY rHG Mercurial BRANCH stable REVISION DETAIL https://phab.mercurial-scm.org/D11971 AFFECTED FILES mercurial/hg.py CHANGE DETAILS To: mharbison72, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -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 []