~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

UnfuckĀ upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
 
74
74
from bzrlib.branch import Branch, find_branch
75
75
from bzrlib.branch import BZR_BRANCH_FORMAT_5, BZR_BRANCH_FORMAT_6
 
76
from bzrlib.branch import BzrBranchFormat4, BzrBranchFormat5, BzrBranchFormat6
76
77
import bzrlib.hashcache as hashcache
77
78
from bzrlib.weave import Weave
78
79
from bzrlib.weavefile import read_weave, write_weave
100
101
        note('starting upgrade of %s', os.path.abspath(self.base))
101
102
        self._backup_control_dir()
102
103
        self.pb = ui_factory.progress_bar()
103
 
        if self.old_format == 4:
 
104
        if isinstance(self.old_format, BzrBranchFormat4):
104
105
            note('starting upgrade from format 4 to 5')
105
106
            self._convert_to_weaves()
106
107
            self._open_branch()
107
 
        if self.old_format == 5:
 
108
        if isinstance(self.old_format, BzrBranchFormat5):
108
109
            note('starting upgrade from format 5 to 6')
109
110
            self._convert_to_prefixed()
110
111
            self._open_branch()
113
114
        cache.write()
114
115
        note("finished")
115
116
 
116
 
 
117
117
    def _convert_to_prefixed(self):
118
118
        from bzrlib.store import hash_prefix
119
119
        for store_name in ["weaves", "revision-store"]:
170
170
    def _open_branch(self):
171
171
        self.branch = Branch.open_downlevel(self.base)
172
172
        self.old_format = self.branch._branch_format
173
 
        if self.old_format == 6:
174
 
            note('this branch is in the most current format')
 
173
        if isinstance(self.old_format, BzrBranchFormat6):
 
174
            note('this branch is in the most current format (%s)', self.old_format)
175
175
            return False
176
 
        if self.old_format not in (4, 5):
177
 
            raise BzrError("cannot upgrade from branch format %r" %
 
176
        if (not isinstance(self.old_format, BzrBranchFormat4) and
 
177
            not isinstance(self.old_format, BzrBranchFormat5)):
 
178
            raise BzrError("cannot upgrade from branch format %s" %
178
179
                           self.branch._branch_format)
179
180
        return True
180
181