diff options
Diffstat (limited to 'subcmds/start.py')
-rw-r--r-- | subcmds/start.py | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/subcmds/start.py b/subcmds/start.py index f6355126..67ac7df9 100644 --- a/subcmds/start.py +++ b/subcmds/start.py | |||
@@ -21,7 +21,18 @@ from git_config import IsImmutable | |||
21 | from git_command import git | 21 | from git_command import git |
22 | import gitc_utils | 22 | import gitc_utils |
23 | from progress import Progress | 23 | from progress import Progress |
24 | from project import SyncBuffer | 24 | from project import SyncBuffer, Project |
25 | from typing import NamedTuple | ||
26 | from error import RepoExitError | ||
27 | |||
28 | |||
29 | class ExecuteOneResult(NamedTuple): | ||
30 | project: Project | ||
31 | error: Exception | ||
32 | |||
33 | |||
34 | class StartError(RepoExitError): | ||
35 | """Exit error for failed start command.""" | ||
25 | 36 | ||
26 | 37 | ||
27 | class Start(Command): | 38 | class Start(Command): |
@@ -73,6 +84,7 @@ revision specified in the manifest. | |||
73 | # a change, then we can't push back to it. Substitute with | 84 | # a change, then we can't push back to it. Substitute with |
74 | # dest_branch, if defined; or with manifest default revision instead. | 85 | # dest_branch, if defined; or with manifest default revision instead. |
75 | branch_merge = "" | 86 | branch_merge = "" |
87 | error = None | ||
76 | if IsImmutable(project.revisionExpr): | 88 | if IsImmutable(project.revisionExpr): |
77 | if project.dest_branch: | 89 | if project.dest_branch: |
78 | branch_merge = project.dest_branch | 90 | branch_merge = project.dest_branch |
@@ -80,7 +92,7 @@ revision specified in the manifest. | |||
80 | branch_merge = self.manifest.default.revisionExpr | 92 | branch_merge = self.manifest.default.revisionExpr |
81 | 93 | ||
82 | try: | 94 | try: |
83 | ret = project.StartBranch( | 95 | project.StartBranch( |
84 | nb, branch_merge=branch_merge, revision=revision | 96 | nb, branch_merge=branch_merge, revision=revision |
85 | ) | 97 | ) |
86 | except Exception as e: | 98 | except Exception as e: |
@@ -88,11 +100,12 @@ revision specified in the manifest. | |||
88 | "error: unable to checkout %s: %s" % (project.name, e), | 100 | "error: unable to checkout %s: %s" % (project.name, e), |
89 | file=sys.stderr, | 101 | file=sys.stderr, |
90 | ) | 102 | ) |
91 | ret = False | 103 | error = e |
92 | return (ret, project) | 104 | return ExecuteOneResult(project, error) |
93 | 105 | ||
94 | def Execute(self, opt, args): | 106 | def Execute(self, opt, args): |
95 | nb = args[0] | 107 | nb = args[0] |
108 | err_projects = [] | ||
96 | err = [] | 109 | err = [] |
97 | projects = [] | 110 | projects = [] |
98 | if not opt.all: | 111 | if not opt.all: |
@@ -146,9 +159,10 @@ revision specified in the manifest. | |||
146 | pm.end() | 159 | pm.end() |
147 | 160 | ||
148 | def _ProcessResults(_pool, pm, results): | 161 | def _ProcessResults(_pool, pm, results): |
149 | for result, project in results: | 162 | for result in results: |
150 | if not result: | 163 | if result.error: |
151 | err.append(project) | 164 | err_projects.append(result.project) |
165 | err.append(result.error) | ||
152 | pm.update(msg="") | 166 | pm.update(msg="") |
153 | 167 | ||
154 | self.ExecuteInParallel( | 168 | self.ExecuteInParallel( |
@@ -161,13 +175,15 @@ revision specified in the manifest. | |||
161 | ), | 175 | ), |
162 | ) | 176 | ) |
163 | 177 | ||
164 | if err: | 178 | if err_projects: |
165 | for p in err: | 179 | for p in err_projects: |
166 | print( | 180 | print( |
167 | "error: %s/: cannot start %s" | 181 | "error: %s/: cannot start %s" |
168 | % (p.RelPath(local=opt.this_manifest_only), nb), | 182 | % (p.RelPath(local=opt.this_manifest_only), nb), |
169 | file=sys.stderr, | 183 | file=sys.stderr, |
170 | ) | 184 | ) |
171 | msg_fmt = "cannot start %d project(s)" | 185 | msg_fmt = "cannot start %d project(s)" |
172 | self.git_event_log.ErrorEvent(msg_fmt % (len(err)), msg_fmt) | 186 | self.git_event_log.ErrorEvent( |
173 | sys.exit(1) | 187 | msg_fmt % (len(err_projects)), msg_fmt |
188 | ) | ||
189 | raise StartError(aggregate_errors=err) | ||