share: store relative share paths with '/' separators
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 08 Apr 2021 18:43:08 -0400
changeset 46888 218a26df7813
parent 46887 6d5a26e94d9e
child 46889 8759e22f1649
share: store relative share paths with '/' separators I created a relative share in Windows and tried to use it in WSL, and it failed: abort: .hg/sharedpath points to nonexistent directory /mnt/c/Users/Matt/hg-review/.hg/..\..\hg\.hg Use `normpath` on the read side so that the code has the usual Windows style paths it always had (I don't think that matters much), but it also eliminates the directory escaping path components in the case where the path is printed. This will not fix repositories that have already been created, but it's trivial enough to hand edit the file to correct it. Differential Revision: https://phab.mercurial-scm.org/D10330
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Apr 09 12:02:51 2021 +0200
+++ b/mercurial/localrepo.py	Thu Apr 08 18:43:08 2021 -0400
@@ -469,7 +469,7 @@
     # ``.hg/`` for ``relshared``.
     sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
     if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
-        sharedpath = hgvfs.join(sharedpath)
+        sharedpath = util.normpath(hgvfs.join(sharedpath))
 
     sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
 
@@ -3672,6 +3672,7 @@
         if createopts.get(b'sharedrelative'):
             try:
                 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
+                sharedpath = util.pconvert(sharedpath)
             except (IOError, ValueError) as e:
                 # ValueError is raised on Windows if the drive letters differ
                 # on each path.