changeset 24833:cb981009d697 stable

dirstate: use pathutil.normasprefix to ensure os.sep at the end of root 3cc630be5f09 replaced "os.path.join(root, '')" by "root.endswith(os.sep)" examination, because Python 2.7.9 changes behavior of "os.path.join(path, '')" on UNC path. But some problematic encodings use 0x5c (= "os.sep" on Windows) as the tail byte of some multi-byte characters, and replacement above prevents Mercurial from working on the repository, of which root path ends with such multi-byte character, regardless of enabling win32mbcs. This patch uses "pathutil.normasprefix()" instead of "root.endswith(os.sep)" examination, to ensure "os.sep" at the end of "dirstate._rootdir" even with problematic encodings. "root" of dirstate can be passed to "pathutil.normasprefix()" without normalization, because it is always given from "repo.root" = "repo.wvfs.base", which is normalized by "os.path.realpath()". Using "util.endswithsep()" instead of "str.endswith(os.sep)" also fixes this problem, but this patch chooses "pathutil.normasprefix()" to centralize "adding os.sep if endswith(os.sep)" logic into it.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 22 Apr 2015 23:38:52 +0900
parents 5947a68fa271
children 6e31e1274080
files mercurial/dirstate.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Tue Apr 21 21:02:08 2015 -0300
+++ b/mercurial/dirstate.py	Wed Apr 22 23:38:52 2015 +0900
@@ -40,10 +40,7 @@
         self._root = 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._rootdir = pathutil.normasprefix(root)
         self._dirty = False
         self._dirtypl = False
         self._lastnormaltime = 0