##// 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 595 kind = getkind(st.st_mode)
596 596 if kind == dirkind:
597 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 599 results[nf] = None
600 600 if matchedir:
601 601 matchedir(nf)
@@ -606,10 +606,10 b' class dirstate(object):'
606 606 badfn(ff, badtype(kind))
607 607 if nf in dmap:
608 608 results[nf] = None
609 except OSError, inst:
610 if nf in dmap: # does it exactly match a file?
609 except OSError, inst: # nf not found on disk - it is dirstate only
610 if nf in dmap: # does it exactly match a missing file?
611 611 results[nf] = None
612 else: # does it match a directory?
612 else: # does it match a missing directory?
613 613 prefix = nf + "/"
614 614 for fn in dmap:
615 615 if fn.startswith(prefix):
@@ -641,13 +641,14 b' class dirstate(object):'
641 641 self._ui.warn('%s: %s\n' % (self.pathto(f), msg))
642 642 return False
643 643
644 ignore = self._ignore
645 dirignore = self._dirignore
646 644 if ignored:
647 645 ignore = util.never
648 646 dirignore = util.never
649 elif not unknown:
650 # if unknown and ignored are False, skip step 2
647 elif unknown:
648 ignore = self._ignore
649 dirignore = self._dirignore
650 else:
651 # if not unknown and not ignored, drop dir recursion and step 2
651 652 ignore = util.always
652 653 dirignore = util.always
653 654
@@ -723,8 +724,11 b' class dirstate(object):'
723 724 del results[s]
724 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 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 732 if not results and matchalways:
729 733 visit = dmap.keys()
730 734 else:
@@ -732,9 +736,10 b' class dirstate(object):'
732 736 visit.sort()
733 737
734 738 if unknown:
735 # unknown == True means we walked the full directory tree above.
736 # So if a file is not seen it was either a) not matching matchfn
737 # b) ignored, c) missing, or d) under a symlink directory.
739 # unknown == True means we walked all dirs under the roots
740 # that wasn't ignored, and everything that matched was stat'ed
741 # and is already in results.
742 # The rest must thus be ignored or under a symlink.
738 743 audit_path = pathutil.pathauditor(self._root)
739 744
740 745 for nf in iter(visit):
@@ -743,15 +748,17 b' class dirstate(object):'
743 748 if audit_path.check(nf):
744 749 try:
745 750 results[nf] = lstat(join(nf))
751 # file was just ignored, no links, and exists
746 752 except OSError:
747 753 # file doesn't exist
748 754 results[nf] = None
749 755 else:
750 756 # It's either missing or under a symlink directory
757 # which we in this case report as missing
751 758 results[nf] = None
752 759 else:
753 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 762 nf = iter(visit).next
756 763 for st in util.statfiles([join(i) for i in visit]):
757 764 results[nf()] = st
General Comments 0
You need to be logged in to leave comments. Login now