Exemple #1
0
def produce_merge(repository, revision):
    """
       This method is called after a user commits to svn repository.
       We get here the repository and revision that was committed.
       We write here to the audit file PRODUCED which means a commit was made.
       Call the server to provide it with information about commit which
       was performed, and let the server continue handling this commit.
       
       Args:
        argv[1]: From post commit hook the repository on which commit was made. 
        argv[2]: From post commit hook the revision number assigned to commit performed.
       
       Returns:
         Result: updates csv audit with commit performed and calls server to treat that merge.
    """
    LOGGER.debug('auto merger %s ' % (mergeconf.VERSION))

    lookcmd = LOOK_CHANGED_TMPL % (revision, repository)
    LOGGER.debug('lookcmd: ' + lookcmd)
    result = mergeconf.M_SHU.runshellcmd(lookcmd)
    LOGGER.debug('result: ' + result)
    current_branch_name = svnutils.get_branch_by_look(result,
                                                      mergeconf.BRANCHES_MAP)

    # If the branch for which a commit just happended is not relevant to our branches.
    if not current_branch_name:
        LOGGER.debug(
            'produce_merge: current_branch_name:' + current_branch_name +
            ', Branch changed is not in list of branches to auto merge')
        write_merge_produced(revision, current_branch_name, repository,
                             mergeconf.CSV_STATUS_MERGE_IGNORED)
        return

    params = urllib.urlencode({
        mergeconf.KEY_REV_START: revision,
        mergeconf.KEY_REPO: repository
    })
    try:
        url = mergeconf.MERGE_SERVER_URL % params
        LOGGER.debug(url)
        f = urllib.urlopen(mergeconf.MERGE_SERVER_URL % params)
        write_merge_produced(revision, current_branch_name, repository,
                             mergeconf.CSV_STATUS_MERGE_PRODUCED)
        LOGGER.debug(f.read())
    except:
        write_merge_produced(revision, current_branch_name, repository,
                             mergeconf.CSV_STATUS_MERGE_FAILED)
        mergeconf.LOGGER.exception("exception occured")
def deduce_current_branch(merge_item):
    """
        Extract branch directory to do local temporal work form branch name.
        For example if we have multiple projects which have the same ending
        branch name projecta/1.0, projectb/1.0 then store the folders as
        projecta_1.0 and projectb_1.0 for temporal work folder for merging.
        
        Args:
            branch_name: The branch name to compute the branch working folder.
        Returns:
            Working branch dir on disk.
    """
    lookcmd = svnutils.LOOK_CHANGED_TMPL % (merge_item[KEY_REV_START], merge_item[KEY_REPO])
    lookresult = M_SHU.runshellcmd(lookcmd)
    mergeconf.LOGGER.debug('result: ' + lookresult)
    if merge_item.get(KEY_SOURCE_BRANCH_NAME, None) is None:
        current_branch = get_branch_by_look(lookresult, mergeconf.BRANCHES_MAP)
    else:
        current_branch = merge_item.get(mergeconf.KEY_SOURCE_BRANCH_NAME, None)
    return current_branch, lookresult
def deduce_current_branch(merge_item):
    """
        Extract branch directory to do local temporal work form branch name.
        For example if we have multiple projects which have the same ending
        branch name projecta/1.0, projectb/1.0 then store the folders as
        projecta_1.0 and projectb_1.0 for temporal work folder for merging.
        
        Args:
            branch_name: The branch name to compute the branch working folder.
        Returns:
            Working branch dir on disk.
    """
    lookcmd = svnutils.LOOK_CHANGED_TMPL % (merge_item[KEY_REV_START],
                                            merge_item[KEY_REPO])
    lookresult = M_SHU.runshellcmd(lookcmd)
    mergeconf.LOGGER.debug('result: ' + lookresult)
    if merge_item.get(KEY_SOURCE_BRANCH_NAME, None) is None:
        current_branch = get_branch_by_look(lookresult, mergeconf.BRANCHES_MAP)
    else:
        current_branch = merge_item.get(mergeconf.KEY_SOURCE_BRANCH_NAME, None)
    return current_branch, lookresult
def produce_merge(repository, revision):
    """
       This method is called after a user commits to svn repository.
       We get here the repository and revision that was committed.
       We write here to the audit file PRODUCED which means a commit was made.
       Call the server to provide it with information about commit which
       was performed, and let the server continue handling this commit.
       
       Args:
        argv[1]: From post commit hook the repository on which commit was made. 
        argv[2]: From post commit hook the revision number assigned to commit performed.
       
       Returns:
         Result: updates csv audit with commit performed and calls server to treat that merge.
    """
    LOGGER.debug('auto merger %s ' % (mergeconf.VERSION))

    lookcmd = LOOK_CHANGED_TMPL % (revision,repository)
    LOGGER.debug('lookcmd: ' + lookcmd)
    result = mergeconf.M_SHU.runshellcmd(lookcmd)
    LOGGER.debug('result: ' + result)
    current_branch_name = svnutils.get_branch_by_look(result, mergeconf.BRANCHES_MAP)
    
    
    # If the branch for which a commit just happended is not relevant to our branches.
    if not current_branch_name:
        LOGGER.debug('Branch changed is not in list of branches to auto merge')
        write_merge_produced(revision, current_branch_name, repository, mergeconf.CSV_STATUS_MERGE_IGNORED)
        return
    
    params = urllib.urlencode({mergeconf.KEY_REV_START: revision, mergeconf.KEY_REPO: repository})
    try:
        url = mergeconf.MERGE_SERVER_URL % params
        LOGGER.debug(url)
        f = urllib.urlopen(mergeconf.MERGE_SERVER_URL % params)
        write_merge_produced(revision, current_branch_name, repository, mergeconf.CSV_STATUS_MERGE_PRODUCED)
        LOGGER.debug(f.read())
    except:
        write_merge_produced(revision, current_branch_name, repository, mergeconf.CSV_STATUS_MERGE_FAILED)
        mergeconf.LOGGER.exception("exception occured")