Rev 6082: (jelmer) Add a "bzr branches" command. (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Aug 18 04:23:24 UTC 2011


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

------------------------------------------------------------
revno: 6082 [merge]
revision-id: pqm at pqm.ubuntu.com-20110818042306-neji85pljf86z885
parent: pqm at pqm.ubuntu.com-20110818010018-zs13cq955e0hc335
parent: jelmer at samba.org-20110817093659-gjeempouhga9agnt
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-08-18 04:23:06 +0000
message:
  (jelmer) Add a "bzr branches" command. (Jelmer Vernooij)
added:
  bzrlib/tests/blackbox/test_branches.py test_branches.py-20110815154803-0t6tna5x9ud2osj3-1
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2011-08-18 01:00:18 +0000
+++ b/bzrlib/builtins.py	2011-08-18 04:23:06 +0000
@@ -1334,6 +1334,23 @@
                 urlutils.unescape_for_display(branch.base, 'utf-8'))
 
 
+class cmd_branches(Command):
+    __doc__ = """List the branches available at the current location.
+
+    This command will print the names of all the branches at the current location.
+    """
+
+    takes_args = ['location?']
+
+    def run(self, location="."):
+        dir = bzrdir.BzrDir.open_containing(location)[0]
+        for branch in dir.list_branches():
+            if branch.name is None:
+                self.outf.write(" (default)\n")
+            else:
+                self.outf.write(" %s\n" % branch.name.encode(self.outf.encoding))
+
+
 class cmd_checkout(Command):
     __doc__ = """Create a new checkout of an existing branch.
 

=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py	2011-05-20 13:34:24 +0000
+++ b/bzrlib/tests/blackbox/__init__.py	2011-08-15 15:48:12 +0000
@@ -44,6 +44,7 @@
                      'test_ancestry',
                      'test_annotate',
                      'test_branch',
+                     'test_branches',
                      'test_break_lock',
                      'test_bound_branches',
                      'test_bundle_info',

=== added file 'bzrlib/tests/blackbox/test_branches.py'
--- a/bzrlib/tests/blackbox/test_branches.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_branches.py	2011-08-15 15:48:12 +0000
@@ -0,0 +1,43 @@
+# Copyright (C) 2011 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 branches."""
+
+from bzrlib.tests import TestCaseWithTransport
+
+
+class TestBranches(TestCaseWithTransport):
+
+    def test_no_colocated_support(self):
+        # Listing the branches in a control directory without colocated branch
+        # support.
+        self.run_bzr('init a')
+        out, err = self.run_bzr('branches a')
+        self.assertEquals(out, " (default)\n")
+
+    def test_no_branch(self):
+        # Listing the branches in a control directory without branches.
+        self.run_bzr('init-repo a')
+        out, err = self.run_bzr('branches a')
+        self.assertEquals(out, "")
+
+    def test_default_current_dir(self):
+        # "bzr branches" list the branches in the current directory
+        # if no location was specified.
+        self.run_bzr('init-repo a')
+        out, err = self.run_bzr('branches', working_dir='a')
+        self.assertEquals(out, "")

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-08-18 01:00:18 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-08-18 04:23:06 +0000
@@ -64,13 +64,16 @@
   encountered. 'warning' and 'eeror' will respectively emit a warning and
   ignore the value or errors out. (Vincent Ladeuil)
 
+* ``bzr help configuration/<option>`` display the help for ``option`` for
+  all registered configuration options. (Vincent Ladeuil, #747050)
+
 * bzr log -m now matches message, author, committer and bugs instead
   of just matching the message.  --message keeps its original meaning,
   while --match-message, --match-author, --match-committer and
   --match-bugs match each of those fields.
 
-* ``bzr help configuration/<option>`` display the help for ``option`` for
-  all registered configuration options. (Vincent Ladeuil, #747050)
+* New builtin ``bzr branches`` command, which lists all colocated branches
+  in a directory. (Jelmer Vernooij, #826820)
 
 * Relative local paths can now be specified in URL syntax by using the
   "file:" prefix.  (Jelmer Vernooij)




More information about the bazaar-commits mailing list