Exemplo n.º 1
0
    def __init__(self, project_name, project_info, local_dir, fetch=True):
        self.project_name = project_name
        self.recombinations = dict()
        self.commits = dict()

        log.info('Current project:\n' + pprint.pformat(project_info))
        self.original_project = project_info['original']
        self.replica_project = project_info['replica']
        self.deploy_name = project_info['deploy-name']
        self.rev_deps = None
        if 'rev-deps' in project_info:
            self.rev_deps = project_info['rev-deps']

        self.test_types = []
        if "tests" in project_info['replica'] and project_info["replica"][
                "tests"] is not None:
            self.test_types = project_info["replica"]["tests"]

        self.replication_strategy = project_info['replication-strategy']
        self.test_minimum_score = 0

        self.patches_branch_suffix = "-patches"
        self.target_branch_suffix = "-tag"
        # Set up local repo
        self.underlayer = Underlayer(project_name, local_dir)

        # Set up remotes
        self.underlayer.set_replica(self.replica_project['location'],
                                    self.replica_project['name'],
                                    fetch=fetch)
        self.underlayer.set_original(self.original_project['type'],
                                     self.original_project['location'],
                                     self.original_project['name'],
                                     fetch=fetch)

        if "mirror" in project_info['replica']:
            self.underlayer.set_replica_mirror(
                project_info['replica']['mirror'],
                self.replica_project['name'],
                fetch=fetch)

        # Set up branches hypermap
        # get branches from original
        # self.original_branches = self.underlayer.list_branches('original')
        self.original_branches = project_info['original']['watch-branches']
        self.backports_startref = dict()
        for original_branch in self.original_branches:
            if 'backports-start' in self.original_project:
                self.backports_startref[
                    original_branch] = self.original_project[
                        'backports-start'][original_branch]
            # apply mapping to find target branch
            try:
                replica_branch = project_info['replica']['branch-mappings'][
                    original_branch]
            except KeyError:
                replica_branch = original_branch
            target_branch = '%s%s' % (replica_branch,
                                      self.target_branch_suffix)
            patches_branch = '%s%s' % (replica_branch,
                                       self.patches_branch_suffix)
            self.underlayer.set_branch_maps(original_branch, replica_branch,
                                            target_branch, patches_branch)

            self.recombinations[replica_branch] = None
            self.commits[replica_branch] = {}

        self.ref_locks = dict()
        if 'ref-locks' in self.replica_project:
            for branch in self.replica_project['ref-locks']:
                # no advancement will be performed past this revision on this branch
                self.ref_locks[branch] = self.replica_project['ref-locks'][
                    branch]