~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
998
998
        repo_name = old_fmt.repository_format.network_name()
999
999
        # Should end up with a 1.9 format (stackable)
1000
1000
        repo, control = self.assertInitializeEx(t, need_meta=True,
1001
 
            repo_format_name=repo_name, stacked_on='../trunk', stack_on_pwd=t.base)
 
1001
            repo_format_name=repo_name, stacked_on='../trunk',
 
1002
            stack_on_pwd=t.base)
1002
1003
        if control is None:
1003
1004
            # uninitialisable format
1004
1005
            return
1282
1283
        self.assertIsInstance(opened_tree, made_tree.__class__)
1283
1284
        self.assertIsInstance(opened_tree._format, made_tree._format.__class__)
1284
1285
 
 
1286
    def test_get_selected_branch(self):
 
1287
        # The segment parameters are accessible from the root transport
 
1288
        # if a URL with segment parameters is opened.
 
1289
        if not self.bzrdir_format.is_supported():
 
1290
            # unsupported formats are not loopback testable
 
1291
            # because the default open will not open them and
 
1292
            # they may not be initializable.
 
1293
            return
 
1294
        t = self.get_transport()
 
1295
        try:
 
1296
            made_control = self.bzrdir_format.initialize(t.base)
 
1297
        except (errors.NotLocalUrl, errors.UnsupportedOperation):
 
1298
            raise TestSkipped("Can't initialize %r on transport %r"
 
1299
                              % (self.bzrdir_format, t))
 
1300
        dir = bzrdir.BzrDir.open(t.base+",branch=foo")
 
1301
        self.assertEquals({"branch": "foo"},
 
1302
            dir.user_transport.get_segment_parameters())
 
1303
        self.assertEquals("foo", dir._get_selected_branch())
 
1304
 
 
1305
    def test_get_selected_branch_none_selected(self):
 
1306
        # _get_selected_branch defaults to None
 
1307
        if not self.bzrdir_format.is_supported():
 
1308
            # unsupported formats are not loopback testable
 
1309
            # because the default open will not open them and
 
1310
            # they may not be initializable.
 
1311
            return
 
1312
        t = self.get_transport()
 
1313
        try:
 
1314
            made_control = self.bzrdir_format.initialize(t.base)
 
1315
        except (errors.NotLocalUrl, errors.UnsupportedOperation):
 
1316
            raise TestSkipped("Can't initialize %r on transport %r"
 
1317
                              % (self.bzrdir_format, t))
 
1318
        dir = bzrdir.BzrDir.open(t.base)
 
1319
        self.assertIs(None, dir._get_selected_branch())
 
1320
 
1285
1321
    def test_root_transport(self):
1286
1322
        dir = self.make_bzrdir('.')
1287
1323
        self.assertEqual(dir.root_transport.base,