summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-18 15:15:24 -0700
committerShawn O. Pearce <sop@google.com>2009-04-18 15:15:24 -0700
commit552ac89929db1794200290550dccdd7f3078d13f (patch)
tree1da257e391ce65db9ba34fb954ebb9f95a1648ff /project.py
parent89e717d9481c0c69292a39f85599f5df8277b004 (diff)
downloadgit-repo-552ac89929db1794200290550dccdd7f3078d13f.tar.gz
Modify 'repo abandon' to be more like 'repo checkout' and 'repo start'
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py40
1 files changed, 30 insertions, 10 deletions
diff --git a/project.py b/project.py
index 029a80f4..3b9535eb 100644
--- a/project.py
+++ b/project.py
@@ -862,18 +862,38 @@ class Project(object):
862 def AbandonBranch(self, name): 862 def AbandonBranch(self, name):
863 """Destroy a local topic branch. 863 """Destroy a local topic branch.
864 """ 864 """
865 try: 865 rev = R_HEADS + name
866 tip_rev = self.bare_git.rev_parse(R_HEADS + name) 866 all = self.bare_ref.all
867 except GitError: 867 if rev not in all:
868 return 868 # Doesn't exist; assume already abandoned.
869 #
870 return True
871
872 head = self.work_git.GetHead()
873 if head == rev:
874 # We can't destroy the branch while we are sitting
875 # on it. Switch to a detached HEAD.
876 #
877 head = all[head]
869 878
870 if self.CurrentBranch == name: 879 rev = self.GetRemote(self.remote.name).ToLocal(self.revision)
871 self._Checkout( 880 if rev in all:
872 self.GetRemote(self.remote.name).ToLocal(self.revision), 881 revid = all[rev]
873 quiet=True) 882 elif IsId(rev):
883 revid = rev
884 else:
885 revid = None
874 886
875 cmd = ['branch', '-D', name] 887 if revid and head == revid:
876 GitCommand(self, cmd, capture_stdout=True).Wait() 888 _lwrite(os.path.join(self.worktree, '.git', HEAD),
889 '%s\n' % revid)
890 else:
891 self._Checkout(rev, quiet=True)
892
893 return GitCommand(self,
894 ['branch', '-D', name],
895 capture_stdout = True,
896 capture_stderr = True).Wait() == 0
877 897
878 def PruneHeads(self): 898 def PruneHeads(self):
879 """Prune any topic branches already merged into upstream. 899 """Prune any topic branches already merged into upstream.