Beispiel #1
0
 def checkout(self, url, tolocation):
     """Given a branch url check it out to the local disk.
         
         Args:
             url: The branch to check out.
             tolocation: Location on disk to check out to.
             svn_username: Auto merging will use this svn username to perform the checkout.
             svn_password: Auto merging will use this svn password to perform the checkout.
         Returns:
             Nothing, the branch specified in url will be checked out to local disk.
     """
     checkout_cmd = CO_TMPL % (url, TMPDIR, tolocation + '/', self.username, self.password)
     M_SHU.runshellcmd(checkout_cmd) # branch to merge to does not exist in disk, check it out from svn.
def get_author(rev, repo, message):
    """
        Extract the author from commit log or look command. 
        We do look only at some cases only on rev and not
        on all revisions which committed under the assumption its going to have
        (ofcourse) the same author.
        
        Args:
            rev: Revision that was comitted which mergeworker handles. 
            repo: rev, revision of commit to check the commit log message.
            message: Commit log message we might extract from there the original
                author as the auto merger merges with his own user and not
                the original committer.
            
        Returns:
            The name of the committer we we perform the merge for.
    """
    if (message and message.find(ORIG_AUTHOR) != -1):
        message = message.replace('\r', '')
        orig_authors = re.compile(r"^orig_author: (.*?)$", re.MULTILINE).search(message).groups()
        author = orig_authors[0] if orig_authors else None
        mergeconf.LOGGER.debug ('author is: %s ' % author)
    else:
        svnlook_getauthor_cmd = svnutils.LOOK_AUTH_TMPL % (rev, repo)
        mergeconf.LOGGER.debug ('get author version control command: %s ' % svnlook_getauthor_cmd)
        author = M_SHU.runshellcmd(svnlook_getauthor_cmd).rstrip()
    return author
Beispiel #3
0
 def merge_to_branch(self,
                     revstart,
                     revend=None,
                     merge_from_url=None,
                     merge_to_branch=None):
     """Given a branch url merge it into a local branch.
         
         Args:
             merge_from_url: The url to merge from.
             merge_to_branch: The branch to merge to.
             revstart: Rev to merge from.
             revend: If not specified only revstart is merged otherwise merging a range of revisions.
             svn_username: Auto merging will use this svn username to perform the merge.
             svn_password: Auto merging will use this svn password to perform the merge.
         Returns:
             Nothing, The branch will be synced on disk.
     """
     mergeconf.LOGGER.debug('\nMerging...')
     prev_rev = int(
         revstart
     ) - 1  # In svn when merging single revision then merging from merge_rev - 1 to merge_rev
     prev_rev_as_str = str(prev_rev)
     if revend is None:
         rev_as_str = str(revstart)
     else:
         rev_as_str = str(revend)
     svn_merge_cmd = MERGE_TMPL % (
         prev_rev_as_str, rev_as_str, merge_from_url, TMPDIR,
         get_branch_dir(merge_to_branch), self.username, self.password)
     mergeconf.LOGGER.debug('merge cmd: : ' + svn_merge_cmd)
     merge_result = M_SHU.runshellcmd(svn_merge_cmd)
     mergeconf.LOGGER.debug('merge result:' + merge_result)
     mergeconf.LOGGER.debug('merge cmd: : ' + svn_merge_cmd)
     return rev_as_str
Beispiel #4
0
 def checkout(self, url, tolocation):
     """Given a branch url check it out to the local disk.
         
         Args:
             url: The branch to check out.
             tolocation: Location on disk to check out to.
             svn_username: Auto merging will use this svn username to perform the checkout.
             svn_password: Auto merging will use this svn password to perform the checkout.
         Returns:
             Nothing, the branch specified in url will be checked out to local disk.
     """
     checkout_cmd = CO_TMPL % (url, TMPDIR, tolocation + '/', self.username,
                               self.password)
     M_SHU.runshellcmd(
         checkout_cmd
     )  # branch to merge to does not exist in disk, check it out from svn.
def get_author(rev, repo, message):
    """
        Extract the author from commit log or look command. 
        We do look only at some cases only on rev and not
        on all revisions which committed under the assumption its going to have
        (ofcourse) the same author.
        
        Args:
            rev: Revision that was comitted which mergeworker handles. 
            repo: rev, revision of commit to check the commit log message.
            message: Commit log message we might extract from there the original
                author as the auto merger merges with his own user and not
                the original committer.
            
        Returns:
            The name of the committer we we perform the merge for.
    """
    if (message and message.find(ORIG_AUTHOR) != -1):
        message = message.replace('\r', '')
        orig_authors = re.compile(r"^orig_author: (.*?)$",
                                  re.MULTILINE).search(message).groups()
        author = orig_authors[0] if orig_authors else None
        mergeconf.LOGGER.debug('author is: %s ' % author)
    else:
        svnlook_getauthor_cmd = svnutils.LOOK_AUTH_TMPL % (rev, repo)
        mergeconf.LOGGER.debug('get author version control command: %s ' %
                               svnlook_getauthor_cmd)
        author = M_SHU.runshellcmd(svnlook_getauthor_cmd).rstrip()
    return author
Beispiel #6
0
 def merge_to_branch(self, revstart, revend=None, merge_from_url=None,
                     merge_to_branch=None):
     """Given a branch url merge it into a local branch.
         
         Args:
             merge_from_url: The url to merge from.
             merge_to_branch: The branch to merge to.
             revstart: Rev to merge from.
             revend: If not specified only revstart is merged otherwise merging a range of revisions.
             svn_username: Auto merging will use this svn username to perform the merge.
             svn_password: Auto merging will use this svn password to perform the merge.
         Returns:
             Nothing, The branch will be synced on disk.
     """
     mergeconf.LOGGER.debug('\nMerging...')
     prev_rev = int(revstart) - 1 # In svn when merging single revision then merging from merge_rev - 1 to merge_rev
     prev_rev_as_str = str(prev_rev)
     if revend is None:
         rev_as_str = str(revstart)
     else:
         rev_as_str = str(revend)
     svn_merge_cmd = MERGE_TMPL % (prev_rev_as_str, rev_as_str, merge_from_url, TMPDIR, get_branch_dir
             (merge_to_branch), self.username, self.password)
     mergeconf.LOGGER.debug('merge cmd: : ' + svn_merge_cmd)
     merge_result = M_SHU.runshellcmd(svn_merge_cmd)
     mergeconf.LOGGER.debug('merge result:' + merge_result)
     mergeconf.LOGGER.debug('merge cmd: : ' + svn_merge_cmd)
     return rev_as_str
Beispiel #7
0
 def does_url_exist(self,url):
     mergeconf.LOGGER.debug('does_url_exist; url:'+ url)
     svn_info_cmd = INFO_TMPL % (url, self.username, self.password)
     mergeconf.LOGGER.debug('does_url_exist; svn_info_cmd:' + svn_info_cmd)
     info_result  = M_SHU.runshellcmd(svn_info_cmd)
     mergeconf.LOGGER.debug('does_url_exist; info_result:' + info_result)
     return info_result.find(MESSAGE_URL_DOES_NOT_EXIST) == -1
Beispiel #8
0
 def log(self, url, startdate, enddate, isxml=False, stoponcopy=False):
     """
     Run svn log commmand.
     """
     logcommand = LOG_URL_TMP % (url, '{' + startdate + '}', '{' + enddate + '}', self.username, self.password, 
                                 ' --xml' if isxml else '', ' --stop-on-copy' if stoponcopy else '')
     logging.info(logcommand)
     return M_SHU.runshellcmd(logcommand)
Beispiel #9
0
 def log(self, url, startdate, enddate, isxml=False, stoponcopy=False):
     """
     Run svn log commmand.
     """
     logcommand = LOG_URL_TMP % (url, '{' + startdate + '}',
                                 '{' + enddate + '}', self.username,
                                 self.password, ' --xml' if isxml else '',
                                 ' --stop-on-copy' if stoponcopy else '')
     logging.info(logcommand)
     return M_SHU.runshellcmd(logcommand)
Beispiel #10
0
 def get_log_message(self, url, rev):
     """
     Get commit log message by url and revision
     Arguments:
         url: Url to get commit log message for.
         rev: Revision to get the commit log message for the url above.
     Returns: 
         The message which was committed on revision rev on url specified.
     """
     mergeconf.LOGGER.debug("Commit log message for url [%s] with rev [%s]" % (url, rev))
     log_cmd = (LOG_URL_TMP % (url, rev, rev, self.username, self.password))
     return M_SHU.runshellcmd(log_cmd)
Beispiel #11
0
 def get_log_message(self, url, rev):
     """
     Get commit log message by url and revision
     Arguments:
         url: Url to get commit log message for.
         rev: Revision to get the commit log message for the url above.
     Returns: 
         The message which was committed on revision rev on url specified.
     """
     mergeconf.LOGGER.debug(
         "Commit log message for url [%s] with rev [%s]" % (url, rev))
     log_cmd = (LOG_URL_TMP % (url, rev, rev, self.username, self.password))
     return M_SHU.runshellcmd(log_cmd)
Beispiel #12
0
def get_commit_log_message(repo, rev):
    """
        Here we compute the commit log message after merge.
        In this commit log message we will include details about
        the merge that was performed, who was original committer etc.
        Args:
            repo: Repository on which the original commit was perforemd.
            rev: The revision that was originally committed from it the 
                merge was performed.
        Returns:
            The message which will be provided to the commit.
    """
    svnlook_log_cmd = LOOK_LOG_TMPL % (rev, repo)
    mergeconf.LOGGER.debug('svn look log command: %s ' % svnlook_log_cmd)
    message = M_SHU.runshellcmd(svnlook_log_cmd)
    mergeconf.LOGGER.debug('log result: %s ' % message)
    return message
Beispiel #13
0
def get_commit_log_message(repo, rev):
    """
        Here we compute the commit log message after merge.
        In this commit log message we will include details about
        the merge that was performed, who was original committer etc.
        Args:
            repo: Repository on which the original commit was perforemd.
            rev: The revision that was originally committed from it the 
                merge was performed.
        Returns:
            The message which will be provided to the commit.
    """
    svnlook_log_cmd = LOOK_LOG_TMPL % (rev, repo)
    mergeconf.LOGGER.debug('svn look log command: %s ' % svnlook_log_cmd)
    message = M_SHU.runshellcmd(svnlook_log_cmd)
    mergeconf.LOGGER.debug('log result: %s ' % message)
    return message
Beispiel #14
0
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
Beispiel #16
0
 def update_local_workbranch(self, branch_dir):
     """Does everything it can to verify the current 
         working branch which is being used for merges is updated 
         and synced with svn so we can perform the merge 
         on this local branch.
         
         Args:
             merge_to_branch: The branch name we want to merge a commit into.
             user: Auto merging will use this svn username to perform the merge.
             pass: Auto merging will use this svn password to perform the merge.
         Returns:
             Nothing, local working branch will be updated in order to perform the auto merge.
     """
     M_SHU.runshellcmd(CLEANUP_TMPL % (TMPDIR, branch_dir, self.username, self.password))
     M_SHU.runshellcmd(REVERT_TMPL % (TMPDIR, branch_dir, self.username, self.password))
     M_SHU.runshellcmd(UPDATE_TMPL % (TMPDIR, branch_dir, self.username, self.password))
Beispiel #17
0
 def update_local_workbranch(self, branch_dir):
     """Does everything it can to verify the current 
         working branch which is being used for merges is updated 
         and synced with svn so we can perform the merge 
         on this local branch.
         
         Args:
             merge_to_branch: The branch name we want to merge a commit into.
             user: Auto merging will use this svn username to perform the merge.
             pass: Auto merging will use this svn password to perform the merge.
         Returns:
             Nothing, local working branch will be updated in order to perform the auto merge.
     """
     M_SHU.runshellcmd(CLEANUP_TMPL %
                       (TMPDIR, branch_dir, self.username, self.password))
     M_SHU.runshellcmd(REVERT_TMPL %
                       (TMPDIR, branch_dir, self.username, self.password))
     M_SHU.runshellcmd(UPDATE_TMPL %
                       (TMPDIR, branch_dir, self.username, self.password))