mercurial/pathutil.py
changeset 30614 cfe66dcf45c0
parent 30332 318a24b52eeb
child 33435 456626e9c3d1
child 33633 20bac46f7744
equal deleted inserted replaced
30613:1112ff99d965 30614:cfe66dcf45c0
     7 
     7 
     8 from .i18n import _
     8 from .i18n import _
     9 from . import (
     9 from . import (
    10     encoding,
    10     encoding,
    11     error,
    11     error,
       
    12     pycompat,
    12     util,
    13     util,
    13 )
    14 )
    14 
    15 
    15 def _lowerclean(s):
    16 def _lowerclean(s):
    16     return encoding.hfsignoreclean(s.lower())
    17     return encoding.hfsignoreclean(s.lower())
    85         prefixes = []
    86         prefixes = []
    86         # It's important that we check the path parts starting from the root.
    87         # It's important that we check the path parts starting from the root.
    87         # This means we won't accidentally traverse a symlink into some other
    88         # This means we won't accidentally traverse a symlink into some other
    88         # filesystem (which is potentially expensive to access).
    89         # filesystem (which is potentially expensive to access).
    89         for i in range(len(parts)):
    90         for i in range(len(parts)):
    90             prefix = os.sep.join(parts[:i + 1])
    91             prefix = pycompat.ossep.join(parts[:i + 1])
    91             normprefix = os.sep.join(normparts[:i + 1])
    92             normprefix = pycompat.ossep.join(normparts[:i + 1])
    92             if normprefix in self.auditeddir:
    93             if normprefix in self.auditeddir:
    93                 continue
    94                 continue
    94             if self._realfs:
    95             if self._realfs:
    95                 self._checkfs(prefix, path)
    96                 self._checkfs(prefix, path)
    96             prefixes.append(normprefix)
    97             prefixes.append(normprefix)
   130 def canonpath(root, cwd, myname, auditor=None):
   131 def canonpath(root, cwd, myname, auditor=None):
   131     '''return the canonical path of myname, given cwd and root'''
   132     '''return the canonical path of myname, given cwd and root'''
   132     if util.endswithsep(root):
   133     if util.endswithsep(root):
   133         rootsep = root
   134         rootsep = root
   134     else:
   135     else:
   135         rootsep = root + os.sep
   136         rootsep = root + pycompat.ossep
   136     name = myname
   137     name = myname
   137     if not os.path.isabs(name):
   138     if not os.path.isabs(name):
   138         name = os.path.join(root, cwd, name)
   139         name = os.path.join(root, cwd, name)
   139     name = os.path.normpath(name)
   140     name = os.path.normpath(name)
   140     if auditor is None:
   141     if auditor is None:
   200     '/foo/bar/'
   201     '/foo/bar/'
   201     >>> normasprefix('/').replace(os.sep, '/')
   202     >>> normasprefix('/').replace(os.sep, '/')
   202     '/'
   203     '/'
   203     '''
   204     '''
   204     d, p = os.path.splitdrive(path)
   205     d, p = os.path.splitdrive(path)
   205     if len(p) != len(os.sep):
   206     if len(p) != len(pycompat.ossep):
   206         return path + os.sep
   207         return path + pycompat.ossep
   207     else:
   208     else:
   208         return path
   209         return path
   209 
   210 
   210 # forward two methods from posixpath that do what we need, but we'd
   211 # forward two methods from posixpath that do what we need, but we'd
   211 # rather not let our internals know that we're thinking in posix terms
   212 # rather not let our internals know that we're thinking in posix terms