##// END OF EJS Templates
dirstate.walk: factor out directory traversal...
Siddharth Agarwal -
r24559:4728d6f7 default
parent child Browse files
Show More
@@ -754,50 +754,54 b' class dirstate(object):'
754 754
755 755 skipstep3 = skipstep3 and not (work or dirsnotfound)
756 756 work = [d for d in work if not dirignore(d[0])]
757 wadd = work.append
758 757
759 758 # step 2: visit subdirectories
760 while work:
761 nd, d = work.pop()
762 skip = None
763 if nd == '.':
764 nd = ''
765 d = ''
766 else:
767 skip = '.hg'
768 try:
769 entries = listdir(join(nd), stat=True, skip=skip)
770 except OSError, inst:
771 if inst.errno in (errno.EACCES, errno.ENOENT):
772 match.bad(self.pathto(nd), inst.strerror)
773 continue
774 raise
775 for f, kind, st in entries:
776 if normalizefile:
777 # even though f might be a directory, we're only interested
778 # in comparing it to files currently in the dmap --
779 # therefore normalizefile is enough
780 nf = normalizefile(nd and (nd + "/" + f) or f, True, True)
781 f = d and (d + "/" + f) or f
759 def traverse(work):
760 wadd = work.append
761 while work:
762 nd, d = work.pop()
763 skip = None
764 if nd == '.':
765 nd = ''
766 d = ''
782 767 else:
783 nf = nd and (nd + "/" + f) or f
784 f = nf
785 if nf not in results:
786 if kind == dirkind:
787 if not ignore(nf):
788 if matchtdir:
789 matchtdir(nf)
790 wadd((nf, f))
791 if nf in dmap and (matchalways or matchfn(nf)):
768 skip = '.hg'
769 try:
770 entries = listdir(join(nd), stat=True, skip=skip)
771 except OSError, inst:
772 if inst.errno in (errno.EACCES, errno.ENOENT):
773 match.bad(self.pathto(nd), inst.strerror)
774 continue
775 raise
776 for f, kind, st in entries:
777 if normalizefile:
778 # even though f might be a directory, we're only
779 # interested in comparing it to files currently in the
780 # dmap -- therefore normalizefile is enough
781 nf = normalizefile(nd and (nd + "/" + f) or f, True,
782 True)
783 f = d and (d + "/" + f) or f
784 else:
785 nf = nd and (nd + "/" + f) or f
786 f = nf
787 if nf not in results:
788 if kind == dirkind:
789 if not ignore(nf):
790 if matchtdir:
791 matchtdir(nf)
792 wadd((nf, f))
793 if nf in dmap and (matchalways or matchfn(nf)):
794 results[nf] = None
795 elif kind == regkind or kind == lnkkind:
796 if nf in dmap:
797 if matchalways or matchfn(nf):
798 results[nf] = st
799 elif (matchalways or matchfn(f)) and not ignore(nf):
800 results[nf] = st
801 elif nf in dmap and (matchalways or matchfn(nf)):
792 802 results[nf] = None
793 elif kind == regkind or kind == lnkkind:
794 if nf in dmap:
795 if matchalways or matchfn(nf):
796 results[nf] = st
797 elif (matchalways or matchfn(f)) and not ignore(nf):
798 results[nf] = st
799 elif nf in dmap and (matchalways or matchfn(nf)):
800 results[nf] = None
803
804 traverse(work)
801 805
802 806 for s in subrepos:
803 807 del results[s]
General Comments 0
You need to be logged in to leave comments. Login now