예제 #1
0
 def mirrorFailed(self, branch_id, reason):
     branch = self._branch_set.get(branch_id)
     if branch is None:
         return faults.NoBranchWithID(branch_id)
     branch.mirror_failures += 1
     branch.mirror_status_message = reason
     return True
예제 #2
0
 def mirrorFailed(self, branch_id, reason):
     """See `ICodehostingAPI`."""
     branch = getUtility(IBranchLookup).get(branch_id)
     if branch is None:
         return faults.NoBranchWithID(branch_id)
     # The puller runs as no user and may pull private branches. We need to
     # bypass Zope's security proxy to set the mirroring information.
     removeSecurityProxy(branch).mirrorFailed(reason)
     return True
예제 #3
0
        def branch_changed(requester):
            branch_set = getUtility(IBranchLookup)
            branch = branch_set.get(branch_id)
            if branch is None:
                return faults.NoBranchWithID(branch_id)

            if requester == LAUNCHPAD_SERVICES:
                branch = removeSecurityProxy(branch)

            info = get_db_branch_info(stacked_on_location, last_revision_id,
                                      control_string, branch_string,
                                      repository_string)
            branch.branchChanged(**info)

            return True
예제 #4
0
    def branchChanged(self, login_id, branch_id, stacked_on_location,
                      last_revision_id, control_string, branch_string,
                      repository_string):
        branch = self._branch_set._find(id=branch_id)
        if branch is None:
            return faults.NoBranchWithID(branch_id)
        branch.mirror_status_message = None
        if stacked_on_location == '':
            stacked_on_branch = None
        else:
            # We could log or something if the branch is not found here, but
            # we just wait until the scanner fails and sets up an appropriate
            # message.
            stacked_on_branch = self._branch_set._find(
                unique_name=stacked_on_location.strip('/'))
            if stacked_on_branch is None:
                branch.mirror_status_message = (
                    'Invalid stacked on location: ' + stacked_on_location)
        branch.stacked_on = stacked_on_branch
        branch.last_mirrored = UTC_NOW
        if branch.last_mirrored_id != last_revision_id:
            branch.last_mirrored_id = last_revision_id

        def match_title(enum, title, default):
            for value in enum.items:
                if value.title == title:
                    return value
            else:
                return default

        branch.control_format = match_title(
            ControlFormat, control_string, ControlFormat.UNRECOGNIZED)
        branch.branch_format = match_title(
            BranchFormat, branch_string, BranchFormat.UNRECOGNIZED)
        branch.repository_format = match_title(
            RepositoryFormat, repository_string,
            RepositoryFormat.UNRECOGNIZED)

        return True