# HG changeset patch # User FUJIWARA Katsunori # Date 1429713532 -32400 # Node ID cb981009d697fc84e32cb5ac29f06d7c77f6aaf5 # Parent 5947a68fa271250dde4dfcd57894bfea1c60d819 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. diff -r 5947a68fa271 -r cb981009d697 mercurial/dirstate.py --- 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