Mercurial > hg
comparison mercurial/localrepo.py @ 46888:218a26df7813
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
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 08 Apr 2021 18:43:08 -0400 |
parents | 3aa78f2aea48 |
children | 631001150e13 |
comparison
equal
deleted
inserted
replaced
46887:6d5a26e94d9e | 46888:218a26df7813 |
---|---|
467 # store lives in the path contained in the ``.hg/sharedpath`` file. | 467 # store lives in the path contained in the ``.hg/sharedpath`` file. |
468 # This is an absolute path for ``shared`` and relative to | 468 # This is an absolute path for ``shared`` and relative to |
469 # ``.hg/`` for ``relshared``. | 469 # ``.hg/`` for ``relshared``. |
470 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') | 470 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') |
471 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements: | 471 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements: |
472 sharedpath = hgvfs.join(sharedpath) | 472 sharedpath = util.normpath(hgvfs.join(sharedpath)) |
473 | 473 |
474 sharedvfs = vfsmod.vfs(sharedpath, realpath=True) | 474 sharedvfs = vfsmod.vfs(sharedpath, realpath=True) |
475 | 475 |
476 if not sharedvfs.exists(): | 476 if not sharedvfs.exists(): |
477 raise error.RepoError( | 477 raise error.RepoError( |
3670 sharedpath = createopts[b'sharedrepo'].sharedpath | 3670 sharedpath = createopts[b'sharedrepo'].sharedpath |
3671 | 3671 |
3672 if createopts.get(b'sharedrelative'): | 3672 if createopts.get(b'sharedrelative'): |
3673 try: | 3673 try: |
3674 sharedpath = os.path.relpath(sharedpath, hgvfs.base) | 3674 sharedpath = os.path.relpath(sharedpath, hgvfs.base) |
3675 sharedpath = util.pconvert(sharedpath) | |
3675 except (IOError, ValueError) as e: | 3676 except (IOError, ValueError) as e: |
3676 # ValueError is raised on Windows if the drive letters differ | 3677 # ValueError is raised on Windows if the drive letters differ |
3677 # on each path. | 3678 # on each path. |
3678 raise error.Abort( | 3679 raise error.Abort( |
3679 _(b'cannot calculate relative path'), | 3680 _(b'cannot calculate relative path'), |