~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_upgrade.py

  • Committer: Robert Collins
  • Date: 2006-02-21 12:42:57 UTC
  • mto: (1563.1.5 integration)
  • mto: This revision was merged to the branch mainline in revision 1568.
  • Revision ID: robertc@robertcollins.net-20060221124257-8ee8f4b0b3b45ac3
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
 
23
23
import bzrlib.bzrdir as bzrdir
 
24
import bzrlib.repository as repository
24
25
from bzrlib.tests import TestCaseWithTransport
25
26
from bzrlib.transport import get_transport
26
27
import bzrlib.ui as ui
30
31
    """A UI Factory which never captures its output.
31
32
    """
32
33
 
 
34
    def clear(self):
 
35
        """See progress.ProgressBar.clear()."""
 
36
 
33
37
    def note(self, fmt_string, *args, **kwargs):
34
38
        """See progress.ProgressBar.note()."""
35
39
        print fmt_string % args
37
41
    def progress_bar(self):
38
42
        return self
39
43
        
40
 
    def update(self, message, count, total):
 
44
    def update(self, message, count=None, total=None):
41
45
        """See progress.ProgressBar.update()."""
42
46
 
43
47
 
57
61
        t.mkdir('format_5_branch')
58
62
        bzrdir.BzrDirFormat5().initialize(self.get_url('format_5_branch'))
59
63
        bzrdir.BzrDir.create_standalone_workingtree('current_format_branch')
 
64
        d = bzrdir.BzrDir.create('metadir_weave_branch')
 
65
        d.create_repository()
 
66
        d.create_branch()
 
67
        d.create_workingtree()
60
68
        self.run_bzr('checkout',
61
69
                     self.get_url('current_format_branch'),
62
70
                     'current_format_checkout')
129
137
        self.assertTrue(isinstance(
130
138
            bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
131
139
            bzrdir.BzrDirMetaFormat1))
 
140
 
 
141
    def test_upgrade_explicit_knit(self):
 
142
        # users can force an upgrade to knit format from a metadir weave 
 
143
        # branch
 
144
        url = get_transport(self.get_url('metadir_weave_branch')).base
 
145
        # check --format takes effect
 
146
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirFormat5())
 
147
        (out, err) = self.run_bzr_captured(
 
148
            ['upgrade', '--format=knit', url])
 
149
        self.assertEqualDiff("""starting upgrade of %s
 
150
making backup of tree history
 
151
%s.bzr has been backed up to %s.bzr.backup
 
152
if conversion fails, you can move this directory back to .bzr
 
153
if it succeeds, you can remove this directory if you wish
 
154
starting repository conversion
 
155
repository converted
 
156
finished
 
157
""" % (url, url, url), out)
 
158
        self.assertEqualDiff("", err)
 
159
        converted_dir = bzrdir.BzrDir.open(self.get_url('metadir_weave_branch'))
 
160
        self.assertTrue(isinstance(converted_dir._format,
 
161
                                   bzrdir.BzrDirMetaFormat1))
 
162
        self.assertTrue(isinstance(converted_dir.open_repository()._format,
 
163
                                   repository.RepositoryFormatKnit1))