Rev 3229: Correctly handle multi-step branch upgrades. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
Robert Collins
robertc at robertcollins.net
Fri Feb 15 02:26:02 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
------------------------------------------------------------
revno: 3229
revision-id:robertc at robertcollins.net-20080215022546-g3i4tmuoln761k8r
parent: robertc at robertcollins.net-20080214044227-pq3gtz42jh3xug6j
committer: Robert Collins <robertc at robertcollins.net>
branch nick: StackableBranch
timestamp: Fri 2008-02-15 13:25:46 +1100
message:
Correctly handle multi-step branch upgrades.
modified:
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2008-02-14 04:42:27 +0000
+++ b/bzrlib/branch.py 2008-02-15 02:25:46 +0000
@@ -2174,7 +2174,7 @@
"""Perform an in-place upgrade of format 6 to format 7"""
def convert(self, branch):
+ format = BzrBranchFormat7()
branch.control_files.put_utf8('stacked-on', '\n')
# update target format
- new_branch.control_files.put_utf8('format',
- format.get_format_string())
+ branch.control_files.put_utf8('format', format.get_format_string())
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2008-02-14 04:42:27 +0000
+++ b/bzrlib/bzrdir.py 2008-02-15 02:25:46 +0000
@@ -2351,21 +2351,24 @@
pass
else:
# TODO: conversions of Branch and Tree should be done by
- # InterXFormat lookups
+ # InterXFormat lookups/some sort of registry.
# Avoid circular imports
from bzrlib import branch as _mod_branch
- old_new = (branch._format.__class__,
- self.target_format.get_branch_format().__class__)
- if (old_new ==
- (_mod_branch.BzrBranchFormat5, _mod_branch.BzrBranchFormat6)):
- branch_converter = _mod_branch.Converter5to6()
- elif (old_new ==
- (_mod_branch.BzrBranchFormat6, _mod_branch.BzrBranchFormat7)):
- branch_converter = _mod_branch.Converter6to7()
- else:
- branch_converter = None
- if branch_converter is not None:
+ old = branch._format.__class__
+ new = self.target_format.get_branch_format().__class__
+ while old != new:
+ if (old == _mod_branch.BzrBranchFormat5 and
+ new in (_mod_branch.BzrBranchFormat6,
+ _mod_branch.BzrBranchFormat7)):
+ branch_converter = _mod_branch.Converter5to6()
+ elif (old == _mod_branch.BzrBranchFormat6 and
+ new == _mod_branch.BzrBranchFormat7):
+ branch_converter = _mod_branch.Converter6to7()
+ else:
+ raise errors.BadConversionTarget("No converter", new)
branch_converter.convert(branch)
+ branch = self.bzrdir.open_branch()
+ old = branch._format.__class__
try:
tree = self.bzrdir.open_workingtree(recommend_upgrade=False)
except (errors.NoWorkingTree, errors.NotLocalUrl):
More information about the bazaar-commits
mailing list