mercurial/dirstate.py
branchstable
changeset 13717 bc41d08a5ccc
parent 13400 14f3795a5ed7
child 13728 15d1db2abfcb
equal deleted inserted replaced
13695:a083c6e62acb 13717:bc41d08a5ccc
   360             self._droppath(f)
   360             self._droppath(f)
   361             del self._map[f]
   361             del self._map[f]
   362         except KeyError:
   362         except KeyError:
   363             self._ui.warn(_("not in dirstate: %s\n") % f)
   363             self._ui.warn(_("not in dirstate: %s\n") % f)
   364 
   364 
   365     def _normalize(self, path, knownpath):
   365     def _normalize(self, path, isknown):
   366         norm_path = os.path.normcase(path)
   366         normed = os.path.normcase(path)
   367         fold_path = self._foldmap.get(norm_path, None)
   367         folded = self._foldmap.get(normed, None)
   368         if fold_path is None:
   368         if folded is None:
   369             if knownpath or not os.path.lexists(os.path.join(self._root, path)):
   369             if isknown or not os.path.lexists(os.path.join(self._root, path)):
   370                 fold_path = path
   370                 folded = path
   371             else:
   371             else:
   372                 fold_path = self._foldmap.setdefault(norm_path,
   372                 folded = self._foldmap.setdefault(normed,
   373                                 util.fspath(path, self._root))
   373                                 util.fspath(path, self._root))
   374         return fold_path
   374         return folded
       
   375 
       
   376     def normalize(self, path, isknown=False):
       
   377         '''
       
   378         normalize the case of a pathname when on a casefolding filesystem
       
   379 
       
   380         isknown specifies whether the filename came from walking the
       
   381         disk, to avoid extra filesystem access
       
   382 
       
   383         The normalized case is determined based on the following precedence:
       
   384 
       
   385         - version of name already stored in the dirstate
       
   386         - version of name stored on disk
       
   387         - version provided via command arguments
       
   388         '''
       
   389 
       
   390         if self._checkcase:
       
   391             return self._normalize(path, isknown)
       
   392         return path
   375 
   393 
   376     def clear(self):
   394     def clear(self):
   377         self._map = {}
   395         self._map = {}
   378         if "_dirs" in self.__dict__:
   396         if "_dirs" in self.__dict__:
   379             delattr(self, "_dirs")
   397             delattr(self, "_dirs")