~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_bzrdir/test_bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
778
778
                                     './.bzr/repository/inventory.knit',
779
779
                                     ])
780
780
        try:
 
781
            local_inventory = dir.transport.local_abspath('inventory')
 
782
        except errors.NotLocalUrl:
 
783
            return
 
784
        try:
781
785
            # If we happen to have a tree, we'll guarantee everything
782
786
            # except for the tree root is the same.
783
 
            inventory_f = file(dir.transport.base+'inventory', 'rb')
 
787
            inventory_f = file(local_inventory, 'rb')
 
788
            self.addCleanup(inventory_f.close)
784
789
            self.assertContainsRe(inventory_f.read(),
785
 
                                  '<inventory file_id="TREE_ROOT[^"]*"'
786
 
                                  ' format="5">\n</inventory>\n')
787
 
            inventory_f.close()
 
790
                                  '<inventory format="5">\n</inventory>\n')
788
791
        except IOError, e:
789
792
            if e.errno != errno.ENOENT:
790
793
                raise
1173
1176
            # because the default open will not open them and
1174
1177
            # they may not be initializable.
1175
1178
            return
 
1179
        # for remote formats, there must be no prior assumption about the
 
1180
        # network name to use - it's possible that this may somehow have got
 
1181
        # in through an unisolated test though - see
 
1182
        # <https://bugs.edge.launchpad.net/bzr/+bug/504102>
 
1183
        self.assertEquals(getattr(self.bzrdir_format,
 
1184
            '_network_name', None),
 
1185
            None)
1176
1186
        # supported formats must be able to init and open
1177
1187
        t = get_transport(self.get_url())
1178
1188
        readonly_t = get_transport(self.get_readonly_url())
1232
1242
            return
1233
1243
        self.assertNotEqual(repo.bzrdir.root_transport.base,
1234
1244
            made_repo.bzrdir.root_transport.base)
1235
 
        # New repositories are write locked.
1236
 
        self.assertTrue(made_repo.is_write_locked())
1237
 
        made_repo.unlock()
1238
1245
 
1239
1246
    def test_format_initialize_on_transport_ex_force_new_repo_False(self):
1240
1247
        t = self.get_transport('repo')
1267
1274
            # uninitialisable format
1268
1275
            return
1269
1276
        self.assertLength(1, repo._fallback_repositories)
1270
 
        # New repositories are write locked.
1271
 
        self.assertTrue(repo.is_write_locked())
1272
 
        repo.unlock()
1273
1277
 
1274
1278
    def test_format_initialize_on_transport_ex_default_stack_on(self):
1275
1279
        # When initialize_on_transport_ex uses a stacked-on branch because of
1292
1296
        repo_name = repo_fmt.repository_format.network_name()
1293
1297
        repo, control = self.assertInitializeEx(
1294
1298
            t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
 
1299
        # self.addCleanup(repo.unlock)
1295
1300
        if control is None:
1296
1301
            # uninitialisable format
1297
1302
            return
1323
1328
            # must stay with the all-in-one-format.
1324
1329
            repo_name = self.bzrdir_format.network_name()
1325
1330
        self.assertEqual(repo_name, repo._format.network_name())
1326
 
        # New repositories are write locked.
1327
 
        self.assertTrue(repo.is_write_locked())
1328
 
        repo.unlock()
1329
1331
 
1330
1332
    def assertInitializeEx(self, t, need_meta=False, **kwargs):
1331
1333
        """Execute initialize_on_transport_ex and check it succeeded correctly.
1343
1345
            return None, None
1344
1346
        repo, control, require_stacking, repo_policy = \
1345
1347
            self.bzrdir_format.initialize_on_transport_ex(t, **kwargs)
 
1348
        if repo is not None:
 
1349
            # Repositories are open write-locked
 
1350
            self.assertTrue(repo.is_write_locked())
 
1351
            self.addCleanup(repo.unlock)
1346
1352
        self.assertIsInstance(control, bzrdir.BzrDir)
1347
1353
        opened = bzrdir.BzrDir.open(t.base)
1348
1354
        expected_format = self.bzrdir_format