def write_blob_diff(f, old_file, new_file):
 (old_path, old_mode, old_blob) = old_file
 (new_path, new_mode, new_blob) = new_file
 old_path = patch_filename(old_path, 'a')
 new_path = patch_filename(new_path, 'b')
 def lines(blob):
  if (blob is not None):
   return blob.splitlines()
  else:
   return []
 f.writelines(gen_diff_header((old_path, new_path), (old_mode, new_mode), (getattr(old_blob, 'id', None), getattr(new_blob, 'id', None))))
 old_contents = lines(old_blob)
 new_contents = lines(new_blob)
 f.writelines(unified_diff(old_contents, new_contents, old_path, new_path))

def write_blob_diff ( f , old_file , new_file ) : ( old_path , old_mode , old_blob ) = old_file ( new_path , new_mode , new_blob ) = new_file old_path = patch_filename ( old_path , 'a' ) new_path = patch_filename ( new_path , 'b' ) def lines ( blob ) : if ( blob is not None ) : return blob . splitlines ( ) else : return [ ] f . writelines ( gen_diff_header ( ( old_path , new_path ) , ( old_mode , new_mode ) , ( getattr ( old_blob , 'id' , None ) , getattr ( new_blob , 'id' , None ) ) ) ) old_contents = lines ( old_blob ) new_contents = lines ( new_blob ) f . writelines ( unified_diff ( old_contents , new_contents , old_path , new_path ) )
write blob diff .