#NEWLINE# def convert_commit( repo_key , repo , commit , include_diff = False ) : #NEWLINE# #INDENT# plain_commit_json = _plumbing_convert_commit ( repo_key , commit , porcelain = True ) #NEWLINE# result = { #NEWLINE# #INDENT# 'commit' : plain_commit_json , #NEWLINE# 'sha' : plain_commit_json [ 'sha' ] , #NEWLINE# 'author' : plain_commit_json [ 'author' ] , #NEWLINE# 'committer' : plain_commit_json [ 'committer' ] , #NEWLINE# 'url' : url_for ( 'porcelain.get_commit' , _external = True , repo_key = repo_key , branch_or_tag_or_sha = unicode ( commit . id ) ) , #NEWLINE# 'parents' : [ { #NEWLINE# #INDENT# 'sha' : unicode ( c . id ) , #NEWLINE# 'url' : url_for ( 'porcelain.get_commit' , _external = True , repo_key = repo_key , branch_or_tag_or_sha = unicode ( c . id ) ) , #NEWLINE# #UNINDENT# } for c in commit . parents ] , #NEWLINE# #UNINDENT# } #NEWLINE# if include_diff : #NEWLINE# #INDENT# diff = get_diff ( repo , commit ) #NEWLINE# patches = list ( diff ) #NEWLINE# filename_to_patch = _filename_to_patch_from ( diff ) #NEWLINE# patches_additions = sum ( ( patch . additions for patch in patches ) ) #NEWLINE# patches_deletions = sum ( ( patch . deletions for patch in patches ) ) #NEWLINE# result . update ( { #NEWLINE# #INDENT# 'stats' : { #NEWLINE# #INDENT# 'additions' : patches_additions , #NEWLINE# 'deletions' : patches_deletions , #NEWLINE# 'total' : ( patches_additions + patches_deletions ) , #NEWLINE# #UNINDENT# } , #NEWLINE# 'files' : [ _convert_patch ( repo_key , patches_additions , patch , filename_to_patch ) for patch in patches ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return result