#NEWLINE# def generate_unified_diff( repository , changed_files , commit1 , commit2 ) : #NEWLINE# #INDENT# diffs = [ ] #NEWLINE# for file_name in changed_files : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# file1 = repository . file_contents ( file_name , commit1 ) #NEWLINE# #UNINDENT# except FileDoesNotExist : #NEWLINE# #INDENT# file1 = '' #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# file2 = repository . file_contents ( file_name , commit2 ) #NEWLINE# #UNINDENT# except FileDoesNotExist : #NEWLINE# #INDENT# file2 = '' #NEWLINE# #UNINDENT# diffs . append ( unified_diff ( file1 . splitlines ( ) , file2 . splitlines ( ) , fromfile = diff , tofile = file_name , fromfiledate = commit1 , tofiledate = commit2 ) ) #NEWLINE# #UNINDENT# return '\n' . join ( ( '\n' . join ( map ( ( lambda s : s . rstrip ( '\n' ) ) , diff ) ) for diff in diffs ) )