~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: jelmer at samba
  • Date: 2011-10-11 12:01:51 UTC
  • mto: This revision was merged to the branch mainline in revision 6214.
  • Revision ID: jelmer@samba.org-20111011120151-l1aa35zasaocrev3
Fix tests and the like.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    bugtracker,
30
30
    bundle,
31
31
    btree_index,
32
 
    bzrdir,
 
32
    controldir,
33
33
    directory_service,
34
34
    delta,
35
35
    config as _mod_config,
197
197
    the --directory option is used to specify a different branch."""
198
198
    if directory is not None:
199
199
        return (None, Branch.open(directory), filename)
200
 
    return bzrdir.BzrDir.open_containing_tree_or_branch(filename)
 
200
    return controldir.ControlDir.open_containing_tree_or_branch(filename)
201
201
 
202
202
 
203
203
# TODO: Make sure no commands unconditionally use the working directory as a
339
339
            raise errors.BzrCommandError(gettext('You must supply either'
340
340
                                         ' --revision or a revision_id'))
341
341
 
342
 
        b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
 
342
        b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
343
343
 
344
344
        revisions = b.repository.revisions
345
345
        if revisions is None:
473
473
            location_list=['.']
474
474
 
475
475
        for location in location_list:
476
 
            d = bzrdir.BzrDir.open(location)
477
 
            
 
476
            d = controldir.ControlDir.open(location)
 
477
 
478
478
            try:
479
479
                working = d.open_workingtree()
480
480
            except errors.NoWorkingTree:
1185
1185
            directory = '.'
1186
1186
        # Get the source branch
1187
1187
        (tree, br_from,
1188
 
         _unused) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
 
1188
         _unused) = controldir.ControlDir.open_containing_tree_or_branch(directory)
1189
1189
        # Get the tip's revision_id
1190
1190
        revision = _get_one_revision('push', revision)
1191
1191
        if revision is not None:
1288
1288
                deprecated_name=self.invoked_as,
1289
1289
                recommended_name='branch',
1290
1290
                deprecated_in_version='2.4')
1291
 
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
 
1291
        accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
1292
1292
            from_location)
1293
1293
        if not (hardlink or files_from):
1294
1294
            # accelerator_tree is usually slower because you have to read N
1317
1317
                    'already exists.') % to_location)
1318
1318
            else:
1319
1319
                try:
1320
 
                    bzrdir.BzrDir.open_from_transport(to_transport)
 
1320
                    controldir.ControlDir.open_from_transport(to_transport)
1321
1321
                except errors.NotBranchError:
1322
1322
                    pass
1323
1323
                else:
1382
1382
            if not t.listable():
1383
1383
                raise errors.BzrCommandError(
1384
1384
                    "Can't scan this type of location.")
1385
 
            for b in bzrdir.BzrDir.find_branches(t):
 
1385
            for b in controldir.ControlDir.find_branches(t):
1386
1386
                self.outf.write("%s\n" % urlutils.unescape_for_display(
1387
1387
                    urlutils.relative_url(t.base, b.base),
1388
1388
                    self.outf.encoding).rstrip("/"))
1389
1389
        else:
1390
 
            dir = bzrdir.BzrDir.open_containing(location)[0]
 
1390
            dir = controldir.ControlDir.open_containing(location)[0]
1391
1391
            for branch in dir.list_branches():
1392
1392
                if branch.name is None:
1393
1393
                    self.outf.write(gettext(" (default)\n"))
1440
1440
        if branch_location is None:
1441
1441
            branch_location = osutils.getcwd()
1442
1442
            to_location = branch_location
1443
 
        accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(
 
1443
        accelerator_tree, source = controldir.ControlDir.open_tree_or_branch(
1444
1444
            branch_location)
1445
1445
        if not (hardlink or files_from):
1446
1446
            # accelerator_tree is usually slower because you have to read N
1654
1654
        else:
1655
1655
            noise_level = 0
1656
1656
        from bzrlib.info import show_bzrdir_info
1657
 
        show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
 
1657
        show_bzrdir_info(controldir.ControlDir.open_containing(location)[0],
1658
1658
                         verbose=noise_level, outfile=self.outf)
1659
1659
 
1660
1660
 
1792
1792
 
1793
1793
    def run(self, branch=".", canonicalize_chks=False):
1794
1794
        from bzrlib.reconcile import reconcile
1795
 
        dir = bzrdir.BzrDir.open(branch)
 
1795
        dir = controldir.ControlDir.open(branch)
1796
1796
        reconcile(dir, canonicalize_chks=canonicalize_chks)
1797
1797
 
1798
1798
 
1874
1874
                help='Specify a format for this branch. '
1875
1875
                'See "help formats".',
1876
1876
                lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1877
 
                converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
1877
                converter=lambda name: controldir.format_registry.make_bzrdir(name),
1878
1878
                value_switches=True,
1879
1879
                title="Branch format",
1880
1880
                ),
1887
1887
    def run(self, location=None, format=None, append_revisions_only=False,
1888
1888
            create_prefix=False, no_tree=False):
1889
1889
        if format is None:
1890
 
            format = bzrdir.format_registry.make_bzrdir('default')
 
1890
            format = controldir.format_registry.make_bzrdir('default')
1891
1891
        if location is None:
1892
1892
            location = u'.'
1893
1893
 
1910
1910
            to_transport.create_prefix()
1911
1911
 
1912
1912
        try:
1913
 
            a_bzrdir = bzrdir.BzrDir.open_from_transport(to_transport)
 
1913
            a_bzrdir = controldir.ControlDir.open_from_transport(to_transport)
1914
1914
        except errors.NotBranchError:
1915
1915
            # really a NotBzrDir error...
1916
 
            create_branch = bzrdir.BzrDir.create_branch_convenience
 
1916
            create_branch = controldir.ControlDir.create_branch_convenience
1917
1917
            if no_tree:
1918
1918
                force_new_tree = False
1919
1919
            else:
1992
1992
    takes_options = [RegistryOption('format',
1993
1993
                            help='Specify a format for this repository. See'
1994
1994
                                 ' "bzr help formats" for details.',
1995
 
                            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1996
 
                            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
1995
                            lazy_registry=('bzrlib.controldir', 'format_registry'),
 
1996
                            converter=lambda name: controldir.format_registry.make_bzrdir(name),
1997
1997
                            value_switches=True, title='Repository format'),
1998
1998
                     Option('no-trees',
1999
1999
                             help='Branches in the repository will default to'
2003
2003
 
2004
2004
    def run(self, location, format=None, no_trees=False):
2005
2005
        if format is None:
2006
 
            format = bzrdir.format_registry.make_bzrdir('default')
 
2006
            format = controldir.format_registry.make_bzrdir('default')
2007
2007
 
2008
2008
        if location is None:
2009
2009
            location = '.'
2614
2614
                location = revision[0].get_branch()
2615
2615
            else:
2616
2616
                location = '.'
2617
 
            dir, relpath = bzrdir.BzrDir.open_containing(location)
 
2617
            dir, relpath = controldir.ControlDir.open_containing(location)
2618
2618
            b = dir.open_branch()
2619
2619
            self.add_cleanup(b.lock_read().unlock)
2620
2620
            rev1, rev2 = _get_revision_range(revision, b, self.name())
3603
3603
        RegistryOption('format',
3604
3604
            help='Upgrade to a specific format.  See "bzr help'
3605
3605
                 ' formats" for details.',
3606
 
            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3607
 
            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
3606
            lazy_registry=('bzrlib.controldir', 'format_registry'),
 
3607
            converter=lambda name: controldir.format_registry.make_bzrdir(name),
3608
3608
            value_switches=True, title='Branch format'),
3609
3609
        Option('clean',
3610
3610
            help='Remove the backup.bzr directory if successful.'),
4855
4855
        ]
4856
4856
 
4857
4857
    def run(self, branch_or_repo='.', clean_obsolete_packs=False):
4858
 
        dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
 
4858
        dir = controldir.ControlDir.open_containing(branch_or_repo)[0]
4859
4859
        try:
4860
4860
            branch = dir.open_branch()
4861
4861
            repository = branch.repository
5138
5138
            revision=None, force=False, local=False, keep_tags=False):
5139
5139
        if location is None:
5140
5140
            location = u'.'
5141
 
        control, relpath = bzrdir.BzrDir.open_containing(location)
 
5141
        control, relpath = controldir.ControlDir.open_containing(location)
5142
5142
        try:
5143
5143
            tree = control.open_workingtree()
5144
5144
            b = tree.branch
5248
5248
            conf = _mod_config.LockableConfig(file_name=location)
5249
5249
            conf.break_lock()
5250
5250
        else:
5251
 
            control, relpath = bzrdir.BzrDir.open_containing(location)
 
5251
            control, relpath = controldir.ControlDir.open_containing(location)
5252
5252
            try:
5253
5253
                control.break_lock()
5254
5254
            except NotImplementedError:
5939
5939
    def run(self, location=None, bind_to=None, force=False,
5940
5940
            tree_type=None, repository_type=None, repository_trees=None,
5941
5941
            stacked_on=None, unstacked=None):
5942
 
        directory = bzrdir.BzrDir.open(location)
 
5942
        directory = controldir.ControlDir.open(location)
5943
5943
        if stacked_on and unstacked:
5944
5944
            raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5945
5945
        elif stacked_on is not None:
6027
6027
        from bzrlib import switch
6028
6028
        tree_location = directory
6029
6029
        revision = _get_one_revision('switch', revision)
6030
 
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
 
6030
        control_dir = controldir.ControlDir.open_containing(tree_location)[0]
6031
6031
        if to_location is None:
6032
6032
            if revision is None:
6033
6033
                raise errors.BzrCommandError(gettext('You must supply either a'
6460
6460
        if path is not None:
6461
6461
            branchdir = path
6462
6462
        tree, branch, relpath =(
6463
 
            bzrdir.BzrDir.open_containing_tree_or_branch(branchdir))
 
6463
            controldir.ControlDir.open_containing_tree_or_branch(branchdir))
6464
6464
        if path is not None:
6465
6465
            path = relpath
6466
6466
        if tree is None: