summaryrefslogtreecommitdiffstats
path: root/subcmds/download.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/download.py')
-rw-r--r--subcmds/download.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/subcmds/download.py b/subcmds/download.py
index 475c0bc2..18e555be 100644
--- a/subcmds/download.py
+++ b/subcmds/download.py
@@ -16,11 +16,15 @@ import re
16import sys 16import sys
17 17
18from command import Command 18from command import Command
19from error import GitError, NoSuchProjectError 19from error import GitError, NoSuchProjectError, RepoExitError
20 20
21CHANGE_RE = re.compile(r"^([1-9][0-9]*)(?:[/\.-]([1-9][0-9]*))?$") 21CHANGE_RE = re.compile(r"^([1-9][0-9]*)(?:[/\.-]([1-9][0-9]*))?$")
22 22
23 23
24class DownloadCommandError(RepoExitError):
25 """Error raised when download command fails."""
26
27
24class Download(Command): 28class Download(Command):
25 COMMON = True 29 COMMON = True
26 helpSummary = "Download and checkout a change" 30 helpSummary = "Download and checkout a change"
@@ -137,15 +141,16 @@ If no project is specified try to use current directory as a project.
137 ) 141 )
138 142
139 def Execute(self, opt, args): 143 def Execute(self, opt, args):
144 try:
145 self._ExecuteHelper(opt, args)
146 except Exception as e:
147 if isinstance(e, RepoExitError):
148 raise e
149 raise DownloadCommandError(aggregate_errors=[e])
150
151 def _ExecuteHelper(self, opt, args):
140 for project, change_id, ps_id in self._ParseChangeIds(opt, args): 152 for project, change_id, ps_id in self._ParseChangeIds(opt, args):
141 dl = project.DownloadPatchSet(change_id, ps_id) 153 dl = project.DownloadPatchSet(change_id, ps_id)
142 if not dl:
143 print(
144 "[%s] change %d/%d not found"
145 % (project.name, change_id, ps_id),
146 file=sys.stderr,
147 )
148 sys.exit(1)
149 154
150 if not opt.revert and not dl.commits: 155 if not opt.revert and not dl.commits:
151 print( 156 print(
@@ -201,4 +206,4 @@ If no project is specified try to use current directory as a project.
201 % (project.name, mode, dl.commit), 206 % (project.name, mode, dl.commit),
202 file=sys.stderr, 207 file=sys.stderr,
203 ) 208 )
204 sys.exit(1) 209 raise