Skip to content

Commit 1777e31

Browse files
Merge pull request #84786 from charles-zablit/charles-zablit/update-checkout/faster-fresh-clone
[update-checkout] make llvm-project be the first project
2 parents 9b68204 + 29c924b commit 1777e31

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import sys
1818
import traceback
1919
from multiprocessing import freeze_support
20-
from typing import Any, Dict, Optional, Set, List
20+
from typing import Any, Dict, Optional, Set, List, Union
2121

2222
from build_swift.build_swift.constants import SWIFT_SOURCE_ROOT
2323
from .runner_arguments import AdditionalSwiftSourcesArguments, UpdateArguments
@@ -340,8 +340,17 @@ def _is_any_repository_locked(pool_args: List[UpdateArguments]) -> Set[str]:
340340
locked_repositories.add(repo_name)
341341
return locked_repositories
342342

343+
def _move_llvm_project_to_first_index(pool_args: List[Union[UpdateArguments, AdditionalSwiftSourcesArguments]]):
344+
llvm_project_idx = None
345+
for i in range(len(pool_args)):
346+
if pool_args[i].repo_name == "llvm-project":
347+
llvm_project_idx = i
348+
break
349+
if llvm_project_idx is not None:
350+
pool_args.insert(0, pool_args.pop(llvm_project_idx))
351+
343352
def update_all_repositories(args, config, scheme_name, scheme_map, cross_repos_pr):
344-
pool_args = []
353+
pool_args: List[UpdateArguments] = []
345354
timestamp = get_timestamp_to_match(args.match_timestamp, args.source_root)
346355
for repo_name in config['repos'].keys():
347356
if repo_name in args.skip_repository_list:
@@ -384,6 +393,7 @@ def update_all_repositories(args, config, scheme_name, scheme_map, cross_repos_p
384393
f"'{repo_name}' is locked by git. Cannot update it."
385394
for repo_name in locked_repositories
386395
]
396+
_move_llvm_project_to_first_index(pool_args)
387397
return ParallelRunner(update_single_repository, pool_args, args.n_processes).run()
388398

389399

@@ -517,13 +527,16 @@ def obtain_all_additional_swift_sources(args, config, with_ssh, scheme_name,
517527

518528
# Only use `ParallelRunner` when submodules are not used, since `.git` dir
519529
# can't be accessed concurrently.
520-
if not use_submodules:
521-
if not pool_args:
522-
print("Not cloning any repositories.")
523-
return
530+
if use_submodules:
531+
return
532+
if not pool_args:
533+
print("Not cloning any repositories.")
534+
return
524535

525-
return ParallelRunner(
526-
obtain_additional_swift_sources, pool_args, args.n_processes).run()
536+
_move_llvm_project_to_first_index(pool_args)
537+
return ParallelRunner(
538+
obtain_additional_swift_sources, pool_args, args.n_processes
539+
).run()
527540

528541

529542
def dump_repo_hashes(args, config, branch_scheme_name='repro'):

0 commit comments

Comments
 (0)