From 11766c8839b0da678eb7e98b075414ba038df226 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 5 Oct 2022 02:59:42 +0300 Subject: [PATCH] ignore: walk: support detail=True --- dvc/ignore.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dvc/ignore.py b/dvc/ignore.py index b26d62ff1..2177768c2 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -300,12 +300,25 @@ class DvcIgnoreFilter: return [fs_dict[name] for name in chain(dirs, nondirs)] def walk(self, fs: FileSystem, path: AnyFSPath, **kwargs): + detail = kwargs.get("detail", False) ignore_subrepos = kwargs.pop("ignore_subrepos", True) if fs.protocol == Schemes.LOCAL: for root, dirs, files in fs.walk(path, **kwargs): - dirs[:], files[:] = self( - root, dirs, files, ignore_subrepos=ignore_subrepos - ) + if detail: + all_dnames = set(dirs.keys()) + all_fnames = set(files.keys()) + dnames, fnames = self( + root, + all_dnames, + all_fnames, + ignore_subrepos=ignore_subrepos, + ) + list(map(dirs.pop, all_dnames - set(dnames))) + list(map(files.pop, all_fnames - set(fnames))) + else: + dirs[:], files[:] = self( + root, dirs, files, ignore_subrepos=ignore_subrepos + ) yield root, dirs, files else: yield from fs.walk(path, **kwargs)