[Request] [+ ] D11971: subrepo: make -S work again on Windows for incoming/outgoing to remote repos
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Tue Jan 11 04:51:46 UTC 2022
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
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 []
To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220111/c0947484/attachment.html>
More information about the Mercurial-patches
mailing list