mercurial/windows.py
branchstable
changeset 15637 7f01ad702405
parent 15488 6eff984d8e76
child 15655 5402fd9dd13e
child 15671 3c5e818ac679
equal deleted inserted replaced
15635:82f5e471792d 15637:7f01ad702405
   138     Returns the true, canonical file system path equivalent to the given
   138     Returns the true, canonical file system path equivalent to the given
   139     path.
   139     path.
   140     '''
   140     '''
   141     # TODO: There may be a more clever way to do this that also handles other,
   141     # TODO: There may be a more clever way to do this that also handles other,
   142     # less common file systems.
   142     # less common file systems.
   143     return os.path.normpath(os.path.normcase(os.path.realpath(path)))
   143     return os.path.normpath(normcase(os.path.realpath(path)))
   144 
   144 
   145 def samestat(s1, s2):
   145 def samestat(s1, s2):
   146     return False
   146     return False
   147 
   147 
   148 # A sequence of backslashes is special iff it precedes a double quote:
   148 # A sequence of backslashes is special iff it precedes a double quote:
   214     return findexisting(os.path.expanduser(os.path.expandvars(command)))
   214     return findexisting(os.path.expanduser(os.path.expandvars(command)))
   215 
   215 
   216 def statfiles(files):
   216 def statfiles(files):
   217     '''Stat each file in files and yield stat or None if file does not exist.
   217     '''Stat each file in files and yield stat or None if file does not exist.
   218     Cluster and cache stat per directory to minimize number of OS stat calls.'''
   218     Cluster and cache stat per directory to minimize number of OS stat calls.'''
   219     ncase = os.path.normcase
       
   220     dircache = {} # dirname -> filename -> status | None if file does not exist
   219     dircache = {} # dirname -> filename -> status | None if file does not exist
   221     for nf in files:
   220     for nf in files:
   222         nf  = ncase(nf)
   221         nf  = normcase(nf)
   223         dir, base = os.path.split(nf)
   222         dir, base = os.path.split(nf)
   224         if not dir:
   223         if not dir:
   225             dir = '.'
   224             dir = '.'
   226         cache = dircache.get(dir, None)
   225         cache = dircache.get(dir, None)
   227         if cache is None:
   226         if cache is None:
   228             try:
   227             try:
   229                 dmap = dict([(ncase(n), s)
   228                 dmap = dict([(normcase(n), s)
   230                     for n, k, s in osutil.listdir(dir, True)])
   229                     for n, k, s in osutil.listdir(dir, True)])
   231             except OSError, err:
   230             except OSError, err:
   232                 # handle directory not found in Python version prior to 2.5
   231                 # handle directory not found in Python version prior to 2.5
   233                 # Python <= 2.4 returns native Windows code 3 in errno
   232                 # Python <= 2.4 returns native Windows code 3 in errno
   234                 # Python >= 2.5 returns ENOENT and adds winerror field
   233                 # Python >= 2.5 returns ENOENT and adds winerror field