#NEWLINE# def split( splits , verbose , dry_run ) : #NEWLINE# #INDENT# for split in splits : #NEWLINE# #INDENT# if verbose : #NEWLINE# #INDENT# log ( 'Operating on split: %s' , commit ) #NEWLINE# #UNINDENT# branch_name = ( '_sapling_split_%s_' % split . name ) #NEWLINE# if dry_run : #NEWLINE# #INDENT# commits = pylist ( split . commits ( ) ) #NEWLINE# print ( ( 'Would split %d new commits to branch: %s' % ( len ( commits ) , branch_name ) ) ) #NEWLINE# print ( '\n' . join ( ( commit . hexsha for commit in commits ) ) ) #NEWLINE# return #NEWLINE# #UNINDENT# class ProgressTracker ( saplib . Split . ApplyListener ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# self . _commit_index = 0 #NEWLINE# self . _width = 80.0 #NEWLINE# self . _pct = 0 #NEWLINE# self . _pct_complete = 0 #NEWLINE# #UNINDENT# def on_start( self , commit_count ) : #NEWLINE# #INDENT# self . _commit_count = commit_count #NEWLINE# message = ( '[split = %s, branch = %s] Processing %d commits' % ( split . name , branch_name , self . _commit_count ) ) #NEWLINE# if verbose : #NEWLINE# #INDENT# log ( message ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _width = max ( ( len ( message ) + 2.0 ) , float ( self . _width ) ) #NEWLINE# self . _quantum = ( self . _commit_count / self . _width ) #NEWLINE# log ( ( ( message + ( ' ' * ( ( int ( self . _width ) - len ( message ) ) - 1 ) ) ) + '|' ) ) #NEWLINE# #UNINDENT# #UNINDENT# def on_commit( self , original_commit , new_commit ) : #NEWLINE# #INDENT# self . _commit_index += 1 #NEWLINE# if verbose : #NEWLINE# #INDENT# log ( '%s -> %s (%d of %d)' , original_commit . hexsha , new_commit . hexsha , self . _commit_index , self . _commit_count ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _pct_complete = int ( ( ( self . _commit_index / self . _quantum ) % self . _commit_count ) ) #NEWLINE# if ( self . _pct_complete > self . _pct ) : #NEWLINE# #INDENT# log ( ( '.' * ( self . _pct_complete - self . _pct ) ) , end = '' ) #NEWLINE# self . _pct = self . _pct_complete #NEWLINE# sys . __stdout__ . flush ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# def on_finish( self ) : #NEWLINE# #INDENT# if ( not verbose ) : #NEWLINE# #INDENT# log ( ( '.' * ( int ( self . _width ) - self . _pct_complete ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# tip = split . apply ( branch_name , apply_listener = ProgressTracker ( ) ) #NEWLINE# if tip : #NEWLINE# #INDENT# print ( tip . hexsha ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log ( 'No new commits to split.' )