@@ -81,10 +81,10 @@ def get_branch_for_repo(config, repo_name, scheme_name, scheme_map,
81
81
return repo_branch , cross_repo
82
82
83
83
84
- def update_single_repository (args ):
85
- config , repo_name , scheme_name , scheme_map , tag , timestamp , \
86
- reset_to_remote , should_clean , cross_repos_pr = args
87
- repo_path = os .path .join (SWIFT_SOURCE_ROOT , repo_name )
84
+ def update_single_repository (pool_args ):
85
+ source_root , config , repo_name , scheme_name , scheme_map , tag , timestamp , \
86
+ reset_to_remote , should_clean , cross_repos_pr = pool_args
87
+ repo_path = os .path .join (source_root , repo_name )
88
88
if not os .path .isdir (repo_path ):
89
89
return
90
90
@@ -175,7 +175,7 @@ def update_single_repository(args):
175
175
def get_timestamp_to_match (args ):
176
176
if not args .match_timestamp :
177
177
return None
178
- with shell .pushd (os .path .join (SWIFT_SOURCE_ROOT , "swift" ),
178
+ with shell .pushd (os .path .join (args . source_root , "swift" ),
179
179
dry_run = False , echo = False ):
180
180
return shell .capture (["git" , "log" , "-1" , "--format=%cI" ],
181
181
echo = False ).strip ()
@@ -198,7 +198,7 @@ def update_all_repositories(args, config, scheme_name, cross_repos_pr):
198
198
if repo_name in args .skip_repository_list :
199
199
print ("Skipping update of '" + repo_name + "', requested by user" )
200
200
continue
201
- my_args = [config ,
201
+ my_args = [args . source_root , config ,
202
202
repo_name ,
203
203
scheme_name ,
204
204
scheme_map ,
@@ -220,7 +220,7 @@ def obtain_additional_swift_sources(pool_args):
220
220
env = dict (os .environ )
221
221
env .update ({'GIT_TERMINAL_PROMPT' : 0 })
222
222
223
- with shell .pushd (SWIFT_SOURCE_ROOT , dry_run = False , echo = False ):
223
+ with shell .pushd (args . source_root , dry_run = False , echo = False ):
224
224
225
225
print ("Cloning '" + repo_name + "'" )
226
226
@@ -236,14 +236,14 @@ def obtain_additional_swift_sources(pool_args):
236
236
env = env ,
237
237
echo = True )
238
238
if scheme_name :
239
- src_path = os .path .join (SWIFT_SOURCE_ROOT , repo_name , ".git" )
239
+ src_path = os .path .join (args . source_root , repo_name , ".git" )
240
240
shell .run (['git' , '--git-dir' ,
241
241
src_path , '--work-tree' ,
242
- os .path .join (SWIFT_SOURCE_ROOT , repo_name ),
242
+ os .path .join (args . source_root , repo_name ),
243
243
'checkout' , repo_branch ],
244
244
env = env ,
245
245
echo = False )
246
- with shell .pushd (os .path .join (SWIFT_SOURCE_ROOT , repo_name ),
246
+ with shell .pushd (os .path .join (args . source_root , repo_name ),
247
247
dry_run = False , echo = False ):
248
248
shell .run (["git" , "submodule" ,
249
249
"update" , "--recursive" ],
@@ -255,7 +255,7 @@ def obtain_all_additional_swift_sources(args, config, with_ssh, scheme_name,
255
255
skip_history , skip_repository_list ):
256
256
257
257
pool_args = []
258
- with shell .pushd (SWIFT_SOURCE_ROOT , dry_run = False , echo = False ):
258
+ with shell .pushd (args . source_root , dry_run = False , echo = False ):
259
259
for repo_name , repo_info in config ['repos' ].items ():
260
260
if repo_name in skip_repository_list :
261
261
print ("Skipping clone of '" + repo_name + "', requested by "
@@ -308,7 +308,7 @@ def obtain_all_additional_swift_sources(args, config, with_ssh, scheme_name,
308
308
args .n_processes )
309
309
310
310
311
- def dump_repo_hashes (config , branch_scheme_name = 'repro' ):
311
+ def dump_repo_hashes (args , config , branch_scheme_name = 'repro' ):
312
312
"""
313
313
Dumps the current state of the repo into a new config file that contains a
314
314
master branch scheme with the relevant branches set to the appropriate
@@ -319,17 +319,17 @@ def dump_repo_hashes(config, branch_scheme_name='repro'):
319
319
for config_copy_key in config_copy_keys :
320
320
new_config [config_copy_key ] = config [config_copy_key ]
321
321
repos = {}
322
- repos = repo_hashes (config )
322
+ repos = repo_hashes (args , config )
323
323
branch_scheme = {'aliases' : [branch_scheme_name ], 'repos' : repos }
324
324
new_config ['branch-schemes' ] = {branch_scheme_name : branch_scheme }
325
325
json .dump (new_config , sys .stdout , indent = 4 )
326
326
327
327
328
- def repo_hashes (config ):
328
+ def repo_hashes (args , config ):
329
329
repos = {}
330
330
for repo_name , repo_info in sorted (config ['repos' ].items (),
331
331
key = lambda x : x [0 ]):
332
- repo_path = os .path .join (SWIFT_SOURCE_ROOT , repo_name )
332
+ repo_path = os .path .join (args . source_root , repo_name )
333
333
if os .path .exists (repo_path ):
334
334
with shell .pushd (repo_path , dry_run = False , echo = False ):
335
335
h = shell .capture (["git" , "rev-parse" , "HEAD" ],
@@ -340,8 +340,8 @@ def repo_hashes(config):
340
340
return repos
341
341
342
342
343
- def print_repo_hashes (config ):
344
- repos = repo_hashes (config )
343
+ def print_repo_hashes (args , config ):
344
+ repos = repo_hashes (args , config )
345
345
for repo_name , repo_hash in sorted (repos .items (),
346
346
key = lambda x : x [0 ]):
347
347
print ("{:<35}: {:<35}" .format (repo_name , repo_hash ))
@@ -484,6 +484,11 @@ def main():
484
484
help = "Number of threads to run at once" ,
485
485
default = 0 ,
486
486
dest = "n_processes" )
487
+ parser .add_argument (
488
+ "--source-root" ,
489
+ help = "The root directory to checkout repositories" ,
490
+ default = SWIFT_SOURCE_ROOT ,
491
+ dest = 'source_root' )
487
492
args = parser .parse_args ()
488
493
489
494
if not args .scheme :
@@ -513,7 +518,7 @@ def main():
513
518
return (None , None )
514
519
515
520
if args .dump_hashes_config :
516
- dump_repo_hashes (config , args .dump_hashes_config )
521
+ dump_repo_hashes (args , config , args .dump_hashes_config )
517
522
return (None , None )
518
523
519
524
cross_repos_pr = {}
@@ -540,7 +545,7 @@ def main():
540
545
skip_repo_list )
541
546
542
547
# Quick check whether somebody is calling update in an empty directory
543
- directory_contents = os .listdir (SWIFT_SOURCE_ROOT )
548
+ directory_contents = os .listdir (args . source_root )
544
549
if not ('cmark' in directory_contents or
545
550
'llvm' in directory_contents or
546
551
'clang' in directory_contents ):
@@ -556,5 +561,5 @@ def main():
556
561
print ("update-checkout failed, fix errors and try again" )
557
562
else :
558
563
print ("update-checkout succeeded" )
559
- print_repo_hashes (config )
564
+ print_repo_hashes (args , config )
560
565
sys .exit (fail_count )
0 commit comments