mercurial/dirstate.py
changeset 6677 9865e15febd0
parent 6675 03a836ca6fde
child 6685 76021ec849c8
equal deleted inserted replaced
6676:33045179d079 6677:9865e15febd0
    29             self._read()
    29             self._read()
    30             return self._map
    30             return self._map
    31         elif name == '_copymap':
    31         elif name == '_copymap':
    32             self._read()
    32             self._read()
    33             return self._copymap
    33             return self._copymap
       
    34         elif name == '_foldmap':
       
    35             _foldmap = {}
       
    36             for name in self._map:
       
    37                 norm = os.path.normcase(os.path.normpath(name))
       
    38                 _foldmap[norm] = name
       
    39             self._foldmap = _foldmap
       
    40             return self._foldmap
    34         elif name == '_branch':
    41         elif name == '_branch':
    35             try:
    42             try:
    36                 self._branch = (self._opener("branch").read().strip()
    43                 self._branch = (self._opener("branch").read().strip()
    37                                 or "default")
    44                                 or "default")
    38             except IOError:
    45             except IOError:
    67             self._checkexec = util.checkexec(self._root)
    74             self._checkexec = util.checkexec(self._root)
    68             return self._checkexec
    75             return self._checkexec
    69         elif name == '_folding':
    76         elif name == '_folding':
    70             self._folding = not util.checkfolding(self._join('.hg'))
    77             self._folding = not util.checkfolding(self._join('.hg'))
    71             return self._folding
    78             return self._folding
       
    79         elif name == 'normalize':
       
    80             if self._folding:
       
    81                 self.normalize = self._normalize
       
    82             else:
       
    83                 self.normalize = lambda x: x
       
    84             return self.normalize
    72         else:
    85         else:
    73             raise AttributeError, name
    86             raise AttributeError, name
    74 
    87 
    75     def _join(self, f):
    88     def _join(self, f):
    76         return os.path.join(self._root, f)
    89         return os.path.join(self._root, f)
   165                 f, c = f.split('\0')
   178                 f, c = f.split('\0')
   166                 copymap[f] = c
   179                 copymap[f] = c
   167             dmap[f] = e # we hold onto e[4] because making a subtuple is slow
   180             dmap[f] = e # we hold onto e[4] because making a subtuple is slow
   168 
   181 
   169     def invalidate(self):
   182     def invalidate(self):
   170         for a in "_map _copymap _branch _pl _dirs _ignore".split():
   183         for a in "_map _copymap _foldmap _branch _pl _dirs _ignore".split():
   171             if a in self.__dict__:
   184             if a in self.__dict__:
   172                 delattr(self, a)
   185                 delattr(self, a)
   173         self._dirty = False
   186         self._dirty = False
   174 
   187 
   175     def copy(self, source, dest):
   188     def copy(self, source, dest):
   317         try:
   330         try:
   318             self._changepath(f, '?')
   331             self._changepath(f, '?')
   319             del self._map[f]
   332             del self._map[f]
   320         except KeyError:
   333         except KeyError:
   321             self._ui.warn(_("not in dirstate: %s\n") % f)
   334             self._ui.warn(_("not in dirstate: %s\n") % f)
       
   335 
       
   336     def _normalize(self, path):
       
   337         normpath = os.path.normcase(os.path.normpath(path))
       
   338         if normpath in self._foldmap:
       
   339             return self._foldmap[normpath]
       
   340         elif os.path.exists(path):
       
   341             self._foldmap[normpath] = util.fspath(path, self._root)
       
   342             return self._foldmap[normpath]
       
   343         else:
       
   344             return path
   322 
   345 
   323     def clear(self):
   346     def clear(self):
   324         self._map = {}
   347         self._map = {}
   325         if "_dirs" in self.__dict__:
   348         if "_dirs" in self.__dict__:
   326             delattr(self, "_dirs");
   349             delattr(self, "_dirs");
   559                 if nf in known:
   582                 if nf in known:
   560                     continue
   583                     continue
   561                 known[nf] = 1
   584                 known[nf] = 1
   562                 if match(nf):
   585                 if match(nf):
   563                     if supported(ff, st.st_mode, verbose=True):
   586                     if supported(ff, st.st_mode, verbose=True):
   564                         yield 'f', nf, st
   587                         yield 'f', self.normalize(nf), st
   565                     elif ff in dc:
   588                     elif ff in dc:
   566                         yield 'm', nf, st
   589                         yield 'm', nf, st
   567 
   590 
   568         # step two run through anything left in the dc hash and yield
   591         # step two run through anything left in the dc hash and yield
   569         # if we haven't already seen it
   592         # if we haven't already seen it