#NEWLINE# def handle_tree( tree , directory , root_path , version ) : #NEWLINE# #INDENT# for ( path , kind ) in tree . items ( ) : #NEWLINE# #INDENT# if ( kind == 'directory' ) : #NEWLINE# #INDENT# rel_path = os . path . join ( directory , path ) #NEWLINE# if os . path . isfile ( rel_path ) : #NEWLINE# #INDENT# error ( ( "In patches path '{0}' is a directory" . format ( rel_path ) + ', but it exists in the upstream branch as a file.' ) , exit = True ) #NEWLINE# #UNINDENT# if ( not os . path . isdir ( rel_path ) ) : #NEWLINE# #INDENT# info ( "  Createing directory... '{0}'" . format ( rel_path ) ) #NEWLINE# os . mkdir ( file_data ) #NEWLINE# #UNINDENT# handle_tree ( ls_tree ( BLOOM_CONFIG_BRANCH , os . path . join ( root_path , rel_path ) ) , rel_path , root_path , version ) #NEWLINE# #UNINDENT# if ( kind == 'file' ) : #NEWLINE# #INDENT# rel_path = os . path . join ( directory , path ) #NEWLINE# if os . path . isdir ( rel_path ) : #NEWLINE# #INDENT# error ( ( "In patches path '{0}' is a file, " . format ( rel_path ) + 'but it exists in the upstream branch as a directory.' ) , exit = True ) #NEWLINE# #UNINDENT# if os . path . isfile ( rel_path ) : #NEWLINE# #INDENT# warning ( "  File '{0}' already exists, overwriting..." . format ( rel_path ) ) #NEWLINE# execute_command ( 'git rm {0}' . format ( rel_path ) , shell = True ) #NEWLINE# #UNINDENT# if ( path in [ 'stack.xml' ] ) : #NEWLINE# #INDENT# warning ( "  Skipping '{0}' templating, fuerte not supported" . format ( rel_path ) ) #NEWLINE# #UNINDENT# if ( path in [ 'package.xml' ] ) : #NEWLINE# #INDENT# info ( "  Templating '{0}' into upstream branch..." . format ( rel_path ) ) #NEWLINE# file_data = show ( BLOOM_CONFIG_BRANCH , os . path . join ( root_path , rel_path ) ) #NEWLINE# file_data = file_data . replace ( ':{version}' , version ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# info ( "  Overlaying '{0}' into upstream branch..." . format ( rel_path ) ) #NEWLINE# file_data = show ( BLOOM_CONFIG_BRANCH , os . path . join ( root_path , rel_path ) ) #NEWLINE# #UNINDENT# with open ( rel_path , 'wb' ) as f : #NEWLINE# #INDENT# f . write ( file_data ) #NEWLINE# #UNINDENT# execute_command ( 'git add {0}' . format ( rel_path ) , shell = True )