mercurial/dirstate.py
changeset 7068 57377fa7eda2
parent 7034 0d513661d6c2
child 7069 852f39691a0a
equal deleted inserted replaced
7067:40d105a12cac 7068:57377fa7eda2
    96             return self._checkcase
    96             return self._checkcase
    97         elif name == 'normalize':
    97         elif name == 'normalize':
    98             if self._checkcase:
    98             if self._checkcase:
    99                 self.normalize = self._normalize
    99                 self.normalize = self._normalize
   100             else:
   100             else:
   101                 self.normalize = lambda x: x
   101                 self.normalize = lambda x, y=False: x
   102             return self.normalize
   102             return self.normalize
   103         else:
   103         else:
   104             raise AttributeError(name)
   104             raise AttributeError(name)
   105 
   105 
   106     def _join(self, f):
   106     def _join(self, f):
   348             self._droppath(f)
   348             self._droppath(f)
   349             del self._map[f]
   349             del self._map[f]
   350         except KeyError:
   350         except KeyError:
   351             self._ui.warn(_("not in dirstate: %s\n") % f)
   351             self._ui.warn(_("not in dirstate: %s\n") % f)
   352 
   352 
   353     def _normalize(self, path):
   353     def _normalize(self, path, knownpath=False):
   354         norm_path = os.path.normcase(os.path.normpath(path))
   354         norm_path = os.path.normcase(os.path.normpath(path))
   355         if norm_path not in self._foldmap:
   355         fold_path = self._foldmap.get(norm_path, None)
   356             if not os.path.exists(os.path.join(self._root, path)):
   356         if fold_path is None:
   357                 return path
   357             if knownpath or not os.path.exists(os.path.join(self._root, path)):
   358             self._foldmap[norm_path] = util.fspath(path, self._root)
   358                 fold_path = path
   359         return self._foldmap[norm_path]
   359             else:
       
   360                 fold_path = self._foldmap.setdefault(norm_path,
       
   361                                 util.fspath(path, self._root))
       
   362         return fold_path
   360 
   363 
   361     def clear(self):
   364     def clear(self):
   362         self._map = {}
   365         self._map = {}
   363         if "_dirs" in self.__dict__:
   366         if "_dirs" in self.__dict__:
   364             delattr(self, "_dirs");
   367             delattr(self, "_dirs");
   513                 nd = ''
   516                 nd = ''
   514                 entries = listdir(join(nd), stat=True)
   517                 entries = listdir(join(nd), stat=True)
   515             else:
   518             else:
   516                 entries = listdir(join(nd), stat=True, skip ='.hg')
   519                 entries = listdir(join(nd), stat=True, skip ='.hg')
   517             for f, kind, st in entries:
   520             for f, kind, st in entries:
   518                 nf = normalize(nd and (nd + "/" + f) or f)
   521                 nf = normalize(nd and (nd + "/" + f) or f, True)
   519                 if nf not in results:
   522                 if nf not in results:
   520                     if kind == dirkind:
   523                     if kind == dirkind:
   521                         if not ignore(nf):
   524                         if not ignore(nf):
   522                             wadd(nf)
   525                             wadd(nf)
   523                         if nf in dmap and matchfn(nf):
   526                         if nf in dmap and matchfn(nf):