comparison 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
comparison
equal deleted inserted replaced
5842:111ed8c871bf 5843:83c354c4d529
339 339
340 def canonpath(root, cwd, myname): 340 def canonpath(root, cwd, myname):
341 """return the canonical path of myname, given cwd and root""" 341 """return the canonical path of myname, given cwd and root"""
342 if root == os.sep: 342 if root == os.sep:
343 rootsep = os.sep 343 rootsep = os.sep
344 elif root.endswith(os.sep): 344 elif endswithsep(root):
345 rootsep = root 345 rootsep = root
346 else: 346 else:
347 rootsep = root + os.sep 347 rootsep = root + os.sep
348 name = myname 348 name = myname
349 if not os.path.isabs(name): 349 if not os.path.isabs(name):
880 880
881 def needbinarypatch(): 881 def needbinarypatch():
882 """return True if patches should be applied in binary mode by default.""" 882 """return True if patches should be applied in binary mode by default."""
883 return os.name == 'nt' 883 return os.name == 'nt'
884 884
885 def endswithsep(path):
886 '''Check path ends with os.sep or os.altsep.'''
887 return path.endswith(os.sep) or os.altsep and path.endswith(os.altsep)
888
885 # Platform specific variants 889 # Platform specific variants
886 if os.name == 'nt': 890 if os.name == 'nt':
887 import msvcrt 891 import msvcrt
888 nulldev = 'NUL:' 892 nulldev = 'NUL:'
889 893