def checkout_target_branch(branch_name, branch_url, svnutilsobj): """Given a branch url make sure it is synced with REPO on local disk (either checkout if does not exist yet on disk or update if already exist. Args: branch_url: The branch to sync (svn url). branch_name: The branch name to sync (will be used as its location on disk - folder name). Returns: Nothing, The branch will be synced on disk. """ if os.path.isdir('%s/%s' % (TMPDIR, svnutils.get_branch_dir(branch_name))): # branch exists update it. svnutilsobj.update_local_workbranch(svnutils.get_branch_dir(branch_name)) else: svnutilsobj.checkout(branch_url, svnutils.get_branch_dir(branch_name)) return branch_name
def commit_merged_code(self, revstart, revend, current_branch_name, next_branch_name, message, author, merge_to_branch, rev_as_str): """When you have a branch which is merged this method will commit it. Args: revstart: The starting revision which was applied as a merge, used mainly for auditing. revend: The ending revision which was applied as a merge, used mainly for auditing.. current_branch_name: The branch which the merge was performed from, used mainly for auditing. next_branch_name: The branch which the merge was performed to, used mainly for auditing. message: Commit message. author: When committing code will add the author name to description so we can keep trac of who was original committer. merge_to_branch: The branch the merge was performed for, this is the actual directory name we do the commit to. Returns: Nothing, The local branch is being committed. """ if revend is None: revend = revstart mergeconf.LOGGER.debug('Committing merged code...') commit_message = mergeconf.ISSUE_ID_NAME + ': ' + mergeconf.ISSUE_ID_DEFAULT_VALUE + '\n' + mergeconf.CODEREVIEW_NAME + \ ': ' + NA + '\n' + ORIG_AUTHOR + ': ' + author + '\n' + ORIG_MESSAGE + ': ' + message commit_merge_result = self.svn_utils.commit(TMPDIR + '/' + svnutils.get_branch_dir(merge_to_branch), commit_message, revstart) mergeconf.LOGGER.debug('is aborting found? ' + str(commit_merge_result.find(MESSAGE_ABORT_COMMIT))) if (commit_merge_result.find(MESSAGE_SUCCESSFUL_COMMIT) == -1): handle_merge_failed(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result) else: handle_success_merge(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_message, commit_merge_result) return True
def checkout_target_branch(branch_name, branch_url, svnutilsobj): """Given a branch url make sure it is synced with REPO on local disk (either checkout if does not exist yet on disk or update if already exist. Args: branch_url: The branch to sync (svn url). branch_name: The branch name to sync (will be used as its location on disk - folder name). Returns: Nothing, The branch will be synced on disk. """ if os.path.isdir( '%s/%s' % (TMPDIR, svnutils.get_branch_dir(branch_name))): # branch exists update it. svnutilsobj.update_local_workbranch( svnutils.get_branch_dir(branch_name)) else: svnutilsobj.checkout(branch_url, svnutils.get_branch_dir(branch_name)) return branch_name
def commit_merged_code(self, revstart, revend, current_branch_name, next_branch_name, message, author, merge_to_branch, rev_as_str): """When you have a branch which is merged this method will commit it. Args: revstart: The starting revision which was applied as a merge, used mainly for auditing. revend: The ending revision which was applied as a merge, used mainly for auditing.. current_branch_name: The branch which the merge was performed from, used mainly for auditing. next_branch_name: The branch which the merge was performed to, used mainly for auditing. message: Commit message. author: When committing code will add the author name to description so we can keep trac of who was original committer. merge_to_branch: The branch the merge was performed for, this is the actual directory name we do the commit to. Returns: Nothing, The local branch is being committed. """ if revend is None: revend = revstart mergeconf.LOGGER.debug('Committing merged code...') commit_message = mergeconf.ISSUE_ID_NAME + ': ' + mergeconf.ISSUE_ID_DEFAULT_VALUE + '\n' + mergeconf.CODEREVIEW_NAME + \ ': ' + NA + '\n' + ORIG_AUTHOR + ': ' + author + '\n' + ORIG_MESSAGE + ': ' + message commit_merge_result = self.svn_utils.commit( TMPDIR + '/' + svnutils.get_branch_dir(merge_to_branch), commit_message, revstart) mergeconf.LOGGER.debug( 'is aborting found? ' + str(commit_merge_result.find(MESSAGE_ABORT_COMMIT))) if (commit_merge_result.find(MESSAGE_SUCCESSFUL_COMMIT) == -1): handle_merge_failed(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result) else: handle_success_merge(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_message, commit_merge_result) return True