1111
1212
1313def scm_find_files (
14- path : _t .PathT , scm_files : set [str ], scm_dirs : set [str ]
14+ path : _t .PathT ,
15+ scm_files : set [str ],
16+ scm_dirs : set [str ],
17+ force_all_files : bool = False ,
1518) -> list [str ]:
1619 """ setuptools compatible file finder that follows symlinks
1720
@@ -20,6 +23,7 @@ def scm_find_files(
2023 (including symlinks to directories)
2124 - scm_dirs: set of scm controlled directories
2225 (including directories containing no scm controlled files)
26+ - force_all_files: ignore ``scm_files`` and ``scm_dirs`` and list everything.
2327
2428 scm_files and scm_dirs must be absolute with symlinks resolved (realpath),
2529 with normalized case (normcase)
@@ -38,7 +42,7 @@ def _link_not_in_scm(n: str) -> bool:
3842 fn = os .path .join (realdirpath , os .path .normcase (n ))
3943 return os .path .islink (fn ) and fn not in scm_files
4044
41- if realdirpath not in scm_dirs :
45+ if not force_all_files and realdirpath not in scm_dirs :
4246 # directory not in scm, don't walk it's content
4347 dirnames [:] = []
4448 continue
@@ -54,13 +58,16 @@ def _link_not_in_scm(n: str) -> bool:
5458 # symlink loop protection
5559 dirnames [:] = []
5660 continue
57- dirnames [:] = [dn for dn in dirnames if not _link_not_in_scm (dn )]
61+ dirnames [:] = [
62+ dn for dn in dirnames if force_all_files or not _link_not_in_scm (dn )
63+ ]
5864 for filename in filenames :
59- if _link_not_in_scm (filename ):
65+ if not force_all_files and _link_not_in_scm (filename ):
6066 continue
6167 # dirpath + filename with symlinks preserved
6268 fullfilename = os .path .join (dirpath , filename )
63- if os .path .normcase (os .path .realpath (fullfilename )) in scm_files :
69+ is_tracked = os .path .normcase (os .path .realpath (fullfilename )) in scm_files
70+ if force_all_files or is_tracked :
6471 res .append (os .path .join (path , os .path .relpath (fullfilename , realpath )))
6572 seen .add (realdirpath )
6673 return res
0 commit comments