Patchwork [STABLE] dirstate: make sure rootdir ends with directory separator (issue4557)

login
register
mail settings
Submitter Yuya Nishihara
Date March 5, 2015, 4 p.m.
Message ID <ad75672575f0cfdba498.1425571218@mimosa>
Download mbox | patch
Permalink /patch/7905/
State Accepted
Commit 3cc630be5f09ab586e1ca3f015456fe5611e6333
Headers show

Comments

Yuya Nishihara - March 5, 2015, 4 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1425568462 -32400
#      Fri Mar 06 00:14:22 2015 +0900
# Branch stable
# Node ID ad75672575f0cfdba49815a3222f052a3f9de53d
# Parent  ac41aa4a66ab21210fc538e9fb51c405a341b69e
dirstate: make sure rootdir ends with directory separator (issue4557)

ntpath.join() of Python 2.7.9 does not work as expected if root is a UNC path
to top of share.

This patch doesn't take care of os.altsep, '/' on Windows, because root should
be normalized by realpath().
Matt Mackall - March 5, 2015, 7:44 p.m.
On Fri, 2015-03-06 at 01:00 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1425568462 -32400
> #      Fri Mar 06 00:14:22 2015 +0900
> # Branch stable
> # Node ID ad75672575f0cfdba49815a3222f052a3f9de53d
> # Parent  ac41aa4a66ab21210fc538e9fb51c405a341b69e
> dirstate: make sure rootdir ends with directory separator (issue4557)

Thanks, queued for stable.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -38,7 +38,12 @@  class dirstate(object):
         self._opener = opener
         self._validate = validate
         self._root = root
-        self._rootdir = os.path.join(root, '')
+        # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is
+        # UNC path pointing to root share (issue4557)
+        if root.endswith(os.sep):
+            self._rootdir = root
+        else:
+            self._rootdir = root + os.sep
         self._dirty = False
         self._dirtypl = False
         self._lastnormaltime = 0