diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 3c35683bee..91728ece85 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -363,17 +363,6 @@ def graph(self): def pipelines(self): return get_pipelines(self.graph) - @staticmethod - def _filter_out_dirs(dirs, outs, root_dir): - def filter_dirs(dname): - path = os.path.join(root_dir, dname) - for out in outs: - if path == os.path.normpath(out): - return False - return True - - return list(filter(filter_dirs, dirs)) - @cached_property def stages(self): """ @@ -388,7 +377,7 @@ def stages(self): from dvc.stage import Stage stages = [] - outs = [] + outs = set() for root, dirs, files in self.tree.walk(self.root_dir): for fname in files: @@ -396,12 +385,13 @@ def stages(self): if not Stage.is_valid_filename(path): continue stage = Stage.load(self, path) + stages.append(stage) + for out in stage.outs: if out.scheme == "local": - outs.append(out.fspath + out.sep) - stages.append(stage) + outs.add(out.fspath) - dirs[:] = self._filter_out_dirs(dirs, outs, root) + dirs[:] = [d for d in dirs if os.path.join(root, d) not in outs] return stages