752 # step 1: find all explicit files |
752 # step 1: find all explicit files |
753 results, work, dirsnotfound = self._walkexplicit(match, subrepos) |
753 results, work, dirsnotfound = self._walkexplicit(match, subrepos) |
754 |
754 |
755 skipstep3 = skipstep3 and not (work or dirsnotfound) |
755 skipstep3 = skipstep3 and not (work or dirsnotfound) |
756 work = [d for d in work if not dirignore(d[0])] |
756 work = [d for d in work if not dirignore(d[0])] |
757 wadd = work.append |
|
758 |
757 |
759 # step 2: visit subdirectories |
758 # step 2: visit subdirectories |
760 while work: |
759 def traverse(work): |
761 nd, d = work.pop() |
760 wadd = work.append |
762 skip = None |
761 while work: |
763 if nd == '.': |
762 nd, d = work.pop() |
764 nd = '' |
763 skip = None |
765 d = '' |
764 if nd == '.': |
766 else: |
765 nd = '' |
767 skip = '.hg' |
766 d = '' |
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 |
|
782 else: |
767 else: |
783 nf = nd and (nd + "/" + f) or f |
768 skip = '.hg' |
784 f = nf |
769 try: |
785 if nf not in results: |
770 entries = listdir(join(nd), stat=True, skip=skip) |
786 if kind == dirkind: |
771 except OSError, inst: |
787 if not ignore(nf): |
772 if inst.errno in (errno.EACCES, errno.ENOENT): |
788 if matchtdir: |
773 match.bad(self.pathto(nd), inst.strerror) |
789 matchtdir(nf) |
774 continue |
790 wadd((nf, f)) |
775 raise |
791 if nf in dmap and (matchalways or matchfn(nf)): |
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 results[nf] = None |
802 results[nf] = None |
793 elif kind == regkind or kind == lnkkind: |
803 |
794 if nf in dmap: |
804 traverse(work) |
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 |
|
801 |
805 |
802 for s in subrepos: |
806 for s in subrepos: |
803 del results[s] |
807 del results[s] |
804 del results['.hg'] |
808 del results['.hg'] |
805 |
809 |