comparison mercurial/dirstate.py @ 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 21e1ece30f8c
children 6eb4bdad198f
comparison
equal deleted inserted replaced
24832:5947a68fa271 24833:cb981009d697
38 self._opener = opener 38 self._opener = opener
39 self._validate = validate 39 self._validate = validate
40 self._root = root 40 self._root = root
41 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is 41 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is
42 # UNC path pointing to root share (issue4557) 42 # UNC path pointing to root share (issue4557)
43 if root.endswith(os.sep): 43 self._rootdir = pathutil.normasprefix(root)
44 self._rootdir = root
45 else:
46 self._rootdir = root + os.sep
47 self._dirty = False 44 self._dirty = False
48 self._dirtypl = False 45 self._dirtypl = False
49 self._lastnormaltime = 0 46 self._lastnormaltime = 0
50 self._ui = ui 47 self._ui = ui
51 self._filecache = {} 48 self._filecache = {}