diff options
Diffstat (limited to 'subcmds/start.py')
| -rw-r--r-- | subcmds/start.py | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/subcmds/start.py b/subcmds/start.py index 56008f42..6dca7e4e 100644 --- a/subcmds/start.py +++ b/subcmds/start.py | |||
| @@ -21,7 +21,6 @@ from error import RepoExitError | |||
| 21 | from git_command import git | 21 | from git_command import git |
| 22 | from git_config import IsImmutable | 22 | from git_config import IsImmutable |
| 23 | from progress import Progress | 23 | from progress import Progress |
| 24 | from project import Project | ||
| 25 | from repo_logging import RepoLogger | 24 | from repo_logging import RepoLogger |
| 26 | 25 | ||
| 27 | 26 | ||
| @@ -29,7 +28,7 @@ logger = RepoLogger(__file__) | |||
| 29 | 28 | ||
| 30 | 29 | ||
| 31 | class ExecuteOneResult(NamedTuple): | 30 | class ExecuteOneResult(NamedTuple): |
| 32 | project: Project | 31 | project_idx: int |
| 33 | error: Exception | 32 | error: Exception |
| 34 | 33 | ||
| 35 | 34 | ||
| @@ -80,18 +79,20 @@ revision specified in the manifest. | |||
| 80 | if not git.check_ref_format("heads/%s" % nb): | 79 | if not git.check_ref_format("heads/%s" % nb): |
| 81 | self.OptionParser.error("'%s' is not a valid name" % nb) | 80 | self.OptionParser.error("'%s' is not a valid name" % nb) |
| 82 | 81 | ||
| 83 | def _ExecuteOne(self, revision, nb, project): | 82 | @classmethod |
| 83 | def _ExecuteOne(cls, revision, nb, default_revisionExpr, project_idx): | ||
| 84 | """Start one project.""" | 84 | """Start one project.""" |
| 85 | # If the current revision is immutable, such as a SHA1, a tag or | 85 | # If the current revision is immutable, such as a SHA1, a tag or |
| 86 | # a change, then we can't push back to it. Substitute with | 86 | # a change, then we can't push back to it. Substitute with |
| 87 | # dest_branch, if defined; or with manifest default revision instead. | 87 | # dest_branch, if defined; or with manifest default revision instead. |
| 88 | branch_merge = "" | 88 | branch_merge = "" |
| 89 | error = None | 89 | error = None |
| 90 | project = cls.get_parallel_context()["projects"][project_idx] | ||
| 90 | if IsImmutable(project.revisionExpr): | 91 | if IsImmutable(project.revisionExpr): |
| 91 | if project.dest_branch: | 92 | if project.dest_branch: |
| 92 | branch_merge = project.dest_branch | 93 | branch_merge = project.dest_branch |
| 93 | else: | 94 | else: |
| 94 | branch_merge = self.manifest.default.revisionExpr | 95 | branch_merge = default_revisionExpr |
| 95 | 96 | ||
| 96 | try: | 97 | try: |
| 97 | project.StartBranch( | 98 | project.StartBranch( |
| @@ -100,7 +101,7 @@ revision specified in the manifest. | |||
| 100 | except Exception as e: | 101 | except Exception as e: |
| 101 | logger.error("error: unable to checkout %s: %s", project.name, e) | 102 | logger.error("error: unable to checkout %s: %s", project.name, e) |
| 102 | error = e | 103 | error = e |
| 103 | return ExecuteOneResult(project, error) | 104 | return ExecuteOneResult(project_idx, error) |
| 104 | 105 | ||
| 105 | def Execute(self, opt, args): | 106 | def Execute(self, opt, args): |
| 106 | nb = args[0] | 107 | nb = args[0] |
| @@ -120,19 +121,28 @@ revision specified in the manifest. | |||
| 120 | def _ProcessResults(_pool, pm, results): | 121 | def _ProcessResults(_pool, pm, results): |
| 121 | for result in results: | 122 | for result in results: |
| 122 | if result.error: | 123 | if result.error: |
| 123 | err_projects.append(result.project) | 124 | project = all_projects[result.project_idx] |
| 125 | err_projects.append(project) | ||
| 124 | err.append(result.error) | 126 | err.append(result.error) |
| 125 | pm.update(msg="") | 127 | pm.update(msg="") |
| 126 | 128 | ||
| 127 | self.ExecuteInParallel( | 129 | with self.ParallelContext(): |
| 128 | opt.jobs, | 130 | self.get_parallel_context()["projects"] = all_projects |
| 129 | functools.partial(self._ExecuteOne, opt.revision, nb), | 131 | self.ExecuteInParallel( |
| 130 | all_projects, | 132 | opt.jobs, |
| 131 | callback=_ProcessResults, | 133 | functools.partial( |
| 132 | output=Progress( | 134 | self._ExecuteOne, |
| 133 | f"Starting {nb}", len(all_projects), quiet=opt.quiet | 135 | opt.revision, |
| 134 | ), | 136 | nb, |
| 135 | ) | 137 | self.manifest.default.revisionExpr, |
| 138 | ), | ||
| 139 | range(len(all_projects)), | ||
| 140 | callback=_ProcessResults, | ||
| 141 | output=Progress( | ||
| 142 | f"Starting {nb}", len(all_projects), quiet=opt.quiet | ||
| 143 | ), | ||
| 144 | chunksize=1, | ||
| 145 | ) | ||
| 136 | 146 | ||
| 137 | if err_projects: | 147 | if err_projects: |
| 138 | for p in err_projects: | 148 | for p in err_projects: |
