<commit_before>import os
from buildbot.changes.filter import ChangeFilter
from anybox.buildbot.openerp import utils
from anybox.buildbot.openerp.mirrors import Updater
from anybox.buildbot.openerp.buildouts import parse_manifest

class MirrorChangeFilter(ChangeFilter):
    """Filter changesets that are to be watched for a given buildout."""

    def __init__(self, buildmaster_dir, buildout):

        self.interesting = {} # hash -> (vcs, minor branch spec)

        parser = parse_manifest(buildmaster_dir)
        try:
            all_watched = parser.get(buildout, 'watch')
        except NoOptionError:
            return

        for watched in all_watched.split(os.linesep):
            vcs, url, minor_spec = Updater.parse_branch_spec(watched)
            h = utils.ez_hash(url)
            self.interesting[h] = vcs, minor_spec

    def filter_change(self, change):
        """True if change's about an interesting repo w/correct branch.
        """
        h = change.repository.rsplit('/', 1)[-1]
        details = self.interesting.get(h)
        if details is None:
            return False

        vcs, minor_spec = details
        if vcs == 'hg': # TODO less hardcoding
            # in hg, a minor spec is a singleton holding branch name
            assert(len(minor_spec) == 1)
            if minor_spec[0] == change.branch:
                return True<commit_msg>Using the branch for bzr triggering should work with our mirrors<commit_after>import os
from buildbot.changes.filter import ChangeFilter
from anybox.buildbot.openerp import utils
from anybox.buildbot.openerp.mirrors import Updater
from anybox.buildbot.openerp.buildouts import parse_manifest

class MirrorChangeFilter(ChangeFilter):
    """Filter changesets that are to be watched for a given buildout."""

    def __init__(self, buildmaster_dir, buildout):

        self.interesting = {} # hash -> (vcs, minor branch spec)

        parser = parse_manifest(buildmaster_dir)
        try:
            all_watched = parser.get(buildout, 'watch')
        except NoOptionError:
            return

        for watched in all_watched.split(os.linesep):
            vcs, url, minor_spec = Updater.parse_branch_spec(watched)
            h = utils.ez_hash(url)
            self.interesting[h] = vcs, minor_spec

    def filter_change(self, change):
        """True if change's about an interesting repo w/correct branch.
        """
        repo_prop = change.repository
        if repo_prop: # hg
            h = repo_prop.rsplit('/', 1)[-1]
        else: # bzr
            h = change.branch

        details = self.interesting.get(h)
        if details is None:
            return False

        vcs, minor_spec = details
        if vcs == 'hg': # TODO less hardcoding
            # in hg, a minor spec is a singleton holding branch name
            assert(len(minor_spec) == 1)
            if minor_spec[0] == change.branch:
                return True
{'fraction_non_alphanumeric': 0.08637760327756913, 'fraction_numerical': 0.0027313076135199728, 'mean_word_length': 2.4069767441860463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '912671', 'n_tokens_mistral': 854, 'n_tokens_neox': 816, 'n_words': 244}