~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-05 16:03:11 UTC
  • mfrom: (6432 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6433.
  • Revision ID: jelmer@samba.org-20120105160311-12o5p67kin1v3zps
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""builtin bzr commands"""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import os
20
22
 
21
23
import bzrlib.bzrdir
22
24
 
23
 
from bzrlib.lazy_import import lazy_import
24
 
lazy_import(globals(), """
 
25
from bzrlib import lazy_import
 
26
lazy_import.lazy_import(globals(), """
25
27
import cStringIO
26
28
import errno
27
29
import sys
1249
1251
        if location is None:
1250
1252
            stored_loc = br_from.get_push_location()
1251
1253
            if stored_loc is None:
1252
 
                raise errors.BzrCommandError(gettext(
1253
 
                    "No push location known or specified."))
 
1254
                parent_loc = br_from.get_parent()
 
1255
                if parent_loc:
 
1256
                    raise errors.BzrCommandError(gettext(
 
1257
                        "No push location known or specified. To push to the "
 
1258
                        "parent branch (at %s), use 'bzr push :parent'." %
 
1259
                        urlutils.unescape_for_display(parent_loc,
 
1260
                            self.outf.encoding)))
 
1261
                else:
 
1262
                    raise errors.BzrCommandError(gettext(
 
1263
                        "No push location known or specified."))
1254
1264
            else:
1255
1265
                display_url = urlutils.unescape_for_display(stored_loc,
1256
1266
                        self.outf.encoding)
1433
1443
                    self.outf.encoding).rstrip("/"))
1434
1444
        else:
1435
1445
            dir = controldir.ControlDir.open_containing(location)[0]
1436
 
            for branch in dir.list_branches():
1437
 
                if branch.name is None:
1438
 
                    self.outf.write(gettext(" (default)\n"))
 
1446
            try:
 
1447
                active_branch = dir.open_branch(name=None)
 
1448
            except errors.NotBranchError:
 
1449
                active_branch = None
 
1450
            branches = dir.get_branches()
 
1451
            names = {}
 
1452
            for name, branch in branches.iteritems():
 
1453
                if name is None:
 
1454
                    continue
 
1455
                active = (active_branch is not None and
 
1456
                          active_branch.base == branch.base)
 
1457
                names[name] = active
 
1458
            # Only mention the current branch explicitly if it's not
 
1459
            # one of the colocated branches
 
1460
            if not any(names.values()) and active_branch is not None:
 
1461
                self.outf.write("* %s\n" % gettext("(default)"))
 
1462
            for name in sorted(names.keys()):
 
1463
                active = names[name]
 
1464
                if active:
 
1465
                    prefix = "*"
1439
1466
                else:
1440
 
                    self.outf.write(" %s\n" % branch.name.encode(
1441
 
                        self.outf.encoding))
 
1467
                    prefix = " "
 
1468
                self.outf.write("%s %s\n" % (
 
1469
                    prefix, name.encode(self.outf.encoding)))
1442
1470
 
1443
1471
 
1444
1472
class cmd_checkout(Command):
2058
2086
            location = '.'
2059
2087
 
2060
2088
        to_transport = transport.get_transport(location)
2061
 
        to_transport.ensure_base()
2062
2089
 
2063
 
        newdir = format.initialize_on_transport(to_transport)
2064
 
        repo = newdir.create_repository(shared=True)
2065
 
        repo.set_make_working_trees(not no_trees)
 
2090
        (repo, newdir, require_stacking, repository_policy) = (
 
2091
            format.initialize_on_transport_ex(to_transport,
 
2092
            create_prefix=True, make_working_trees=not no_trees,
 
2093
            shared_repo=True, force_new_repo=True,
 
2094
            use_existing_dir=True,
 
2095
            repo_format_name=format.repository_format.get_format_string()))
2066
2096
        if not is_quiet():
2067
2097
            from bzrlib.info import show_bzrdir_info
2068
 
            show_bzrdir_info(repo.bzrdir, verbose=0, outfile=self.outf)
 
2098
            show_bzrdir_info(newdir, verbose=0, outfile=self.outf)
2069
2099
 
2070
2100
 
2071
2101
class cmd_diff(Command):
3974
4004
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3975
4005
            parallel=None, lsprof_tests=False,
3976
4006
            sync=False):
 
4007
 
 
4008
        # During selftest, disallow proxying, as it can cause severe
 
4009
        # performance penalties and is only needed for thread
 
4010
        # safety. The selftest command is assumed to not use threads
 
4011
        # too heavily. The call should be as early as possible, as
 
4012
        # error reporting for past duplicate imports won't have useful
 
4013
        # backtraces.
 
4014
        lazy_import.disallow_proxying()
 
4015
 
3977
4016
        from bzrlib import tests
3978
4017
 
3979
4018
        if testspecs_list is not None:
4693
4732
 
4694
4733
    @display_command
4695
4734
    def run(self, context=None):
4696
 
        import shellcomplete
 
4735
        from bzrlib import shellcomplete
4697
4736
        shellcomplete.shellcomplete(context)
4698
4737
 
4699
4738
 
5579
5618
                self.outf.writelines(directive.to_lines())
5580
5619
        else:
5581
5620
            message = directive.to_email(mail_to, branch, sign)
5582
 
            s = SMTPConnection(branch.get_config())
 
5621
            s = SMTPConnection(branch.get_config_stack())
5583
5622
            s.send_email(message)
5584
5623
 
5585
5624