Bug 1335309 - Change the default for find_executables to False. r=mshal

Back when the class was written, for the packaging code, it made sense
that the default was True. But now that it's used all over the place,
and that the vast majority of uses are with find_executables=False, it
makes more sense for that to be the default.

--HG--
extra : rebase_source : ff813735fc0d53093f348f20eb77ee03e9b09d4e
This commit is contained in:
Mike Hommey 2017-01-31 14:06:15 +09:00
Родитель dbdbf959b8
Коммит dc5d1e6adf
25 изменённых файлов: 38 добавлений и 47 удалений

Просмотреть файл

@ -150,16 +150,14 @@ def resolve_files():
vs_path, sdk_path = find_vs_paths()
for entry in VS_PATTERNS:
finder = FileFinder(vs_path, find_executables=False,
ignore=entry.get('ignore', []))
finder = FileFinder(vs_path, ignore=entry.get('ignore', []))
for p, f in finder.find(entry['pattern']):
assert p.startswith(('VC/', 'DIA SDK/'))
yield p.encode('utf-8'), f
for entry in SDK_PATTERNS:
finder = FileFinder(sdk_path, find_executables=False,
ignore=entry.get('ignore', []))
finder = FileFinder(sdk_path, ignore=entry.get('ignore', []))
for p, f in finder.find(entry['pattern']):
relpath = 'SDK/%s' % p

Просмотреть файл

@ -89,8 +89,7 @@ class TestMozbuildReading(unittest.TestCase):
all_paths = self._mozbuilds(reader)
_, contexts = reader.read_relevant_mozbuilds(all_paths)
finder = FileFinder(config.topsrcdir, find_executables=False,
ignore=['obj*'])
finder = FileFinder(config.topsrcdir, ignore=['obj*'])
def pattern_exists(pat):
return [p for p in finder.find(pat)] != []

Просмотреть файл

@ -34,7 +34,7 @@ def explode(aar, destdir):
os.rename(mozpath.join(destdir, 'classes.jar'), classes_jar)
# Embedded JAR libraries are optional.
finder = FileFinder(mozpath.join(destdir, 'libs'), find_executables=False)
finder = FileFinder(mozpath.join(destdir, 'libs'))
for p, _ in finder.find('*.jar'):
jar = mozpath.join(finder.base, name + '-' + p)
os.rename(mozpath.join(finder.base, p), jar)

Просмотреть файл

@ -102,7 +102,7 @@ def main(args):
if not opts.resources:
continue
resources = os.path.abspath(opts.resources)
finder = FileFinder(resources, find_executables=False)
finder = FileFinder(resources)
matches = [p for p, _ in finder.find(drawables_template.format(name=name))]
if not matches:
raise Exception("Could not find drawable in '{resources}' for '{name}'"

Просмотреть файл

@ -54,12 +54,12 @@ def package_fennec_apk(inputs=[], omni_ja=None, classes_dex=None,
jarrer.add(path, file, compress=compress)
for features_dir in features_dirs:
finder = FileFinder(features_dir, find_executables=False)
finder = FileFinder(features_dir)
for p, f in finder.find('**'):
add(mozpath.join('assets', 'features', p), f, False)
for assets_dir in assets_dirs:
finder = FileFinder(assets_dir, find_executables=False)
finder = FileFinder(assets_dir)
for p, f in finder.find('**'):
compress = None # Take default from Jarrer.
if p.endswith('.so'):
@ -91,7 +91,7 @@ def package_fennec_apk(inputs=[], omni_ja=None, classes_dex=None,
add(mozpath.join('assets', p), f, compress=compress)
for lib_dir in lib_dirs:
finder = FileFinder(lib_dir, find_executables=False)
finder = FileFinder(lib_dir)
for p, f in finder.find('**'):
add(mozpath.join('lib', p), f)

Просмотреть файл

@ -44,8 +44,7 @@ def process_manifest(destdir, paths, track=None,
remove_unaccounted = FileRegistry()
dummy_file = BaseFile()
finder = FileFinder(destdir, find_executables=False,
find_dotfiles=True)
finder = FileFinder(destdir, find_dotfiles=True)
for dest in manifest._dests:
for p, f in finder.find(dest):
remove_unaccounted.add(p, dummy_file)

Просмотреть файл

@ -470,7 +470,6 @@ def find_files(archive):
])
common_kwargs = {
'find_executables': False,
'find_dotfiles': True,
'ignore': ignore,
}

Просмотреть файл

@ -28,7 +28,7 @@ def main(args):
jarrer = Jarrer(optimize=False)
with errors.accumulate():
finder = FileFinder(args.C, find_executables=False)
finder = FileFinder(args.C)
for path in args.input:
for p, f in finder.find(path):
jarrer.add(p, f)

Просмотреть файл

@ -247,7 +247,7 @@ class AndroidEclipseBackend(CommonBackend):
defines['MOZ_ANDROID_MIN_SDK_VERSION'] = self.environment.defines['MOZ_ANDROID_MIN_SDK_VERSION']
copier = FileCopier()
finder = FileFinder(template_directory, find_executables=False)
finder = FileFinder(template_directory)
for input_filename, f in itertools.chain(finder.find('**'), finder.find('.**')):
if input_filename == 'AndroidManifest.xml' and not data.is_library:
# Main projects supply their own manifests.

Просмотреть файл

@ -190,8 +190,7 @@ class VisualStudioBackend(CommonBackend):
sources = set(os.path.join('$(TopSrcDir)', path, s) for s in sources)
sources = set(os.path.normpath(s) for s in sources)
finder = FileFinder(os.path.join(self.environment.topsrcdir, path),
find_executables=False)
finder = FileFinder(os.path.join(self.environment.topsrcdir, path))
headers = [t[0] for t in finder.find('*.h')]
headers = [os.path.normpath(os.path.join('$(TopSrcDir)',

Просмотреть файл

@ -15,7 +15,7 @@ def package_gcno_tree(root, output_file):
if isinstance(root, unicode):
root = root.encode('utf-8')
finder = FileFinder(root, find_executables=False)
finder = FileFinder(root)
jarrer = Jarrer(optimize=False)
for p, f in finder.find("**/*.gcno"):
jarrer.add(p, f)

Просмотреть файл

@ -380,7 +380,7 @@ class GypProcessor(object):
depth = chrome_src
# Files that gyp_chromium always includes
includes = [encode(mozpath.join(script_dir, 'common.gypi'))]
finder = FileFinder(chrome_src, find_executables=False)
finder = FileFinder(chrome_src)
includes.extend(encode(mozpath.join(chrome_src, name))
for name, _ in finder.find('*/supplement.gypi'))

Просмотреть файл

@ -192,7 +192,7 @@ class MozbuildFileCommands(MachCommandBase):
# We need two finders because the reader's finder operates on
# absolute paths.
finder = FileFinder(self.topsrcdir, find_executables=False)
finder = FileFinder(self.topsrcdir)
if repo:
reader_finder = MercurialRevisionFinder(repo, rev=rev,
recognize_repo_paths=True)

Просмотреть файл

@ -942,8 +942,7 @@ class BuildReader(object):
'obj*',
}
finder = FileFinder(self.config.topsrcdir, find_executables=False,
ignore=ignore)
finder = FileFinder(self.config.topsrcdir, ignore=ignore)
# The root doesn't get picked up by FileFinder.
yield 'moz.build'

Просмотреть файл

@ -31,7 +31,7 @@ from .context import Context
from mozpack.files import FileFinder
default_finder = FileFinder('/', find_executables=False)
default_finder = FileFinder('/')
def alphabetical_sorted(iterable, cmp=None, key=lambda x: x.lower(),

Просмотреть файл

@ -418,7 +418,7 @@ class JarMaker(object):
prefix = ''.join(_prefix(src))
emitted = set()
for _srcdir in src_base:
finder = FileFinder(_srcdir, find_executables=False)
finder = FileFinder(_srcdir)
for path, _ in finder.find(src):
# If the path was already seen in one of the other source
# directories, skip it. That matches the non-wildcard case

Просмотреть файл

@ -152,7 +152,7 @@ class TestBuild(unittest.TestCase):
# of the difference in type.
result = {
p: f.open().read().decode('utf-8')
for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist'), find_executables=False)
for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist'))
}
self.assertTrue(len(result))
self.assertEqual(result, {

Просмотреть файл

@ -841,7 +841,7 @@ class FileFinder(BaseFinder):
'''
Helper to get appropriate BaseFile instances from the file system.
'''
def __init__(self, base, ignore=(),
def __init__(self, base, find_executables=False, ignore=(),
find_dotfiles=False, **kargs):
'''
Create a FileFinder for files under the given base directory.
@ -856,8 +856,6 @@ class FileFinder(BaseFinder):
to a directory, all files under that directory will be ignored. If
an entry corresponds to a file, that particular file will be ignored.
'''
assert 'find_executables' in kargs
find_executables = kargs.pop('find_executables')
BaseFinder.__init__(self, base, **kargs)
self.find_dotfiles = find_dotfiles
self.find_executables = find_executables

Просмотреть файл

@ -361,7 +361,7 @@ class InstallManifest(object):
if install_type in (self.PATTERN_SYMLINK, self.PATTERN_COPY):
_, base, pattern, dest = entry
finder = FileFinder(base, find_executables=False)
finder = FileFinder(base)
paths = [f[0] for f in finder.find(pattern)]
if install_type == self.PATTERN_SYMLINK:

Просмотреть файл

@ -47,7 +47,7 @@ class UnpackFinder(BaseFinder):
if isinstance(source, BaseFinder):
self._finder = source
else:
self._finder = FileFinder(source, find_executables=False)
self._finder = FileFinder(source)
self.base = self._finder.base
self.files = FileRegistry()
self.kind = 'flat'

Просмотреть файл

@ -924,13 +924,13 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
def test_file_finder(self):
self.prepare_match_test(with_dotfiles=True)
self.finder = FileFinder(self.tmpdir, find_executables=False)
self.finder = FileFinder(self.tmpdir)
self.do_match_test()
self.do_finder_test(self.finder)
def test_get(self):
self.prepare_match_test()
finder = FileFinder(self.tmpdir, find_executables=False)
finder = FileFinder(self.tmpdir)
self.assertIsNone(finder.get('does-not-exist'))
res = finder.get('bar')
@ -946,7 +946,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
# Present to ensure prefix matching doesn't exclude.
self.add('foo/quxz')
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux'], find_executables=False)
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux'])
self.do_check('**', ['bar', 'foo/bar', 'foo/baz', 'foo/quxz', 'fooz'])
self.do_check('foo/*', ['foo/bar', 'foo/baz', 'foo/quxz'])
@ -964,7 +964,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
# Be sure prefix match doesn't get ignored.
self.add('barz')
self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar'], find_executables=False)
self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar'])
self.do_check('**', ['barz', 'foo/baz', 'foo/qux/1', 'foo/qux/2/test',
'foo/qux/2/test2', 'foo/qux/bar'])
self.do_check('foo/**', ['foo/baz', 'foo/qux/1', 'foo/qux/2/test',
@ -976,14 +976,14 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
self.add('foo/quxz')
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*'], find_executables=False)
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*'])
self.do_check('**', ['foo/bar', 'foo/baz', 'foo/quxz', 'bar'])
self.do_check('foo/**', ['foo/bar', 'foo/baz', 'foo/quxz'])
def test_dotfiles(self):
"""Finder can find files beginning with . is configured."""
self.prepare_match_test(with_dotfiles=True)
self.finder = FileFinder(self.tmpdir, find_dotfiles=True, find_executables=False)
self.finder = FileFinder(self.tmpdir, find_dotfiles=True)
self.do_check('**', ['bar', 'foo/.foo', 'foo/.bar/foo',
'foo/bar', 'foo/baz', 'foo/qux/1', 'foo/qux/bar',
'foo/qux/2/test', 'foo/qux/2/test2'])
@ -991,7 +991,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
def test_dotfiles_plus_ignore(self):
self.prepare_match_test(with_dotfiles=True)
self.finder = FileFinder(self.tmpdir, find_dotfiles=True,
ignore=['foo/.bar/**'], find_executables=False)
ignore=['foo/.bar/**'])
self.do_check('foo/**', ['foo/.foo', 'foo/bar', 'foo/baz',
'foo/qux/1', 'foo/qux/bar', 'foo/qux/2/test', 'foo/qux/2/test2'])
@ -1060,8 +1060,8 @@ class TestComposedFinder(MatchTestTemplate, TestWithTmpDir):
open(self.tmppath('a/foo/qux/hoge'), 'wb').write('hoge')
open(self.tmppath('a/foo/qux/bar'), 'wb').write('not the right content')
self.finder = ComposedFinder({
'': FileFinder(self.tmppath('a'), find_executables=False),
'foo/qux': FileFinder(self.tmppath('b'), find_executables=False),
'': FileFinder(self.tmppath('a')),
'foo/qux': FileFinder(self.tmppath('b')),
})
self.do_match_test()

Просмотреть файл

@ -245,7 +245,7 @@ class TestJar(unittest.TestCase):
def test_add_from_finder(self):
s = MockDest()
with JarWriter(fileobj=s, optimize=self.optimize) as jar:
finder = FileFinder(test_data_path, find_executables=False)
finder = FileFinder(test_data_path)
for p, f in finder.find('test_data'):
jar.add('test_data', f)

Просмотреть файл

@ -46,8 +46,8 @@ class TestUnifiedFinder(TestUnified):
self.create_one('b', 'test/foo', 'b\nc\na\n')
self.create_both('test/bar', 'a\nb\nc\n')
finder = UnifiedFinder(FileFinder(self.tmppath('a'), find_executables=False),
FileFinder(self.tmppath('b'), find_executables=False),
finder = UnifiedFinder(FileFinder(self.tmppath('a')),
FileFinder(self.tmppath('b')),
sorted=['test'])
self.assertEqual(sorted([(f, c.open().read())
for f, c in finder.find('foo')]),
@ -63,8 +63,8 @@ class TestUnifiedFinder(TestUnified):
class TestUnifiedBuildFinder(TestUnified):
def test_unified_build_finder(self):
finder = UnifiedBuildFinder(FileFinder(self.tmppath('a'), find_executables=False),
FileFinder(self.tmppath('b'), find_executables=False))
finder = UnifiedBuildFinder(FileFinder(self.tmppath('a')),
FileFinder(self.tmppath('b')))
# Test chrome.manifest unification
self.create_both('chrome.manifest', 'a\nb\nc\n')

Просмотреть файл

@ -22,7 +22,7 @@ class FilterPath(object):
if self._finder:
return self._finder
self._finder = FileFinder(
self.path, find_executables=False, ignore=self.exclude)
self.path, ignore=self.exclude)
return self._finder
@property

Просмотреть файл

@ -82,7 +82,7 @@ class SphinxManager(object):
for p in sorted(self._python_package_dirs):
full = os.path.join(self._topsrcdir, p)
finder = FileFinder(full, find_executables=False)
finder = FileFinder(full)
dirs = {os.path.dirname(f[0]) for f in finder.find('**')}
excludes = {d for d in dirs if d.endswith('test')}