mercurial/dirstate.py
changeset 34678 e8a89ed7ce96
parent 34677 014bd2a555c8
child 34933 0217f75b6e59
equal deleted inserted replaced
34677:014bd2a555c8 34678:e8a89ed7ce96
   129     def _map(self):
   129     def _map(self):
   130         '''Return the dirstate contents as a map from filename to
   130         '''Return the dirstate contents as a map from filename to
   131         (state, mode, size, time).'''
   131         (state, mode, size, time).'''
   132         self._read()
   132         self._read()
   133         return self._map
   133         return self._map
   134 
       
   135     @propertycache
       
   136     def _dirfoldmap(self):
       
   137         f = {}
       
   138         normcase = util.normcase
       
   139         for name in self._map.dirs:
       
   140             f[normcase(name)] = name
       
   141         return f
       
   142 
   134 
   143     @property
   135     @property
   144     def _sparsematcher(self):
   136     def _sparsematcher(self):
   145         """The matcher for the sparse checkout.
   137         """The matcher for the sparse checkout.
   146 
   138 
   370 
   362 
   371         This is different from localrepo.invalidatedirstate() because it always
   363         This is different from localrepo.invalidatedirstate() because it always
   372         rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
   364         rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
   373         check whether the dirstate has changed before rereading it.'''
   365         check whether the dirstate has changed before rereading it.'''
   374 
   366 
   375         for a in ("_map", "_dirfoldmap", "_branch",
   367         for a in ("_map", "_branch", "_ignore"):
   376                   "_ignore"):
       
   377             if a in self.__dict__:
   368             if a in self.__dict__:
   378                 delattr(self, a)
   369                 delattr(self, a)
   379         self._lastnormaltime = 0
   370         self._lastnormaltime = 0
   380         self._dirty = False
   371         self._dirty = False
   381         self._updatedfiles.clear()
   372         self._updatedfiles.clear()
   566 
   557 
   567     def _normalize(self, path, isknown, ignoremissing=False, exists=None):
   558     def _normalize(self, path, isknown, ignoremissing=False, exists=None):
   568         normed = util.normcase(path)
   559         normed = util.normcase(path)
   569         folded = self._map.filefoldmap.get(normed, None)
   560         folded = self._map.filefoldmap.get(normed, None)
   570         if folded is None:
   561         if folded is None:
   571             folded = self._dirfoldmap.get(normed, None)
   562             folded = self._map.dirfoldmap.get(normed, None)
   572         if folded is None:
   563         if folded is None:
   573             if isknown:
   564             if isknown:
   574                 folded = path
   565                 folded = path
   575             else:
   566             else:
   576                 # store discovered result in dirfoldmap so that future
   567                 # store discovered result in dirfoldmap so that future
   577                 # normalizefile calls don't start matching directories
   568                 # normalizefile calls don't start matching directories
   578                 folded = self._discoverpath(path, normed, ignoremissing, exists,
   569                 folded = self._discoverpath(path, normed, ignoremissing, exists,
   579                                             self._dirfoldmap)
   570                                             self._map.dirfoldmap)
   580         return folded
   571         return folded
   581 
   572 
   582     def normalize(self, path, isknown=False, ignoremissing=False):
   573     def normalize(self, path, isknown=False, ignoremissing=False):
   583         '''
   574         '''
   584         normalize the case of a pathname when on a casefolding filesystem
   575         normalize the case of a pathname when on a casefolding filesystem
   873 
   864 
   874             for norm, paths in normed.iteritems():
   865             for norm, paths in normed.iteritems():
   875                 if len(paths) > 1:
   866                 if len(paths) > 1:
   876                     for path in paths:
   867                     for path in paths:
   877                         folded = self._discoverpath(path, norm, True, None,
   868                         folded = self._discoverpath(path, norm, True, None,
   878                                                     self._dirfoldmap)
   869                                                     self._map.dirfoldmap)
   879                         if path != folded:
   870                         if path != folded:
   880                             results[path] = None
   871                             results[path] = None
   881 
   872 
   882         return results, dirsfound, dirsnotfound
   873         return results, dirsfound, dirsnotfound
   883 
   874 
  1394     @propertycache
  1385     @propertycache
  1395     def identity(self):
  1386     def identity(self):
  1396         self.read()
  1387         self.read()
  1397         return self.identity
  1388         return self.identity
  1398 
  1389 
       
  1390     @propertycache
       
  1391     def dirfoldmap(self):
       
  1392         f = {}
       
  1393         normcase = util.normcase
       
  1394         for name in self.dirs:
       
  1395             f[normcase(name)] = name
       
  1396         return f