~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

(jelmer) Indicate current branch in 'bzr branches'. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1435
1435
                    self.outf.encoding).rstrip("/"))
1436
1436
        else:
1437
1437
            dir = controldir.ControlDir.open_containing(location)[0]
1438
 
            for branch in dir.list_branches():
1439
 
                if branch.name is None:
1440
 
                    self.outf.write(gettext(" (default)\n"))
 
1438
            try:
 
1439
                active_branch = dir.open_branch(name=None)
 
1440
            except errors.NotBranchError:
 
1441
                active_branch = None
 
1442
            branches = dir.get_branches()
 
1443
            names = {}
 
1444
            for name, branch in branches.iteritems():
 
1445
                if name is None:
 
1446
                    continue
 
1447
                active = (active_branch is not None and
 
1448
                          active_branch.base == branch.base)
 
1449
                names[name] = active
 
1450
            # Only mention the current branch explicitly if it's not
 
1451
            # one of the colocated branches
 
1452
            if not any(names.values()) and active_branch is not None:
 
1453
                self.outf.write("* %s\n" % gettext("(default)"))
 
1454
            for name in sorted(names.keys()):
 
1455
                active = names[name]
 
1456
                if active:
 
1457
                    prefix = "*"
1441
1458
                else:
1442
 
                    self.outf.write(" %s\n" % branch.name.encode(
1443
 
                        self.outf.encoding))
 
1459
                    prefix = " "
 
1460
                self.outf.write("%s %s\n" % (
 
1461
                    prefix, name.encode(self.outf.encoding)))
1444
1462
 
1445
1463
 
1446
1464
class cmd_checkout(Command):