~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Robert Collins
  • Date: 2009-06-15 10:22:08 UTC
  • mto: This revision was merged to the branch mainline in revision 4441.
  • Revision ID: robertc@robertcollins.net-20090615102208-35q3sg050vbxd32e
And fix tests for bzr help.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2008, 2009 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
17
17
"""bzr upgrade logic."""
18
18
 
19
19
 
20
 
from bzrlib.bzrdir import BzrDir, format_registry
 
20
from bzrlib.bzrdir import BzrDir, BzrDirFormat, format_registry
21
21
import bzrlib.errors as errors
22
22
from bzrlib.remote import RemoteBzrDir
 
23
from bzrlib.transport import get_transport
23
24
import bzrlib.ui as ui
24
25
 
25
26
 
34
35
        if self.bzrdir.root_transport.is_readonly():
35
36
            raise errors.UpgradeReadonly
36
37
        self.transport = self.bzrdir.root_transport
37
 
        self.convert()
 
38
        self.pb = ui.ui_factory.nested_progress_bar()
 
39
        try:
 
40
            self.convert()
 
41
        finally:
 
42
            self.pb.finished()
38
43
 
39
44
    def convert(self):
40
45
        try:
41
46
            branch = self.bzrdir.open_branch()
42
47
            if branch.bzrdir.root_transport.base != \
43
48
                self.bzrdir.root_transport.base:
44
 
                ui.ui_factory.note("This is a checkout. The branch (%s) needs to be "
45
 
                             "upgraded separately." %
 
49
                self.pb.note("This is a checkout. The branch (%s) needs to be "
 
50
                             "upgraded separately.",
46
51
                             branch.bzrdir.root_transport.base)
47
52
            del branch
48
53
        except (errors.NotBranchError, errors.IncompatibleRepositories):
67
72
            raise errors.BzrError("cannot upgrade from bzrdir format %s" %
68
73
                           self.bzrdir._format)
69
74
        self.bzrdir.check_conversion_target(format)
70
 
        ui.ui_factory.note('starting upgrade of %s' % self.transport.base)
71
 
 
 
75
        self.pb.note('starting upgrade of %s', self.transport.base)
72
76
        self.bzrdir.backup_bzrdir()
73
77
        while self.bzrdir.needs_format_conversion(format):
74
78
            converter = self.bzrdir._format.get_converter(format)
75
 
            self.bzrdir = converter.convert(self.bzrdir, None)
76
 
        ui.ui_factory.note("finished")
 
79
            self.bzrdir = converter.convert(self.bzrdir, self.pb)
 
80
        self.pb.note("finished")
77
81
 
78
82
 
79
83
def upgrade(url, format=None):