~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/weave_fmt/test_bzrdir.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2011, 2012, 2016 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
19
19
For interface contract tests, see tests/per_bzr_dir.
20
20
"""
21
21
 
 
22
from __future__ import absolute_import
 
23
 
22
24
import os
23
25
import sys
24
26
 
25
27
from bzrlib import (
26
28
    branch,
27
29
    bzrdir,
 
30
    controldir,
28
31
    errors,
29
32
    repository,
30
33
    upgrade,
33
36
    )
34
37
from bzrlib.osutils import (
35
38
    getcwd,
36
 
    lexists,
37
39
    )
38
40
from bzrlib.tests.test_bundle import V4BundleTester
39
41
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
65
67
            self.assertTrue(ctrl_2 is ctrl_3)
66
68
        check_dir_components_use_same_lock(dir)
67
69
        # and if we open it normally.
68
 
        dir = bzrdir.BzrDir.open(self.get_url())
 
70
        dir = controldir.ControlDir.open(self.get_url())
69
71
        check_dir_components_use_same_lock(dir)
70
72
 
71
73
    def test_can_convert(self):
99
101
            self.assertTrue(ctrl_2 is ctrl_3)
100
102
        check_dir_components_use_same_lock(dir)
101
103
        # and if we open it normally.
102
 
        dir = bzrdir.BzrDir.open(self.get_url())
 
104
        dir = controldir.ControlDir.open(self.get_url())
103
105
        check_dir_components_use_same_lock(dir)
104
106
 
105
107
    def test_can_convert(self):
301
303
        # At this point, we have a format6 branch without checkout files.
302
304
        upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
303
305
        # The upgrade should not have set up a working tree.
304
 
        control = bzrdir.BzrDir.open('.')
 
306
        control = controldir.ControlDir.open('.')
305
307
        self.assertFalse(control.has_workingtree())
306
308
        # We have covered the scope of this test, we may as well check that
307
309
        # upgrade has not eaten our data, even if it's a bit redundant with
308
310
        # other tests.
309
311
        self.assertIsInstance(control._format, bzrdir.BzrDirMetaFormat1)
310
312
        b = control.open_branch()
311
 
        self.assertEquals(b.revision_history(),
 
313
        self.addCleanup(b.lock_read().unlock)
 
314
        self.assertEqual(b._revision_history(),
312
315
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
313
316
            'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
314
317
 
315
318
    def test_upgrade_simple(self):
316
319
        """Upgrade simple v0.0.4 format to latest format"""
317
 
        eq = self.assertEquals
 
320
        eq = self.assertEqual
318
321
        self.build_tree_contents(_upgrade1_template)
319
322
        upgrade.upgrade(u'.')
320
 
        control = bzrdir.BzrDir.open('.')
 
323
        control = controldir.ControlDir.open('.')
321
324
        b = control.open_branch()
322
325
        # tsk, peeking under the covers.
323
326
        self.assertIsInstance(
324
327
            control._format,
325
328
            bzrdir.BzrDirFormat.get_default_format().__class__)
326
 
        rh = b.revision_history()
 
329
        self.addCleanup(b.lock_read().unlock)
 
330
        rh = b._revision_history()
327
331
        eq(rh,
328
332
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
329
333
            'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
374
378
        bzr, but can happen in branches imported from baz and arch, or from
375
379
        other systems, where the importer knows about a revision but not
376
380
        its contents."""
377
 
        eq = self.assertEquals
 
381
        eq = self.assertEqual
378
382
        self.build_tree_contents(_ghost_template)
379
383
        upgrade.upgrade(u'.')
380
384
        b = branch.Branch.open(u'.')
381
 
        revision_id = b.revision_history()[1]
 
385
        self.addCleanup(b.lock_read().unlock)
 
386
        revision_id = b._revision_history()[1]
382
387
        rev = b.repository.get_revision(revision_id)
383
388
        eq(len(rev.parent_ids), 2)
384
389
        eq(rev.parent_ids[1], 'wibble@wobble-2')
385
390
 
386
391
    def test_upgrade_makes_dir_weaves(self):
387
392
        self.build_tree_contents(_upgrade_dir_template)
388
 
        old_repodir = bzrdir.BzrDir.open_unsupported('.')
 
393
        old_repodir = controldir.ControlDir.open_unsupported('.')
389
394
        old_repo_format = old_repodir.open_repository()._format
390
395
        upgrade.upgrade('.')
391
396
        # this is the path to the literal file. As format changes
407
412
        self.build_tree_contents(_upgrade_dir_template)
408
413
        upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
409
414
        tree = workingtree.WorkingTree.open('.')
410
 
        self.assertEqual([tree.branch.revision_history()[-1]],
 
415
        self.addCleanup(tree.lock_read().unlock)
 
416
        self.assertEqual([tree.branch._revision_history()[-1]],
411
417
            tree.get_parent_ids())
412
418
 
413
419
 
539
545
        self.build_tree(['master/', 'child/'])
540
546
        self.make_branch_and_tree('master')
541
547
        self.make_branch_and_tree('child',
542
 
                        format=bzrdir.format_registry.make_bzrdir('weave'))
 
548
                        format=controldir.format_registry.make_bzrdir('weave'))
543
549
        os.chdir('child')
544
550
 
545
551
    def test_bind_format_6_bzrdir(self):