~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Robert Collins
  • Date: 2006-02-16 11:19:47 UTC
  • mto: (1534.1.24 integration)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060216111947-e6946ac37fe8b21a
Correct buggy test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
class Convert(object):
29
29
 
30
 
    def __init__(self, url):
 
30
    def __init__(self, url, format):
 
31
        self.format = format
31
32
        self.bzrdir = BzrDir.open_unsupported(url)
32
33
        if self.bzrdir.root_transport.is_readonly():
33
34
            raise errors.UpgradeReadonly
41
42
            self.pb.note("This is a checkout. The branch (%s) needs to be "
42
43
                         "upgraded separately.",
43
44
                         branch.bzrdir.root_transport.base)
44
 
        if not self.bzrdir.needs_format_update():
 
45
        if not self.bzrdir.needs_format_update(self.format):
45
46
            raise errors.UpToDateFormat(self.bzrdir._format)
46
47
        if not self.bzrdir.can_update_format():
47
48
            raise errors.BzrError("cannot upgrade from branch format %s" %
48
49
                           self.bzrdir._format)
49
50
        self.pb.note('starting upgrade of %s', self.transport.base)
50
51
        self._backup_control_dir()
51
 
        while self.bzrdir.needs_format_update():
52
 
            converter = self.bzrdir._format.get_updater()
53
 
            self.bzrdir = converter.convert(self.bzrdir, self.pb)
54
 
        if isinstance(self.bzrdir._format, BzrDirFormat4):
55
 
            converter = ConvertBzrDir4To5()
56
 
            self.bzrdir = converter.convert(self.bzrdir, self.pb)
57
 
        if isinstance(self.bzrdir._format, BzrDirFormat5):
58
 
            converter = ConvertBzrDir5To6()
 
52
        while self.bzrdir.needs_format_update(self.format):
 
53
            converter = self.bzrdir._format.get_updater(self.format)
59
54
            self.bzrdir = converter.convert(self.bzrdir, self.pb)
60
55
        self.pb.note("finished")
61
56
 
68
63
        self.pb.note('if conversion fails, you can move this directory back to .bzr')
69
64
        self.pb.note('if it succeeds, you can remove this directory if you wish')
70
65
 
71
 
def upgrade(url):
72
 
    Convert(url)
 
66
def upgrade(url, format=None):
 
67
    """Upgrade to format, or the default bzrdir format if not supplied."""
 
68
    Convert(url, format)