コード例 #1
0
def handle_merge_failed(revstart, revend, current_branch_name,
                        next_branch_name, message, author, rev_as_str,
                        commit_merge_result):
    mergeconf.LOGGER.debug('merge failed')
    try:
        mailutils.mail(
            mergeconf.get_dl(author, mergeconf.ENUM_MERGE),
            get_failed_mergecommit_subject(current_branch_name,
                                           next_branch_name, author,
                                           rev_as_str),
            get_failed_mergecommit_text(current_branch_name, next_branch_name,
                                        message, author, rev_as_str,
                                        commit_merge_result),
            mergeconf.MAIL_ENABLED)
    except:
        LOGGER.error(
            "Please check mail configuration, failed sending email...")
    audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name,
                revstart, revend, NA, NA, AUDIT_RES_FAILED_CONFLICT)
    add_row(
        {
            mergeconf.TYPE_COL: SPREADSHEET_MERGE_FAILED,
            'who': SPREADSHEET_AUTHOR_PREFIX + author,
            'frombranch': current_branch_name,
            'tobranch': next_branch_name,
            'rfrom': revstart,
            'rend': revend,
            'rcommit': NA,
            'bugid': mergeconf.ISSUE_ID_DEFAULT_VALUE,
            'details': SPREADSHEET_CONFLICT_MSG
        }, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD,
        mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID,
        mergeconf.APP_KEY)
コード例 #2
0
def handle_success_merge(revstart, revend, current_branch_name,
                         next_branch_name, message, author, rev_as_str,
                         commit_message, commit_merge_result):
    audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name,
                revstart, revend, NA, NA, CSV_STATUS_MERGE_SUCCESS)
    rcommit = get_commit_rev_by_resp(commit_merge_result)
    try:
        mailutils.mail(
            mergeconf.get_dl(author, mergeconf.ENUM_MERGE),
            get_merge_success_subject(current_branch_name, next_branch_name,
                                      author, rev_as_str),
            get_merge_success_text(current_branch_name, next_branch_name,
                                   message, author, rev_as_str,
                                   commit_merge_result),
            mergeconf.MAIL_ENABLED)
    except:
        LOGGER.error(
            "Please check mail configuration, failed sending email...")
    add_row(
        {
            mergeconf.TYPE_COL: SPREADSHEET_MERGE,
            'who': SPREADSHEET_AUTHOR_PREFIX + author,
            'frombranch': current_branch_name,
            'tobranch': next_branch_name,
            'rfrom': revstart,
            'rend': revend,
            'rcommit': rcommit,
            'bugid': mergeconf.ISSUE_ID_DEFAULT_VALUE,
            'details': commit_message
        }, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD,
        mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID,
        mergeconf.APP_KEY)
コード例 #3
0
def handle_success_merge(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_message, commit_merge_result):
    audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name, revstart, revend, NA, NA, CSV_STATUS_MERGE_SUCCESS)
    rcommit = get_commit_rev_by_resp(commit_merge_result)
    try:
        mailutils.mail(mergeconf.get_dl(author, mergeconf.ENUM_MERGE), get_merge_success_subject(current_branch_name, next_branch_name, author, rev_as_str), get_merge_success_text(current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result), mergeconf.MAIL_ENABLED)
    except:
        LOGGER.error("Please check mail configuration, failed sending email...")
    add_row({mergeconf.TYPE_COL:SPREADSHEET_MERGE, 'who':SPREADSHEET_AUTHOR_PREFIX + author, 'frombranch':current_branch_name, 'tobranch':next_branch_name, 'rfrom':revstart, 'rend':revend, 'rcommit':rcommit, 'bugid':mergeconf.ISSUE_ID_DEFAULT_VALUE, 'details':commit_message}, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD, mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID, mergeconf.APP_KEY)
コード例 #4
0
def handle_merge_failed(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result):
    mergeconf.LOGGER.debug('merge failed')
    try:
        mailutils.mail(mergeconf.get_dl(author, mergeconf.ENUM_MERGE), get_failed_mergecommit_subject(current_branch_name, next_branch_name, author, rev_as_str), get_failed_mergecommit_text(current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result), mergeconf.MAIL_ENABLED)
    except:
        LOGGER.error("Please check mail configuration, failed sending email...")
    audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name, revstart, revend, NA, NA, AUDIT_RES_FAILED_CONFLICT)
    add_row({mergeconf.TYPE_COL:SPREADSHEET_MERGE_FAILED, 'who':SPREADSHEET_AUTHOR_PREFIX + author, 'frombranch':current_branch_name, 'tobranch':next_branch_name, 'rfrom':revstart, 'rend':revend, 'rcommit':NA, 'bugid':mergeconf.ISSUE_ID_DEFAULT_VALUE, 'details':SPREADSHEET_CONFLICT_MSG}, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD, mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID, mergeconf.APP_KEY)
コード例 #5
0
    def do_merge(self, merge_item):
        """
            This is the main handler for merges.
            This method recieves some details from the commit
            it checks if we need to do a merge, to which branch
            deduces the merge message, sends emails, and
            actually performs the merge.
            Args:
                REPO: Repository on which the original commit was perforemd.
                revstart: The revision that was originally committed from it the 
                    merge was performed.
                is_manual: Manual - A merge through a web interface,
                    Automatic means an auto merge.
                revend: In case of multiple revisions to perform commit to
                    (relevant in manual merge only).
                source_branch: The originating branch for this potential merge.
                svn_username: The username to use in order to perform the commit after merge.
                svn_password: The password to use while committing the merge.
            Returns:
                Result: performing the merge.
        """

        try:
            log_prefix_desc(merge_item)
            merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_LOOK_RESULT] = deduce_current_branch(merge_item) 
            if not is_relevant_branch(merge_item[KEY_REV_START], merge_item[KEY_CURRENT_BRANCH]): 
                return

            mergeconf.LOGGER.debug('current_branch: ' + merge_item[KEY_CURRENT_BRANCH])
            merge_item[KEY_NEXT_BRANCH] = branchutils.get_next_branch(merge_item[KEY_LOOK_RESULT], mergeconf.BRANCHES_MAP)

            if not is_next_branch_relevant(merge_item[KEY_REV_START], merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH]): 
                return

            merge_item[KEY_CURRENT_BRANCH_URL] = branchutils.get_branch_url(merge_item[KEY_CURRENT_BRANCH])
            merge_item[KEY_NEXT_BRANCH_URL] = branchutils.get_branch_url(merge_item[KEY_NEXT_BRANCH])
            mergeconf.LOGGER.debug ('result: %s' % merge_item[KEY_LOOK_RESULT])
            merge_item[KEY_MESSAGE] = svnutils.get_commit_log_message(merge_item[KEY_REPO], merge_item[KEY_REV_START])
            merge_item[KEY_AUTHOR] = get_author(merge_item[KEY_REV_START], merge_item[KEY_REPO], merge_item[KEY_MESSAGE])
            merge_item[KEY_FILES_TO_IGNORE] = mergeconf.FILES_TO_IGNORE
            merge_item[KEY_AUTHORS_TO_IGNORE] = mergeconf.AUTHORS_TO_IGNORE

            if not branchutils.handle_merge_conditions(merge_item):
                return
            merge_to_branch = checkout_target_branch(merge_item[KEY_NEXT_BRANCH], merge_item[KEY_NEXT_BRANCH_URL], self.svn_utils)
            rev_as_str = self.svn_utils.merge_to_branch(merge_item[mergeconf.KEY_REV_START], merge_item.get(mergeconf.KEY_REV_END, None), merge_item[KEY_CURRENT_BRANCH_URL], merge_to_branch)
            self.commit_merged_code(merge_item[mergeconf.KEY_REV_START], merge_item.get(mergeconf.KEY_REV_END, None), merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH], merge_item[KEY_MESSAGE] + '\n' + merge_item[KEY_LOOK_RESULT], merge_item[KEY_AUTHOR],
                                    merge_to_branch, rev_as_str)
        except:
            mergeconf.LOGGER.exception("failed performing merge please see further details")
            audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR], merge_item[KEY_CURRENT_BRANCH],
                        merge_item[KEY_NEXT_BRANCH], merge_item[mergeconf.KEY_REV_START], merge_item[mergeconf.KEY_REV_START],
                        NA, NA, AUDIT_EXPL_EXCEPTION)
コード例 #6
0
def is_next_branch_relevant(commitrev, current_branch, next_branch):
    """
        Check if the branch to merge into is relevant, and we should merge into it.
        Args:
            commitrev: The revision which commit was done,
                used for auditing.
            current_branch: The current branch name (commit has been performed to this branch).
            next_branch: The branch we potentially will merge into.
        Returns:
            True if next branch is relevant for merges, False if not.
    """
    is_relevant = True
    if not next_branch:
        audit_write(AUDIT_OP_MERGE, NA, current_branch, NA, commitrev, commitrev, NA, NA, AUDIT_RES_NO_NEXT_BRANCH)
        mergeconf.LOGGER.debug('No next branch to: ' + current_branch + ' to merge into')
        is_relevant = False
    return is_relevant
コード例 #7
0
def is_relevant_branch(commitrev, branch_name):
    """
        Check if the branch is in our merger.conf at all.  If not then we 
        are not going to deal with it.
        Args:
            commitrev: The revision which commit was done,
                used for auditing.
            branch_name: The branch to check if relevant for auto merges or not.
        Returns:
            True if branch is relevant for merges, False if not.
    """
    is_relevant = True
    if not branch_name:
        audit_write(AUDIT_OP_MERGE, NA, branch_name, NA, commitrev, commitrev, NA, NA,
                    AUDIT_RES_BRANCH_NOT_INF_CONF)
        mergeconf.LOGGER.debug('Branch changed is not in list of branches to auto merge')
        is_relevant = False
    return is_relevant
コード例 #8
0
def is_next_branch_relevant(commitrev, current_branch, next_branch):
    """
        Check if the branch to merge into is relevant, and we should merge into it.
        Args:
            commitrev: The revision which commit was done,
                used for auditing.
            current_branch: The current branch name (commit has been performed to this branch).
            next_branch: The branch we potentially will merge into.
        Returns:
            True if next branch is relevant for merges, False if not.
    """
    is_relevant = True
    if not next_branch:
        audit_write(AUDIT_OP_MERGE, NA, current_branch, NA, commitrev,
                    commitrev, NA, NA, AUDIT_RES_NO_NEXT_BRANCH)
        mergeconf.LOGGER.debug('No next branch to: ' + current_branch +
                               ' to merge into')
        is_relevant = False
    return is_relevant
コード例 #9
0
def is_relevant_branch(commitrev, branch_name):
    """
        Check if the branch is in our merger.conf at all.  If not then we 
        are not going to deal with it.
        Args:
            commitrev: The revision which commit was done,
                used for auditing.
            branch_name: The branch to check if relevant for auto merges or not.
        Returns:
            True if branch is relevant for merges, False if not.
    """
    is_relevant = True
    if not branch_name:
        audit_write(AUDIT_OP_MERGE, NA, branch_name, NA, commitrev, commitrev,
                    NA, NA, AUDIT_RES_BRANCH_NOT_INF_CONF)
        mergeconf.LOGGER.debug(
            'Branch changed is not in list of branches to auto merge')
        is_relevant = False
    return is_relevant
コード例 #10
0
    def do_merge(self, merge_item):
        """
            This is the main handler for merges.
            This method recieves some details from the commit
            it checks if we need to do a merge, to which branch
            deduces the merge message, sends emails, and
            actually performs the merge.
            Args:
                REPO: Repository on which the original commit was perforemd.
                revstart: The revision that was originally committed from it the 
                    merge was performed.
                is_manual: Manual - A merge through a web interface,
                    Automatic means an auto merge.
                revend: In case of multiple revisions to perform commit to
                    (relevant in manual merge only).
                source_branch: The originating branch for this potential merge.
                svn_username: The username to use in order to perform the commit after merge.
                svn_password: The password to use while committing the merge.
            Returns:
                Result: performing the merge.
        """

        try:
            log_prefix_desc(merge_item)
            merge_item[KEY_CURRENT_BRANCH], merge_item[
                KEY_LOOK_RESULT] = deduce_current_branch(merge_item)
            if not is_relevant_branch(merge_item[KEY_REV_START],
                                      merge_item[KEY_CURRENT_BRANCH]):
                return

            mergeconf.LOGGER.debug('current_branch: ' +
                                   merge_item[KEY_CURRENT_BRANCH])
            merge_item[KEY_NEXT_BRANCH] = branchutils.get_next_branch(
                merge_item[KEY_LOOK_RESULT], mergeconf.BRANCHES_MAP)

            if not is_next_branch_relevant(merge_item[KEY_REV_START],
                                           merge_item[KEY_CURRENT_BRANCH],
                                           merge_item[KEY_NEXT_BRANCH]):
                return

            merge_item[KEY_CURRENT_BRANCH_URL] = branchutils.get_branch_url(
                merge_item[KEY_CURRENT_BRANCH])
            merge_item[KEY_NEXT_BRANCH_URL] = branchutils.get_branch_url(
                merge_item[KEY_NEXT_BRANCH])
            mergeconf.LOGGER.debug('result: %s' % merge_item[KEY_LOOK_RESULT])
            merge_item[KEY_MESSAGE] = svnutils.get_commit_log_message(
                merge_item[KEY_REPO], merge_item[KEY_REV_START])
            merge_item[KEY_AUTHOR] = get_author(merge_item[KEY_REV_START],
                                                merge_item[KEY_REPO],
                                                merge_item[KEY_MESSAGE])
            merge_item[KEY_FILES_TO_IGNORE] = mergeconf.FILES_TO_IGNORE
            merge_item[KEY_AUTHORS_TO_IGNORE] = mergeconf.AUTHORS_TO_IGNORE

            if not branchutils.handle_merge_conditions(merge_item):
                return
            merge_to_branch = checkout_target_branch(
                merge_item[KEY_NEXT_BRANCH], merge_item[KEY_NEXT_BRANCH_URL],
                self.svn_utils)
            rev_as_str = self.svn_utils.merge_to_branch(
                merge_item[mergeconf.KEY_REV_START],
                merge_item.get(mergeconf.KEY_REV_END, None),
                merge_item[KEY_CURRENT_BRANCH_URL], merge_to_branch)
            self.commit_merged_code(
                merge_item[mergeconf.KEY_REV_START],
                merge_item.get(mergeconf.KEY_REV_END, None),
                merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH],
                merge_item[KEY_MESSAGE] + '\n' + merge_item[KEY_LOOK_RESULT],
                merge_item[KEY_AUTHOR], merge_to_branch, rev_as_str)
        except:
            mergeconf.LOGGER.exception(
                "failed performing merge please see further details")
            audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR],
                        merge_item[KEY_CURRENT_BRANCH],
                        merge_item[KEY_NEXT_BRANCH],
                        merge_item[mergeconf.KEY_REV_START],
                        merge_item[mergeconf.KEY_REV_START], NA, NA,
                        AUDIT_EXPL_EXCEPTION)