##// END OF EJS Templates
Add util.splitpath() and use it instead of using os.sep directly....
Shun-ichi GOTO -
r5844:07d8eb78 default
parent child Browse files
Show More
@@ -328,7 +328,7 b' def pathto(root, n1, n2):'
328 328 if os.path.splitdrive(root)[0] != os.path.splitdrive(n1)[0]:
329 329 return os.path.join(root, localpath(n2))
330 330 n2 = '/'.join((pconvert(root), n2))
331 a, b = n1.split(os.sep), n2.split('/')
331 a, b = splitpath(n1), n2.split('/')
332 332 a.reverse()
333 333 b.reverse()
334 334 while a and b and a[-1] == b[-1]:
@@ -692,7 +692,7 b' class path_auditor(object):'
692 692 if path in self.audited:
693 693 return
694 694 normpath = os.path.normcase(path)
695 parts = normpath.split(os.sep)
695 parts = splitpath(normpath)
696 696 if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '')
697 697 or os.pardir in parts):
698 698 raise Abort(_("path contains illegal component: %s") % path)
@@ -886,6 +886,14 b' def endswithsep(path):'
886 886 '''Check path ends with os.sep or os.altsep.'''
887 887 return path.endswith(os.sep) or os.altsep and path.endswith(os.altsep)
888 888
889 def splitpath(path):
890 '''Split path by os.sep.
891 Note that this function does not use os.altsep because this is
892 an alternative of simple "xxx.split(os.sep)".
893 It is recommended to use os.path.normpath() before using this
894 function if need.'''
895 return path.split(os.sep)
896
889 897 # Platform specific variants
890 898 if os.name == 'nt':
891 899 import msvcrt
@@ -983,7 +991,7 b" if os.name == 'nt':"
983 991 msvcrt.setmode(fd.fileno(), os.O_BINARY)
984 992
985 993 def pconvert(path):
986 return path.replace("\\", "/")
994 return '/'.join(splitpath(path))
987 995
988 996 def localpath(path):
989 997 return path.replace('/', '\\')
General Comments 0
You need to be logged in to leave comments. Login now