summaryrefslogtreecommitdiffstats
path: root/subcmds/abandon.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/abandon.py')
-rw-r--r--subcmds/abandon.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/subcmds/abandon.py b/subcmds/abandon.py
index ded287f6..896b348f 100644
--- a/subcmds/abandon.py
+++ b/subcmds/abandon.py
@@ -20,6 +20,11 @@ import sys
20from command import Command, DEFAULT_LOCAL_JOBS 20from command import Command, DEFAULT_LOCAL_JOBS
21from git_command import git 21from git_command import git
22from progress import Progress 22from progress import Progress
23from error import RepoError, RepoExitError
24
25
26class AbandonError(RepoExitError):
27 """Exit error when abandon command fails."""
23 28
24 29
25class Abandon(Command): 30class Abandon(Command):
@@ -68,28 +73,37 @@ It is equivalent to "git branch -D <branchname>".
68 branches = nb 73 branches = nb
69 74
70 ret = {} 75 ret = {}
76 errors = []
71 for name in branches: 77 for name in branches:
72 status = project.AbandonBranch(name) 78 status = None
79 try:
80 status = project.AbandonBranch(name)
81 except RepoError as e:
82 status = False
83 errors.append(e)
73 if status is not None: 84 if status is not None:
74 ret[name] = status 85 ret[name] = status
75 return (ret, project) 86
87 return (ret, project, errors)
76 88
77 def Execute(self, opt, args): 89 def Execute(self, opt, args):
78 nb = args[0].split() 90 nb = args[0].split()
79 err = defaultdict(list) 91 err = defaultdict(list)
80 success = defaultdict(list) 92 success = defaultdict(list)
93 aggregate_errors = []
81 all_projects = self.GetProjects( 94 all_projects = self.GetProjects(
82 args[1:], all_manifests=not opt.this_manifest_only 95 args[1:], all_manifests=not opt.this_manifest_only
83 ) 96 )
84 _RelPath = lambda p: p.RelPath(local=opt.this_manifest_only) 97 _RelPath = lambda p: p.RelPath(local=opt.this_manifest_only)
85 98
86 def _ProcessResults(_pool, pm, states): 99 def _ProcessResults(_pool, pm, states):
87 for results, project in states: 100 for results, project, errors in states:
88 for branch, status in results.items(): 101 for branch, status in results.items():
89 if status: 102 if status:
90 success[branch].append(project) 103 success[branch].append(project)
91 else: 104 else:
92 err[branch].append(project) 105 err[branch].append(project)
106 aggregate_errors.extend(errors)
93 pm.update(msg="") 107 pm.update(msg="")
94 108
95 self.ExecuteInParallel( 109 self.ExecuteInParallel(
@@ -116,13 +130,13 @@ It is equivalent to "git branch -D <branchname>".
116 " " * len(err_msg) + " | %s" % _RelPath(proj), 130 " " * len(err_msg) + " | %s" % _RelPath(proj),
117 file=sys.stderr, 131 file=sys.stderr,
118 ) 132 )
119 sys.exit(1) 133 raise AbandonError(aggregate_errors=aggregate_errors)
120 elif not success: 134 elif not success:
121 print( 135 print(
122 "error: no project has local branch(es) : %s" % nb, 136 "error: no project has local branch(es) : %s" % nb,
123 file=sys.stderr, 137 file=sys.stderr,
124 ) 138 )
125 sys.exit(1) 139 raise AbandonError(aggregate_errors=aggregate_errors)
126 else: 140 else:
127 # Everything below here is displaying status. 141 # Everything below here is displaying status.
128 if opt.quiet: 142 if opt.quiet: