#NEWLINE# def Save( self , fd , peg_rev = False , peg_rev_upstream = True , groups = None ) : #NEWLINE# #INDENT# 'Write the current manifest out to the given file descriptor.\n    ' #NEWLINE# mp = self . manifestProject #NEWLINE# if ( groups is None ) : #NEWLINE# #INDENT# groups = mp . config . GetString ( 'manifest.groups' ) #NEWLINE# #UNINDENT# if groups : #NEWLINE# #INDENT# groups = self . _ParseGroups ( groups ) #NEWLINE# #UNINDENT# doc = xml . dom . minidom . Document ( ) #NEWLINE# root = doc . createElement ( 'manifest' ) #NEWLINE# doc . appendChild ( root ) #NEWLINE# if self . notice : #NEWLINE# #INDENT# notice_element = root . appendChild ( doc . createElement ( 'notice' ) ) #NEWLINE# notice_lines = self . notice . splitlines ( ) #NEWLINE# indented_notice = '\n' . join ( ( ( ( ' ' * 4 ) + line ) for line in notice_lines ) ) [ 4 : ] #NEWLINE# notice_element . appendChild ( doc . createTextNode ( indented_notice ) ) #NEWLINE# #UNINDENT# d = self . default #NEWLINE# for r in sorted ( self . remotes ) : #NEWLINE# #INDENT# self . _RemoteToXml ( self . remotes [ r ] , doc , root ) #NEWLINE# #UNINDENT# if self . remotes : #NEWLINE# #INDENT# root . appendChild ( doc . createTextNode ( '' ) ) #NEWLINE# #UNINDENT# have_default = False #NEWLINE# e = doc . createElement ( 'default' ) #NEWLINE# if d . remote : #NEWLINE# #INDENT# have_default = True #NEWLINE# e . setAttribute ( 'remote' , d . remote . name ) #NEWLINE# #UNINDENT# if d . revisionExpr : #NEWLINE# #INDENT# have_default = True #NEWLINE# e . setAttribute ( 'revision' , d . revisionExpr ) #NEWLINE# #UNINDENT# if d . destBranchExpr : #NEWLINE# #INDENT# have_default = True #NEWLINE# e . setAttribute ( 'dest-branch' , d . destBranchExpr ) #NEWLINE# #UNINDENT# if ( d . sync_j > 1 ) : #NEWLINE# #INDENT# have_default = True #NEWLINE# e . setAttribute ( 'sync-j' , ( '%d' % d . sync_j ) ) #NEWLINE# #UNINDENT# if d . sync_c : #NEWLINE# #INDENT# have_default = True #NEWLINE# e . setAttribute ( 'sync-c' , 'true' ) #NEWLINE# #UNINDENT# if d . sync_s : #NEWLINE# #INDENT# have_default = True #NEWLINE# e . setAttribute ( 'sync-s' , 'true' ) #NEWLINE# #UNINDENT# if have_default : #NEWLINE# #INDENT# root . appendChild ( e ) #NEWLINE# root . appendChild ( doc . createTextNode ( '' ) ) #NEWLINE# #UNINDENT# if self . _manifest_server : #NEWLINE# #INDENT# e = doc . createElement ( 'manifest-server' ) #NEWLINE# e . setAttribute ( 'url' , self . _manifest_server ) #NEWLINE# root . appendChild ( e ) #NEWLINE# root . appendChild ( doc . createTextNode ( '' ) ) #NEWLINE# #UNINDENT# def output_projects( parent , parent_node , projects ) : #NEWLINE# #INDENT# for project_name in projects : #NEWLINE# #INDENT# for project in self . _projects [ project_name ] : #NEWLINE# #INDENT# output_project ( parent , parent_node , project ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# def output_project( parent , parent_node , p ) : #NEWLINE# #INDENT# if ( not p . MatchesGroups ( groups ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# name = p . name #NEWLINE# relpath = p . relpath #NEWLINE# if parent : #NEWLINE# #INDENT# name = self . _UnjoinName ( parent . name , name ) #NEWLINE# relpath = self . _UnjoinRelpath ( parent . relpath , relpath ) #NEWLINE# #UNINDENT# e = doc . createElement ( 'project' ) #NEWLINE# parent_node . appendChild ( e ) #NEWLINE# e . setAttribute ( 'name' , name ) #NEWLINE# if ( relpath != name ) : #NEWLINE# #INDENT# e . setAttribute ( 'path' , relpath ) #NEWLINE# #UNINDENT# remoteName = None #NEWLINE# if d . remote : #NEWLINE# #INDENT# remoteName = ( d . remote . remoteAlias or d . remote . name ) #NEWLINE# #UNINDENT# if ( ( not d . remote ) or ( p . remote . name != remoteName ) ) : #NEWLINE# #INDENT# remoteName = p . remote . name #NEWLINE# e . setAttribute ( 'remote' , remoteName ) #NEWLINE# #UNINDENT# if peg_rev : #NEWLINE# #INDENT# if self . IsMirror : #NEWLINE# #INDENT# value = p . bare_git . rev_parse ( ( p . revisionExpr + '^0' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = p . work_git . rev_parse ( ( HEAD + '^0' ) ) #NEWLINE# #UNINDENT# e . setAttribute ( 'revision' , value ) #NEWLINE# if peg_rev_upstream : #NEWLINE# #INDENT# if p . upstream : #NEWLINE# #INDENT# e . setAttribute ( 'upstream' , p . upstream ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( value != p . revisionExpr ) : #NEWLINE# #INDENT# e . setAttribute ( 'upstream' , p . revisionExpr ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# revision = ( self . remotes [ remoteName ] . revision or d . revisionExpr ) #NEWLINE# if ( ( not revision ) or ( revision != p . revisionExpr ) ) : #NEWLINE# #INDENT# e . setAttribute ( 'revision' , p . revisionExpr ) #NEWLINE# #UNINDENT# if ( p . upstream and ( p . upstream != p . revisionExpr ) ) : #NEWLINE# #INDENT# e . setAttribute ( 'upstream' , p . upstream ) #NEWLINE# #UNINDENT# #UNINDENT# if ( p . dest_branch and ( p . dest_branch != d . destBranchExpr ) ) : #NEWLINE# #INDENT# e . setAttribute ( 'dest-branch' , p . dest_branch ) #NEWLINE# #UNINDENT# for c in p . copyfiles : #NEWLINE# #INDENT# ce = doc . createElement ( 'copyfile' ) #NEWLINE# ce . setAttribute ( 'src' , c . src ) #NEWLINE# ce . setAttribute ( 'dest' , c . dest ) #NEWLINE# e . appendChild ( ce ) #NEWLINE# #UNINDENT# for l in p . linkfiles : #NEWLINE# #INDENT# le = doc . createElement ( 'linkfile' ) #NEWLINE# le . setAttribute ( 'src' , l . src ) #NEWLINE# le . setAttribute ( 'dest' , l . dest ) #NEWLINE# e . appendChild ( le ) #NEWLINE# #UNINDENT# default_groups = [ 'all' , ( 'name:%s' % p . name ) , ( 'path:%s' % p . relpath ) ] #NEWLINE# egroups = [ g for g in p . groups if ( g not in default_groups ) ] #NEWLINE# if egroups : #NEWLINE# #INDENT# e . setAttribute ( 'groups' , ',' . join ( egroups ) ) #NEWLINE# #UNINDENT# for a in p . annotations : #NEWLINE# #INDENT# if ( a . keep == 'true' ) : #NEWLINE# #INDENT# ae = doc . createElement ( 'annotation' ) #NEWLINE# ae . setAttribute ( 'name' , a . name ) #NEWLINE# ae . setAttribute ( 'value' , a . value ) #NEWLINE# e . appendChild ( ae ) #NEWLINE# #UNINDENT# #UNINDENT# if p . sync_c : #NEWLINE# #INDENT# e . setAttribute ( 'sync-c' , 'true' ) #NEWLINE# #UNINDENT# if p . sync_s : #NEWLINE# #INDENT# e . setAttribute ( 'sync-s' , 'true' ) #NEWLINE# #UNINDENT# if p . clone_depth : #NEWLINE# #INDENT# e . setAttribute ( 'clone-depth' , str ( p . clone_depth ) ) #NEWLINE# #UNINDENT# self . _output_manifest_project_extras ( p , e ) #NEWLINE# if p . subprojects : #NEWLINE# #INDENT# subprojects = set ( ( subp . name for subp in p . subprojects ) ) #NEWLINE# output_projects ( p , e , list ( sorted ( subprojects ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# projects = set ( ( p . name for p in self . _paths . values ( ) if ( not p . parent ) ) ) #NEWLINE# output_projects ( None , root , list ( sorted ( projects ) ) ) #NEWLINE# if self . _repo_hooks_project : #NEWLINE# #INDENT# root . appendChild ( doc . createTextNode ( '' ) ) #NEWLINE# e = doc . createElement ( 'repo-hooks' ) #NEWLINE# e . setAttribute ( 'in-project' , self . _repo_hooks_project . name ) #NEWLINE# e . setAttribute ( 'enabled-list' , ' ' . join ( self . _repo_hooks_project . enabled_repo_hooks ) ) #NEWLINE# root . appendChild ( e ) #NEWLINE# #UNINDENT# doc . writexml ( fd , '' , '  ' , '\n' , 'UTF-8' )