#NEWLINE# def cmd_resync( args ) : #NEWLINE# #INDENT# "Stashes unstaged changes,\n    Fetches, Auto-Merge/Rebase upstream data from specified upstream branch,\n    Performs smart pull+merge for current branch,\n    Pushes local commits up, and Unstashes changes.\n    Default upstream branch is 'master'.\n    " #NEWLINE# if args . get ( 0 ) : #NEWLINE# #INDENT# upstream = fuzzy_match_branch ( args . get ( 0 ) ) #NEWLINE# if upstream : #NEWLINE# #INDENT# is_external = True #NEWLINE# original_branch = get_current_branch_name ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( "{0} doesn't exist. Use a branch that does." . format ( colored . yellow ( args . get ( 0 ) ) ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# upstream = 'master' #NEWLINE# #UNINDENT# original_branch = get_current_branch_name ( ) #NEWLINE# if repo . is_dirty ( ) : #NEWLINE# #INDENT# status_log ( stash_it , 'Saving local changes.' , sync = True ) #NEWLINE# #UNINDENT# switch_to ( upstream ) #NEWLINE# status_log ( smart_pull , 'Pulling commits from the server.' ) #NEWLINE# switch_to ( original_branch ) #NEWLINE# status_log ( smart_merge , 'Grafting commits from {0}.' . format ( colored . yellow ( original_branch ) ) , upstream , allow_rebase = False ) #NEWLINE# if unstash_index ( sync = True ) : #NEWLINE# #INDENT# status_log ( unstash_it , 'Restoring local changes.' , sync = True ) #NEWLINE# #UNINDENT# status_log ( smart_pull , 'Pulling commits from the server.' ) #NEWLINE# status_log ( push , 'Pushing commits to the server.' , original_branch )