gecko-dev/python
Andrew Halberstadt f4c851912d Bug 1494069 - [mozlint] Collapse exclude paths into their smallest possible set, r=egao
Often we specify globs in our exclude patterns, e.g:

    exclude:
        - **/node_modules
        - obj*

However, these globs get expanded out to *every* file that matches them. This
can sometimes be thousands or even tens of thousands of files.

We then pass these paths on to the underlying linters and tell them to
exclude them all. This causes a lot of overhead and slows down performance.

This commit implements a "collapse" function. Given a set of paths, it'll
collapse them into the smallest set of parent directories that contain the
original set, and that don't contain any extra files.

For example, given a directory structure like this:

    a
    -- foo.txt
    -- b
       -- bar.txt
       -- baz.txt
    -- c
       -- ham.txt
       -- d
          -- spam.txt

Then the following will happen:

     >>> collapse(['a/foo.txt', 'a/b/bar.txt', 'a/c/ham.txt', 'a/c/d/spam.txt'])
     ['a/foo.txt', 'b/bar.txt', 'c']

Since all files under directory 'c' are specified by the original set (both
'c/ham.txt' and 'c/d/spam.txt'), we can collapse it down to just 'c'. However
not all files under 'b' are specified (we're missing 'a/b/baz.txt'), so we
can't collapse 'b' (and by extension also can't collapse 'a').

If we had included 'a/b/baz.txt':

     >>> collapse(['a/foo.txt', 'a/b/bar.txt', 'a/b/baz.txt', 'a/c/ham.txt', 'a/c/d/spam.txt'])
     ['a']

In both cases, the smallest set of paths that contains the original set (and
only the original set) is computed.

The collapse function has a little bit of overhead but it's not too bad.
For example collapsing all files matched by '**/node_modules' takes ~0.015s.
Collapsing two full objdirs, takes ~0.6s. But a follow up commit is planned to
make sure we stop using 'obj*' to reduce that overhead.

Depends on D7738

Differential Revision: https://phabricator.services.mozilla.com/D7739

--HG--
extra : moz-landing-system : lando
2018-10-12 15:57:42 +00:00
..
devtools/migrate-l10n
docs Backed out 3 changesets (bug 1346026) for Bugzilla linting 2018-05-23 19:42:13 +03:00
l10n/fluent_migrations Bug 1486934 - Modify about:about to use fluent for localization r=Gijs,flod,jaws,Pike 2018-10-10 17:41:47 +00:00
mach Bug 1291335 - Check mozconfig for --disable-tests when running mach test commands r=gbrown 2018-10-03 15:40:48 +00:00
mozboot Bug 1494287 - followup: Fix undefined variable in fallback path. r=me 2018-10-12 08:24:04 +09:00
mozbuild Bug 1497359 - Detect and reject re-use of objdirs between Make and Tup in configure. r=froydnj 2018-10-11 19:16:49 +00:00
mozlint Bug 1494069 - [mozlint] Collapse exclude paths into their smallest possible set, r=egao 2018-10-12 15:57:42 +00:00
mozrelease Merge inbound to mozilla-central. a=merge 2018-09-14 01:01:37 +03:00
mozterm Bug 1471171 - Indicate that mozterm is universal and works on any version of Python; r=emorley 2018-07-02 12:03:10 +01:00
mozversioncontrol Bug 1472177 - Run mozversioncontrol tests under python 3 r=gps 2018-07-24 21:21:46 +00:00
safety Bug 1476003 Update python virtual environment for |mach python-safety| r=davehunt 2018-07-16 15:36:50 +00:00
README
mach_commands.py Bug 1476390 - [python-test] Default number of processes to multiprocessing.cpu_count() r=davehunt 2018-07-18 16:15:48 +00:00
moz.build Bug 1469872 - update bugzilla products and components in moz.build files: devtools. r=nalexander 2018-06-20 21:34:40 +03:00

README

This directory contains common Python code.

The basic rule is that if Python code is cross-module (that's "module" in the
Mozilla meaning - as in "module ownership") and is MPL-compatible, it should
go here.

What should not go here:

* Vendored python modules (use third_party/python instead)
* Python that is not MPL-compatible (see other-licenses/)
* Python that has good reason to remain close to its "owning" (Mozilla)
  module (e.g. it is only being consumed from there).

Historical information can be found at
https://bugzilla.mozilla.org/show_bug.cgi?id=775243
https://bugzilla.mozilla.org/show_bug.cgi?id=1346025