#NEWLINE# @ log_prefix ( '[git-bloom-patch remove]: ' ) #NEWLINE# def remove_patches( directory = None ) : #NEWLINE# #INDENT# current_branch = get_current_branch ( directory ) #NEWLINE# if ( current_branch is None ) : #NEWLINE# #INDENT# error ( 'Could not determine current branch.' , exit = True ) #NEWLINE# #UNINDENT# if ( current_branch is None ) : #NEWLINE# #INDENT# error ( 'Could not determine current branch, are you in a git repo?' , exit = True ) #NEWLINE# #UNINDENT# patches_branch = ( 'patches/' + current_branch ) #NEWLINE# try : #NEWLINE# #INDENT# if branch_exists ( patches_branch , False , directory = directory ) : #NEWLINE# #INDENT# if ( not branch_exists ( patches_branch , True , directory = directory ) ) : #NEWLINE# #INDENT# track_branches ( patches_branch , directory ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# error ( ( ( 'No patches branch (' + patches_branch ) + ') found, cannot remove patches.' ) , exit = True ) #NEWLINE# #UNINDENT# config = get_patch_config ( patches_branch , directory = directory ) #NEWLINE# ( parent , spec ) = ( config [ 'parent' ] , config [ 'base' ] ) #NEWLINE# if ( None in [ parent , spec ] ) : #NEWLINE# #INDENT# error ( 'Could not retrieve patches info.' , exit = True ) #NEWLINE# #UNINDENT# debug ( ( ( ( 'Removing patches from ' + current_branch ) + ' back to base commit ' ) + spec ) ) #NEWLINE# current_commit = get_commit_hash ( current_branch , directory ) #NEWLINE# command_spec = ( ( spec + '..' ) + current_commit ) #NEWLINE# execute_command ( ( 'git revert --no-edit -Xtheirs ' + command_spec ) , cwd = directory ) #NEWLINE# config [ 'base' ] = get_commit_hash ( current_branch , directory ) #NEWLINE# set_patch_config ( patches_branch , config , directory = directory ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if current_branch : #NEWLINE# #INDENT# checkout ( current_branch , directory = directory )