Patchwork [V2,STABLE] subrepo: avoid false unsafe path detection on Windows

login
register
mail settings
Submitter Matt Harbison
Date Feb. 7, 2019, 5:03 a.m.
Message ID <75d70ffee2f9fb710f58.1549515833@Envy>
Download mbox | patch
Permalink /patch/38517/
State Accepted
Headers show

Comments

Matt Harbison - Feb. 7, 2019, 5:03 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1549417854 18000
#      Tue Feb 05 20:50:54 2019 -0500
# Branch stable
# Node ID 75d70ffee2f9fb710f58d5552b319514ece459f9
# Parent  8b2892d5a9f2c06c998c977015a9ad3e3a3c9b5f
subrepo: avoid false unsafe path detection on Windows

Subrepo paths are not normalized for the OS, so what was happening in the
subsequent root path check was:

    root                  -> $TESTTMP\issue1852a\sub/repo
    util.expandpath(...)  -> $TESTTMP\issue1852a\sub/repo
    os.path.realpath(...) -> $TESTTMP\issue1852a\sub\repo
Yuya Nishihara - Feb. 7, 2019, 11:17 a.m.
On Thu, 07 Feb 2019 00:03:53 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1549417854 18000
> #      Tue Feb 05 20:50:54 2019 -0500
> # Branch stable
> # Node ID 75d70ffee2f9fb710f58d5552b319514ece459f9
> # Parent  8b2892d5a9f2c06c998c977015a9ad3e3a3c9b5f
> subrepo: avoid false unsafe path detection on Windows

Queued for stable, thanks.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -405,7 +405,7 @@  class hgsubrepo(abstractsubrepo):
         super(hgsubrepo, self).__init__(ctx, path)
         self._state = state
         r = ctx.repo()
-        root = r.wjoin(path)
+        root = r.wjoin(util.localpath(path))
         create = allowcreate and not r.wvfs.exists('%s/.hg' % path)
         # repository constructor does expand variables in path, which is
         # unsafe since subrepo path might come from untrusted source.