Rev 5105: (Jelmer) Add rmbranch command. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Mar 22 11:39:18 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5105 [merge]
revision-id: pqm at pqm.ubuntu.com-20100322113916-cwzfq5olk75uzs20
parent: pqm at pqm.ubuntu.com-20100322022224-uie280enmzfd9xzs
parent: jelmer at samba.org-20100322101100-5omqm0h278vmvv1e
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-03-22 11:39:16 +0000
message:
  (Jelmer) Add rmbranch command.
added:
  bzrlib/tests/blackbox/test_rmbranch.py test_rmbranch.py-20100131150653-auenl06hu4y2d9tr-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
=== modified file 'NEWS'
--- a/NEWS	2010-03-19 12:10:28 +0000
+++ b/NEWS	2010-03-22 11:39:16 +0000
@@ -37,6 +37,9 @@
 New Features
 ************
 
+* Added ``bzr remove-branch`` command that can remove a local or remote 
+  branch. (Jelmer Vernooij, #276295)
+
 * ``bzr export`` now takes an optional argument ``--per-file-timestamps``
   to set file mtimes to the last timestamp of the last revision in which
   they were changed rather than the current time. (Jelmer Vernooij)

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-03-19 08:06:29 +0000
+++ b/bzrlib/builtins.py	2010-03-22 11:39:16 +0000
@@ -5749,6 +5749,31 @@
                     self.outf.write("    <no hooks installed>\n")
 
 
+class cmd_remove_branch(Command):
+    """Remove a branch.
+
+    This will remove the branch from the specified location but 
+    will keep any working tree or repository in place.
+
+    :Examples:
+
+      Remove the branch at repo/trunk::
+
+        bzr remove-branch repo/trunk
+
+    """
+
+    takes_args = ["location?"]
+
+    aliases = ["rmbranch"]
+
+    def run(self, location=None):
+        if location is None:
+            location = "."
+        branch = Branch.open_containing(location)[0]
+        branch.bzrdir.destroy_branch()
+        
+
 class cmd_shelve(Command):
     """Temporarily set aside some changes from the current tree.
 

=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py	2009-04-29 20:31:34 +0000
+++ b/bzrlib/tests/blackbox/__init__.py	2010-01-31 15:11:43 +0000
@@ -95,6 +95,7 @@
                      'bzrlib.tests.blackbox.test_revno',
                      'bzrlib.tests.blackbox.test_revision_history',
                      'bzrlib.tests.blackbox.test_revision_info',
+                     'bzrlib.tests.blackbox.test_rmbranch',
                      'bzrlib.tests.blackbox.test_selftest',
                      'bzrlib.tests.blackbox.test_send',
                      'bzrlib.tests.blackbox.test_serve',

=== added file 'bzrlib/tests/blackbox/test_rmbranch.py'
--- a/bzrlib/tests/blackbox/test_rmbranch.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_rmbranch.py	2010-03-22 10:11:00 +0000
@@ -0,0 +1,59 @@
+# Copyright (C) 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+"""Black-box tests for bzr rmbranch."""
+
+from bzrlib import (
+    bzrdir,
+    )
+from bzrlib.tests.blackbox import (
+    ExternalBase,
+    )
+
+
+class TestRemoveBranch(ExternalBase):
+
+    def example_branch(self, path='.'):
+        tree = self.make_branch_and_tree(path)
+        self.build_tree_contents([(path + '/hello', 'foo')])
+        tree.add('hello')
+        tree.commit(message='setup')
+        self.build_tree_contents([(path + '/goodbye', 'baz')])
+        tree.add('goodbye')
+        tree.commit(message='setup')
+
+    def test_remove_local(self):
+        # Remove a local branch.
+        self.example_branch('a')
+        self.run_bzr('rmbranch a')
+        dir = bzrdir.BzrDir.open('a')
+        self.assertFalse(dir.has_branch())
+        self.failUnlessExists('a/hello')
+        self.failUnlessExists('a/goodbye')
+
+    def test_no_branch(self):
+        # No branch in the current directory. 
+        self.make_repository('a')
+        self.run_bzr_error(['Not a branch'],
+            'rmbranch a')
+
+    def test_no_arg(self):
+        # location argument defaults to current directory
+        self.example_branch('a')
+        self.run_bzr('rmbranch', working_dir='a')
+        dir = bzrdir.BzrDir.open('a')
+        self.assertFalse(dir.has_branch())




More information about the bazaar-commits mailing list