Rev 6396: (jelmer) Indicate current branch in 'bzr branches'. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 21 16:52:41 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6396 [merge]
revision-id: pqm at pqm.ubuntu.com-20111221165239-5jak0hiyb0857m74
parent: pqm at pqm.ubuntu.com-20111221153234-kbq1axff8pe224vt
parent: jelmer at samba.org-20111221162624-uod8d0ncnumv4qhp
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-12-21 16:52:39 +0000
message:
(jelmer) Indicate current branch in 'bzr branches'. (Jelmer Vernooij)
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
bzrlib/tests/blackbox/test_branches.py test_branches.py-20110815154803-0t6tna5x9ud2osj3-1
bzrlib/tests/blackbox/test_init.py test_init.py-20060309032856-a292116204d86eb7
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2011-12-20 18:47:35 +0000
+++ b/bzrlib/builtins.py 2011-12-21 16:52:39 +0000
@@ -1435,12 +1435,30 @@
self.outf.encoding).rstrip("/"))
else:
dir = controldir.ControlDir.open_containing(location)[0]
- for branch in dir.list_branches():
- if branch.name is None:
- self.outf.write(gettext(" (default)\n"))
+ try:
+ active_branch = dir.open_branch(name=None)
+ except errors.NotBranchError:
+ active_branch = None
+ branches = dir.get_branches()
+ names = {}
+ for name, branch in branches.iteritems():
+ if name is None:
+ continue
+ active = (active_branch is not None and
+ active_branch.base == branch.base)
+ names[name] = active
+ # Only mention the current branch explicitly if it's not
+ # one of the colocated branches
+ if not any(names.values()) and active_branch is not None:
+ self.outf.write("* %s\n" % gettext("(default)"))
+ for name in sorted(names.keys()):
+ active = names[name]
+ if active:
+ prefix = "*"
else:
- self.outf.write(" %s\n" % branch.name.encode(
- self.outf.encoding))
+ prefix = " "
+ self.outf.write("%s %s\n" % (
+ prefix, name.encode(self.outf.encoding)))
class cmd_checkout(Command):
=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py 2011-12-14 20:08:26 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py 2011-12-21 14:28:03 +0000
@@ -79,7 +79,7 @@
self.assertEqual('', out)
self.assertEqual('Branched 2 revisions.\n', err)
out, err = self.run_bzr('branches b')
- self.assertEqual(" thiswasa\n orig\n", out)
+ self.assertEqual(" orig\n thiswasa\n", out)
self.assertEqual('', err)
out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
self.assertEqual('', out)
=== modified file 'bzrlib/tests/blackbox/test_branches.py'
--- a/bzrlib/tests/blackbox/test_branches.py 2011-08-30 09:03:33 +0000
+++ b/bzrlib/tests/blackbox/test_branches.py 2011-12-21 14:28:03 +0000
@@ -17,6 +17,7 @@
"""Black-box tests for bzr branches."""
+from bzrlib.branch import BranchReferenceFormat
from bzrlib.tests import TestCaseWithTransport
@@ -27,7 +28,7 @@
# support.
self.run_bzr('init a')
out, err = self.run_bzr('branches a')
- self.assertEquals(out, " (default)\n")
+ self.assertEquals(out, "* (default)\n")
def test_no_branch(self):
# Listing the branches in a control directory without branches.
@@ -58,3 +59,21 @@
self.assertIs(True, 'source/subsource' in lines, lines)
self.assertIs(True, 'checkout/subcheckout' in lines, lines)
self.assertIs(True, 'checkout' not in lines, lines)
+
+ def test_indicates_non_branch(self):
+ t = self.make_branch_and_tree('a', format='development-colo')
+ t.bzrdir.create_branch(name='another')
+ t.bzrdir.create_branch(name='colocated')
+ out, err = self.run_bzr('branches a')
+ self.assertEquals(out, "* (default)\n"
+ " another\n"
+ " colocated\n")
+
+ def test_indicates_branch(self):
+ t = self.make_repository('a', format='development-colo')
+ t.bzrdir.create_branch(name='another')
+ branch = t.bzrdir.create_branch(name='colocated')
+ BranchReferenceFormat().initialize(t.bzrdir, target_branch=branch)
+ out, err = self.run_bzr('branches a')
+ self.assertEquals(out, " another\n"
+ "* colocated\n")
=== modified file 'bzrlib/tests/blackbox/test_init.py'
--- a/bzrlib/tests/blackbox/test_init.py 2011-11-17 17:24:57 +0000
+++ b/bzrlib/tests/blackbox/test_init.py 2011-12-21 16:26:24 +0000
@@ -61,7 +61,7 @@
out)
self.assertEqual('', err)
out, err = self.run_bzr('branches')
- self.assertEqual(" abranch\n", out)
+ self.assertEqual(" abranch\n", out)
self.assertEqual('', err)
def test_init_at_repository_root(self):
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-12-21 15:32:34 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-12-21 16:52:39 +0000
@@ -46,6 +46,9 @@
will mean bzr works with non-ascii files when no locale or an incorrect
locale is set. (Martin Packman, #794353)
+* ``bzr branches`` now indicates the active colocated branch.
+ (Jelmer Vernooij, #891667)
+
* ``bzr send`` now only opens a single connection, rather than two,
to the target branch. (Jelmer Vernooij)
More information about the bazaar-commits
mailing list