#NEWLINE# def parse_diff( self , result , stdin = None ) : #NEWLINE# #INDENT# lines = result . splitlines ( ) #NEWLINE# matcher = re . compile ( '^@@ -([0-9]*),([0-9]*) \\+([0-9]*),([0-9]*) @@' ) #NEWLINE# diff = [ ] #NEWLINE# for line_index in range ( 0 , len ( lines ) ) : #NEWLINE# #INDENT# line = lines [ line_index ] #NEWLINE# if ( not line . startswith ( '@' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# match = matcher . match ( line ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( line_before , len_before , line_after , len_after ) = [ int ( match . group ( x ) ) for x in [ 1 , 2 , 3 , 4 ] ] #NEWLINE# chunk_index = ( line_index + 1 ) #NEWLINE# tracked_line_index = ( line_after - 1 ) #NEWLINE# deletion = False #NEWLINE# insertion = False #NEWLINE# while True : #NEWLINE# #INDENT# line = lines [ chunk_index ] #NEWLINE# if line . startswith ( '@' ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if line . startswith ( '-' ) : #NEWLINE# #INDENT# if ( not ( line . strip ( ) == '-' ) ) : #NEWLINE# #INDENT# deletion = True #NEWLINE# #UNINDENT# tracked_line_index -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if line . startswith ( '+' ) : #NEWLINE# #INDENT# if ( deletion and ( not ( line . strip ( ) == '+' ) ) ) : #NEWLINE# #INDENT# diff . append ( [ 'x' , tracked_line_index ] ) #NEWLINE# insertion = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not deletion ) : #NEWLINE# #INDENT# insertion = True #NEWLINE# diff . append ( [ '+' , tracked_line_index ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not insertion ) and deletion ) : #NEWLINE# #INDENT# diff . append ( [ '-' , tracked_line_index ] ) #NEWLINE# #UNINDENT# insertion = deletion = False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# tracked_line_index += 1 #NEWLINE# chunk_index += 1 #NEWLINE# if ( chunk_index >= len ( lines ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . annotate ( line_index )