11
11
12
12
13
13
def 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 ,
15
18
) -> list [str ]:
16
19
""" setuptools compatible file finder that follows symlinks
17
20
@@ -20,6 +23,7 @@ def scm_find_files(
20
23
(including symlinks to directories)
21
24
- scm_dirs: set of scm controlled directories
22
25
(including directories containing no scm controlled files)
26
+ - force_all_files: ignore ``scm_files`` and ``scm_dirs`` and list everything.
23
27
24
28
scm_files and scm_dirs must be absolute with symlinks resolved (realpath),
25
29
with normalized case (normcase)
@@ -38,7 +42,7 @@ def _link_not_in_scm(n: str) -> bool:
38
42
fn = os .path .join (realdirpath , os .path .normcase (n ))
39
43
return os .path .islink (fn ) and fn not in scm_files
40
44
41
- if realdirpath not in scm_dirs :
45
+ if not force_all_files and realdirpath not in scm_dirs :
42
46
# directory not in scm, don't walk it's content
43
47
dirnames [:] = []
44
48
continue
@@ -54,13 +58,16 @@ def _link_not_in_scm(n: str) -> bool:
54
58
# symlink loop protection
55
59
dirnames [:] = []
56
60
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
+ ]
58
64
for filename in filenames :
59
- if _link_not_in_scm (filename ):
65
+ if not force_all_files and _link_not_in_scm (filename ):
60
66
continue
61
67
# dirpath + filename with symlinks preserved
62
68
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 :
64
71
res .append (os .path .join (path , os .path .relpath (fullfilename , realpath )))
65
72
seen .add (realdirpath )
66
73
return res
0 commit comments