mercurial/windows.py
changeset 47622 bb917eea1605
parent 47424 f77404040776
child 47789 064cd182555f
equal deleted inserted replaced
47621:d6ee6456bd5f 47622:bb917eea1605
   329     return pconvert(os.path.normpath(path))
   329     return pconvert(os.path.normpath(path))
   330 
   330 
   331 
   331 
   332 def normcase(path):
   332 def normcase(path):
   333     return encoding.upper(path)  # NTFS compares via upper()
   333     return encoding.upper(path)  # NTFS compares via upper()
       
   334 
       
   335 
       
   336 DRIVE_RE_B = re.compile(b'^[a-z]:')
       
   337 DRIVE_RE_S = re.compile('^[a-z]:')
       
   338 
       
   339 
       
   340 def abspath(path):
       
   341     abs_path = os.path.abspath(path)  # re-exports
       
   342     # Python on Windows is inconsistent regarding the capitalization of drive
       
   343     # letter and this cause issue with various path comparison along the way.
       
   344     # So we normalize the drive later to upper case here.
       
   345     #
       
   346     # See https://bugs.python.org/issue40368 for and example of this hell.
       
   347     if isinstance(abs_path, bytes):
       
   348         if DRIVE_RE_B.match(abs_path):
       
   349             abs_path = abs_path[0:1].upper() + abs_path[1:]
       
   350     elif DRIVE_RE_S.match(abs_path):
       
   351         abs_path = abs_path[0:1].upper() + abs_path[1:]
       
   352     return abs_path
   334 
   353 
   335 
   354 
   336 # see posix.py for definitions
   355 # see posix.py for definitions
   337 normcasespec = encoding.normcasespecs.upper
   356 normcasespec = encoding.normcasespecs.upper
   338 normcasefallback = encoding.upperfallback
   357 normcasefallback = encoding.upperfallback