diff mercurial/util.py @ 5843:83c354c4d529

Add endswithsep() and use it instead of using os.sep and os.altsep directly. This change is intended to allow hooking endswithsep() by win32mbcs extension for MBCS support.
author Shun-ichi GOTO <shunichi.goto@gmail.com>
date Wed, 09 Jan 2008 21:30:35 +0900
parents d852151fb8d4
children 07d8eb78dd68
line wrap: on
line diff
--- a/mercurial/util.py	Wed Jan 09 21:30:13 2008 +0900
+++ b/mercurial/util.py	Wed Jan 09 21:30:35 2008 +0900
@@ -341,7 +341,7 @@
     """return the canonical path of myname, given cwd and root"""
     if root == os.sep:
         rootsep = os.sep
-    elif root.endswith(os.sep):
+    elif endswithsep(root):
         rootsep = root
     else:
         rootsep = root + os.sep
@@ -882,6 +882,10 @@
     """return True if patches should be applied in binary mode by default."""
     return os.name == 'nt'
 
+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)
+
 # Platform specific variants
 if os.name == 'nt':
     import msvcrt