diff options
author | Doug Anderson <dianders@google.com> | 2011-04-07 11:46:59 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-04-07 16:49:23 -0400 |
commit | dafb1d68d33137779c96a83c7e42cac0e7a27ca4 (patch) | |
tree | e0e3c93d316c8cdf48a15fec97c458b391a6039e /subcmds | |
parent | 4655e81a75f2ea5f1eaf93de1249886171281e61 (diff) | |
download | git-repo-dafb1d68d33137779c96a83c7e42cac0e7a27ca4.tar.gz |
Fixed repo abandon to give better messages.
The main fix is to give an error message if nothing was actually
abandoned. See <http://crosbug.com/6041>.
The secondary fix is to list projects where the abandon happened.
This could be done in a separate CL or dropped altogether if requested.
TEST=manual
$ repo abandon dougabc; echo $?
Abandon dougabc: 100% (127/127), done.
Abandoned in 2 project(s):
chromite
src/platform/init
0
$ repo abandon dougabc; echo $?
Abandon dougabc: 100% (127/127), done.
error: no project has branch dougabc
1
$ repo abandon dougabc; echo $?
Abandon dougabc: 100% (127/127), done.
error: chromite/: cannot abandon dougabc
1
Change-Id: I79520cc3279291acadc1a24ca34a761e9de04ed4
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/abandon.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index 8af61327..42abb2ff 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py | |||
@@ -41,21 +41,30 @@ It is equivalent to "git branch -D <branchname>". | |||
41 | 41 | ||
42 | nb = args[0] | 42 | nb = args[0] |
43 | err = [] | 43 | err = [] |
44 | success = [] | ||
44 | all = self.GetProjects(args[1:]) | 45 | all = self.GetProjects(args[1:]) |
45 | 46 | ||
46 | pm = Progress('Abandon %s' % nb, len(all)) | 47 | pm = Progress('Abandon %s' % nb, len(all)) |
47 | for project in all: | 48 | for project in all: |
48 | pm.update() | 49 | pm.update() |
49 | if not project.AbandonBranch(nb): | 50 | |
50 | err.append(project) | 51 | status = project.AbandonBranch(nb) |
52 | if status is not None: | ||
53 | if status: | ||
54 | success.append(project) | ||
55 | else: | ||
56 | err.append(project) | ||
51 | pm.end() | 57 | pm.end() |
52 | 58 | ||
53 | if err: | 59 | if err: |
54 | if len(err) == len(all): | 60 | for p in err: |
55 | print >>sys.stderr, 'error: no project has branch %s' % nb | 61 | print >>sys.stderr,\ |
56 | else: | 62 | "error: %s/: cannot abandon %s" \ |
57 | for p in err: | 63 | % (p.relpath, nb) |
58 | print >>sys.stderr,\ | 64 | sys.exit(1) |
59 | "error: %s/: cannot abandon %s" \ | 65 | elif not success: |
60 | % (p.relpath, nb) | 66 | print >>sys.stderr, 'error: no project has branch %s' % nb |
61 | sys.exit(1) | 67 | sys.exit(1) |
68 | else: | ||
69 | print >>sys.stderr, 'Abandoned in %d project(s):\n %s' % ( | ||
70 | len(success), '\n '.join(p.relpath for p in success)) | ||