Patchwork D10330: share: store relative share paths with '/' separators

login
register
mail settings
Submitter phabricator
Date April 8, 2021, 11:53 p.m.
Message ID <differential-rev-PHID-DREV-ojarx2kynwnpks67rwjv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48647/
State Superseded
Headers show

Comments

phabricator - April 8, 2021, 11:53 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10330

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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.