mercurial/dirstate.py
changeset 21115 1b6e37f44250
parent 21026 7ee03e190c1d
child 21116 30c60e28aa9b
equal deleted inserted replaced
21114:a63958bcf63a 21115:1b6e37f44250
   593             try:
   593             try:
   594                 st = lstat(join(nf))
   594                 st = lstat(join(nf))
   595                 kind = getkind(st.st_mode)
   595                 kind = getkind(st.st_mode)
   596                 if kind == dirkind:
   596                 if kind == dirkind:
   597                     if nf in dmap:
   597                     if nf in dmap:
   598                         #file deleted on disk but still in dirstate
   598                         # file replaced by dir on disk but still in dirstate
   599                         results[nf] = None
   599                         results[nf] = None
   600                     if matchedir:
   600                     if matchedir:
   601                         matchedir(nf)
   601                         matchedir(nf)
   602                     foundadd(nf)
   602                     foundadd(nf)
   603                 elif kind == regkind or kind == lnkkind:
   603                 elif kind == regkind or kind == lnkkind:
   604                     results[nf] = st
   604                     results[nf] = st
   605                 else:
   605                 else:
   606                     badfn(ff, badtype(kind))
   606                     badfn(ff, badtype(kind))
   607                     if nf in dmap:
   607                     if nf in dmap:
   608                         results[nf] = None
   608                         results[nf] = None
   609             except OSError, inst:
   609             except OSError, inst: # nf not found on disk - it is dirstate only
   610                 if nf in dmap: # does it exactly match a file?
   610                 if nf in dmap: # does it exactly match a missing file?
   611                     results[nf] = None
   611                     results[nf] = None
   612                 else: # does it match a directory?
   612                 else: # does it match a missing directory?
   613                     prefix = nf + "/"
   613                     prefix = nf + "/"
   614                     for fn in dmap:
   614                     for fn in dmap:
   615                         if fn.startswith(prefix):
   615                         if fn.startswith(prefix):
   616                             if matchedir:
   616                             if matchedir:
   617                                 matchedir(nf)
   617                                 matchedir(nf)
   639 
   639 
   640         def fwarn(f, msg):
   640         def fwarn(f, msg):
   641             self._ui.warn('%s: %s\n' % (self.pathto(f), msg))
   641             self._ui.warn('%s: %s\n' % (self.pathto(f), msg))
   642             return False
   642             return False
   643 
   643 
   644         ignore = self._ignore
       
   645         dirignore = self._dirignore
       
   646         if ignored:
   644         if ignored:
   647             ignore = util.never
   645             ignore = util.never
   648             dirignore = util.never
   646             dirignore = util.never
   649         elif not unknown:
   647         elif unknown:
   650             # if unknown and ignored are False, skip step 2
   648             ignore = self._ignore
       
   649             dirignore = self._dirignore
       
   650         else:
       
   651             # if not unknown and not ignored, drop dir recursion and step 2
   651             ignore = util.always
   652             ignore = util.always
   652             dirignore = util.always
   653             dirignore = util.always
   653 
   654 
   654         matchfn = match.matchfn
   655         matchfn = match.matchfn
   655         matchalways = match.always()
   656         matchalways = match.always()
   721 
   722 
   722         for s in subrepos:
   723         for s in subrepos:
   723             del results[s]
   724             del results[s]
   724         del results['.hg']
   725         del results['.hg']
   725 
   726 
   726         # step 3: report unseen items in the dmap hash
   727         # step 3: visit remaining files from dmap
   727         if not skipstep3 and not exact:
   728         if not skipstep3 and not exact:
       
   729             # If a dmap file is not in results yet, it was either
       
   730             # a) not matching matchfn b) ignored, c) missing, or d) under a
       
   731             # symlink directory.
   728             if not results and matchalways:
   732             if not results and matchalways:
   729                 visit = dmap.keys()
   733                 visit = dmap.keys()
   730             else:
   734             else:
   731                 visit = [f for f in dmap if f not in results and matchfn(f)]
   735                 visit = [f for f in dmap if f not in results and matchfn(f)]
   732             visit.sort()
   736             visit.sort()
   733 
   737 
   734             if unknown:
   738             if unknown:
   735                 # unknown == True means we walked the full directory tree above.
   739                 # unknown == True means we walked all dirs under the roots
   736                 # So if a file is not seen it was either a) not matching matchfn
   740                 # that wasn't ignored, and everything that matched was stat'ed
   737                 # b) ignored, c) missing, or d) under a symlink directory.
   741                 # and is already in results.
       
   742                 # The rest must thus be ignored or under a symlink.
   738                 audit_path = pathutil.pathauditor(self._root)
   743                 audit_path = pathutil.pathauditor(self._root)
   739 
   744 
   740                 for nf in iter(visit):
   745                 for nf in iter(visit):
   741                     # Report ignored items in the dmap as long as they are not
   746                     # Report ignored items in the dmap as long as they are not
   742                     # under a symlink directory.
   747                     # under a symlink directory.
   743                     if audit_path.check(nf):
   748                     if audit_path.check(nf):
   744                         try:
   749                         try:
   745                             results[nf] = lstat(join(nf))
   750                             results[nf] = lstat(join(nf))
       
   751                             # file was just ignored, no links, and exists
   746                         except OSError:
   752                         except OSError:
   747                             # file doesn't exist
   753                             # file doesn't exist
   748                             results[nf] = None
   754                             results[nf] = None
   749                     else:
   755                     else:
   750                         # It's either missing or under a symlink directory
   756                         # It's either missing or under a symlink directory
       
   757                         # which we in this case report as missing
   751                         results[nf] = None
   758                         results[nf] = None
   752             else:
   759             else:
   753                 # We may not have walked the full directory tree above,
   760                 # We may not have walked the full directory tree above,
   754                 # so stat everything we missed.
   761                 # so stat and check everything we missed.
   755                 nf = iter(visit).next
   762                 nf = iter(visit).next
   756                 for st in util.statfiles([join(i) for i in visit]):
   763                 for st in util.statfiles([join(i) for i in visit]):
   757                     results[nf()] = st
   764                     results[nf()] = st
   758         return results
   765         return results
   759 
   766