##// END OF EJS Templates
dirstate: improve documentation and readability of match and ignore in the walker
Mads Kiilerich -
r21115:1b6e37f4 default
parent child Browse files
Show More
@@ -595,7 +595,7 b' class dirstate(object):'
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)
@@ -606,10 +606,10 b' class dirstate(object):'
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):
@@ -641,13 +641,14 b' class dirstate(object):'
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
@@ -723,8 +724,11 b' class dirstate(object):'
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:
@@ -732,9 +736,10 b' class dirstate(object):'
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):
@@ -743,15 +748,17 b' class dirstate(object):'
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
General Comments 0
You need to be logged in to leave comments. Login now