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
diff --git a/project.py b/project.py
index 9d98041..7ba1b38 100644
--- a/project.py
+++ b/project.py
@@ -1204,13 +1204,19 @@
def AbandonBranch(self, name):
"""Destroy a local topic branch.
+
+ Args:
+ name: The name of the branch to abandon.
+
+ Returns:
+ True if the abandon succeeded; False if it didn't; None if the branch
+ didn't exist.
"""
rev = R_HEADS + name
all = self.bare_ref.all
if rev not in all:
- # Doesn't exist; assume already abandoned.
- #
- return True
+ # Doesn't exist
+ return None
head = self.work_git.GetHead()
if head == rev: