[PATCH 3 of 5] Add util.splitpath() and use it instead of using split() directly
Shun-ichi Goto
shunichi.goto at gmail.com
Sun Jan 6 12:26:14 UTC 2008
# HG changeset patch
# User Shun-ichi GOTO <shunichi.goto at gmail.com>
# Date 1199621785 -32400
# Node ID e7739db328e05cf824c8d5f3bf6d694e15bb0d02
# Parent 43ff7c5ed8446a721a7bad5655ddd59f8fc62e7b
Add util.splitpath() and use it instead of using split() directly.
This is required for workaround of 0x5c issue.
diff -r 43ff7c5ed844 -r e7739db328e0 mercurial/util.py
--- a/mercurial/util.py Sun Jan 06 21:16:08 2008 +0900
+++ b/mercurial/util.py Sun Jan 06 21:16:25 2008 +0900
@@ -328,7 +328,7 @@ def pathto(root, n1, n2):
if os.path.splitdrive(root)[0] != os.path.splitdrive(n1)[0]:
return os.path.join(root, localpath(n2))
n2 = '/'.join((pconvert(root), n2))
- a, b = n1.split(os.sep), n2.split('/')
+ a, b = splitpath(n1), n2.split('/')
a.reverse()
b.reverse()
while a and b and a[-1] == b[-1]:
@@ -886,6 +886,10 @@ def endswithsep(path):
'''Check path ends with os.sep or os.altsep.'''
return path.endswith(os.sep) or os.altsep and path.endswith(os.altsep)
+def splitpath(path):
+ '''Split path by os.sep with supporting mbcs local encoding.'''
+ return path.split(os.sep)
+
# Platform specific variants
if os.name == 'nt':
import msvcrt
@@ -983,7 +987,7 @@ if os.name == 'nt':
msvcrt.setmode(fd.fileno(), os.O_BINARY)
def pconvert(path):
- return path.replace("\\", "/")
+ return '/'.join(splitpath(path))
def localpath(path):
return path.replace('/', '\\')
More information about the Mercurial-devel
mailing list