#NEWLINE# def show( command ) : #NEWLINE# #INDENT# pr = subprocess . Popen ( [ '/usr/bin/git' , 'show' , command ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# ( out , error ) = pr . communicate ( ) #NEWLINE# if error : #NEWLINE# #INDENT# raise Exception ( error ) #NEWLINE# #UNINDENT# commits = [ ] #NEWLINE# from collections import defaultdict #NEWLINE# commit = defaultdict ( ( lambda : '' ) ) #NEWLINE# ignoretext = False #NEWLINE# for line in out . split ( '\n' ) : #NEWLINE# #INDENT# if line . startswith ( 'commit ' ) : #NEWLINE# #INDENT# if commit [ 'commit' ] : #NEWLINE# #INDENT# commits . insert ( 0 , commit ) #NEWLINE# commit = defaultdict ( ( lambda : '' ) ) #NEWLINE# #UNINDENT# commit [ 'commit' ] = line [ 7 : ] #NEWLINE# ignoretext = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if line . startswith ( 'diff ' ) : #NEWLINE# #INDENT# ignoretext = False #NEWLINE# #UNINDENT# #UNINDENT# if ( not ignoretext ) : #NEWLINE# #INDENT# commit [ 'patch' ] += ( line + '\n' ) #NEWLINE# #UNINDENT# #UNINDENT# commits . insert ( 0 , commit ) #NEWLINE# return commits