~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

Branch now uses BzrDir reasonably sanely.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
 
77
77
import bzrlib
78
78
from bzrlib.branch import Branch
79
 
from bzrlib.branch import BZR_BRANCH_FORMAT_5, BZR_BRANCH_FORMAT_6
80
 
from bzrlib.branch import BzrBranchFormat, BzrBranchFormat4, BzrBranchFormat5, BzrBranchFormat6
 
79
from bzrlib.bzrdir import BzrDirFormat, BzrDirFormat4, BzrDirFormat5, BzrDirFormat6
81
80
from bzrlib.errors import NoSuchFile, UpgradeReadonly
82
81
import bzrlib.hashcache as hashcache
83
82
from bzrlib.lockable_files import LockableFiles
125
124
        note('starting upgrade of %s', self.base)
126
125
        self._backup_control_dir()
127
126
        self.pb = ui_factory.progress_bar()
128
 
        if isinstance(self.old_format, BzrBranchFormat4):
 
127
        if isinstance(self.old_format, BzrDirFormat4):
129
128
            note('starting upgrade from format 4 to 5')
130
129
            self._convert_to_weaves()
131
 
        if isinstance(self.old_format, BzrBranchFormat5):
 
130
        if isinstance(self.old_format, BzrDirFormat5):
132
131
            note('starting upgrade from format 5 to 6')
133
132
            self._convert_to_prefixed()
134
133
        if isinstance(self.transport, LocalTransport):
158
157
                except NoSuchFile: # catches missing dirs strangely enough
159
158
                    store_transport.mkdir(prefix_dir)
160
159
                    store_transport.move(filename, prefix_dir + '/' + filename)
161
 
        self._set_new_format(BZR_BRANCH_FORMAT_6)
162
 
        self.branch = BzrBranchFormat6().open(self.transport)
163
 
        self.old_format = self.branch._branch_format
 
160
        self.old_format = BzrDirFormat6()
 
161
        self._set_new_format(self.old_format.get_format_string())
 
162
        self.bzrdir = self.old_format.open(self.transport)
 
163
        self.branch = self.bzrdir.open_branch()
164
164
 
165
165
    def _convert_to_weaves(self):
166
166
        note('note: upgrade may be faster if all store files are ungzipped first')
201
201
        note('  %6d revisions not present' % len(self.absent_revisions))
202
202
        note('  %6d texts' % self.text_count)
203
203
        self._cleanup_spare_files_after_format4()
204
 
        self._set_new_format(BZR_BRANCH_FORMAT_5)
205
 
        self.branch = BzrBranchFormat5().open(self.transport)
206
 
        self.old_format = self.branch._branch_format
 
204
        self.old_format = BzrDirFormat5()
 
205
        self._set_new_format(self.old_format.get_format_string())
 
206
        self.bzrdir = self.old_format.open(self.transport)
 
207
        self.branch = self.bzrdir.open_branch()
207
208
 
208
209
    def _open_branch(self):
209
 
        self.old_format = BzrBranchFormat.find_format(self.transport)
210
 
        self.branch = self.old_format.open(self.transport)
211
 
        if isinstance(self.old_format, BzrBranchFormat6):
 
210
        self.old_format = BzrDirFormat.find_format(self.transport)
 
211
        self.bzrdir = self.old_format.open(self.transport)
 
212
        self.branch = self.bzrdir.open_branch()
 
213
        if isinstance(self.old_format, BzrDirFormat6):
212
214
            note('this branch is in the most current format (%s)', self.old_format)
213
215
            return False
214
 
        if (not isinstance(self.old_format, BzrBranchFormat4) and
215
 
            not isinstance(self.old_format, BzrBranchFormat5)):
 
216
        if (not isinstance(self.old_format, BzrDirFormat4) and
 
217
            not isinstance(self.old_format, BzrDirFormat5)):
216
218
            raise BzrError("cannot upgrade from branch format %s" %
217
219
                           self.branch._branch_format)
218
220
        return True