Dnia 12 czerwca 2016 11:43:35 CEST, Zac Medico <zmed...@gentoo.org> napisał(a): >On 06/12/2016 02:31 AM, Michał Górny wrote: >> Dnia 12 czerwca 2016 11:20:36 CEST, Zac Medico <zmed...@gentoo.org> >napisał(a): >>> On 05/21/2016 11:56 PM, Michał Górny wrote: >>>> Allow INSTALL_MASK patterns to start with '-' to indicate that >>>> a specific match is to be excluded from being masked. In this case, >>>> the last matching pattern determines whether the file is actually >>>> filtered out or kept. >>>> --- >>>> pym/portage/dbapi/vartree.py | 10 ++++++---- >>>> 1 file changed, 6 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/pym/portage/dbapi/vartree.py >>> b/pym/portage/dbapi/vartree.py >>>> index 8e5ac43..d02d850 100644 >>>> --- a/pym/portage/dbapi/vartree.py >>>> +++ b/pym/portage/dbapi/vartree.py >>>> @@ -3690,19 +3690,21 @@ class dblink(object): >>>> def _is_install_masked(self, relative_path): >>>> ret = False >>>> for pattern in self.settings.install_mask: >>>> + # if pattern starts with -, possibly exclude this path >>>> + pat_res = not pattern.startswith('-') >>>> + if not pat_res: >>>> + pattern = pattern[1:] >>>> # absolute path pattern >>>> if pattern.startswith('/'): >>>> # match either exact path or one of parent dirs >>>> # the latter is done via matching pattern/* >>>> if (fnmatch.fnmatch(relative_path, pattern[1:]) >>>> or >>>> fnmatch.fnmatch(relative_path, pattern[1:] + '/*')): >>>> - ret = True >>>> - break >>>> + ret = pat_res >>>> # filename >>>> else: >>>> if >>>> fnmatch.fnmatch(os.path.basename(relative_path), pattern): >>>> - ret = True >>>> - break >>>> + ret = pat_res >>>> return ret >>>> >>>> def treewalk(self, srcroot, destroot, inforoot, myebuild, >>> cleanup=0, >>>> >>> >>> In order to implement this with pre-compiled patterns, we can use a >>> separate regular expression to represent all of the exclusions. >> >> That won't work since exclusive and inclusive patterns can be >stacked, and for this to work they are applied in order. >> >> E.g. /usr/foo -/usr/foo/bar /usr/foo/bar/baz >> >> Should remove all foo subdirectories except for bar, and also baz >inside bar. > >Hmm, I suppose there could be an optimized implementation to handle >INSTALL_MASK settings where there are no such ordering constraints.
Is this really worth the effort? I'm using the patch for a while and I/O's the bottleneck, not CPU. If you really insist on optimizing this, i guess we could precompile all patterns separately. -- Best regards, Michał Górny (by phone)