Rev 3916: 1.12-preview formats (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Dec 23 07:35:02 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3916
revision-id: pqm at pqm.ubuntu.com-20081223073457-19rneaiz4yscvyiy
parent: pqm at pqm.ubuntu.com-20081219200818-g19t5zbtkj52bwqp
parent: ian.clatworthy at canonical.com-20081223064634-nqdyif50rxxjsxfb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-12-23 07:34:57 +0000
message:
1.12-preview formats (Ian Clatworthy)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tests/workingtree_implementations/test_add.py test_add.py-20070226165239-4vo178spkrnhavc7-1
bzrlib/tests/workingtree_implementations/test_basis_inventory.py test_basis_inventory.py-20051218151655-3650468941091309
bzrlib/tests/workingtree_implementations/test_move.py test_move.py-20070225171927-mohn2vqj5fx7edc6-1
bzrlib/tests/workingtree_implementations/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 3915.1.2
revision-id: ian.clatworthy at canonical.com-20081223064634-nqdyif50rxxjsxfb
parent: ian.clatworthy at canonical.com-20081223034445-nuj7zz42t2vxib94
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Tue 2008-12-23 16:46:34 +1000
message:
tweak selftest test for new wt format
modified:
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
------------------------------------------------------------
revno: 3915.1.1
revision-id: ian.clatworthy at canonical.com-20081223034445-nuj7zz42t2vxib94
parent: pqm at pqm.ubuntu.com-20081219200818-g19t5zbtkj52bwqp
parent: ian.clatworthy at canonical.com-20081222084420-4arkm0evawpd16x7
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Tue 2008-12-23 13:44:45 +1000
message:
1.12-preview formats (Ian Clatworthy)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tests/workingtree_implementations/test_add.py test_add.py-20070226165239-4vo178spkrnhavc7-1
bzrlib/tests/workingtree_implementations/test_basis_inventory.py test_basis_inventory.py-20051218151655-3650468941091309
bzrlib/tests/workingtree_implementations/test_move.py test_move.py-20070225171927-mohn2vqj5fx7edc6-1
bzrlib/tests/workingtree_implementations/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 3907.2.3
revision-id: ian.clatworthy at canonical.com-20081222084420-4arkm0evawpd16x7
parent: ian.clatworthy at canonical.com-20081218065837-5rvhmsp4a24nlmxy
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.wt5
timestamp: Mon 2008-12-22 18:44:20 +1000
message:
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced
removed:
bzrlib/workingtree_5.py workingtree_5.py-20081216060511-xp0m9qmsz0qdqj6v-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tests/workingtree_implementations/test_add.py test_add.py-20070226165239-4vo178spkrnhavc7-1
bzrlib/tests/workingtree_implementations/test_basis_inventory.py test_basis_inventory.py-20051218151655-3650468941091309
bzrlib/tests/workingtree_implementations/test_move.py test_move.py-20070225171927-mohn2vqj5fx7edc6-1
bzrlib/tests/workingtree_implementations/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 3907.2.2
revision-id: ian.clatworthy at canonical.com-20081218065837-5rvhmsp4a24nlmxy
parent: ian.clatworthy at canonical.com-20081216063133-q2s3ckxjnqgeiku1
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.wt5
timestamp: Thu 2008-12-18 16:58:37 +1000
message:
add Tree.supports_content_filtering
modified:
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
------------------------------------------------------------
revno: 3907.2.1
revision-id: ian.clatworthy at canonical.com-20081216063133-q2s3ckxjnqgeiku1
parent: pqm at pqm.ubuntu.com-20081216015655-5wn3k66fkt8wv4i9
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.wt5
timestamp: Tue 2008-12-16 16:31:33 +1000
message:
WorkingTreeFormat5 supporting content filtering and views
added:
bzrlib/workingtree_5.py workingtree_5.py-20081216060511-xp0m9qmsz0qdqj6v-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS 2008-12-19 20:08:18 +0000
+++ b/NEWS 2008-12-23 03:44:45 +0000
@@ -114,6 +114,11 @@
means that PQM will now reject changes that introduce new trailing
whitespace. (Marius Kruger)
+ * Introduced new experimental formats called ``1.12-preview`` and
+ ``1.12-preview-rich-root`` to enable testing of related pending
+ features, namely content filtering and filtered views.
+ (Ian Clatworthy)
+
INTERNALS:
* Added an ``InventoryEntry`` cache when deserializing inventories.
@@ -125,6 +130,10 @@
cost of not preserving the 'active' set as well as an ``LRUCache``.
(John Arbash Meinel)
+ * ``DirStateWorkingTree`` and ``DirStateWorkingTreeFormat`` added
+ as base classes of ``WorkingTree4`` and ``WorkingTreeFormat4``
+ respectively. (Ian Clatworthy)
+
* ``KnitVersionedFiles.get_record_stream()`` will now chose a
more optimal ordering when the keys are requested 'unordered'.
Previously the order was fully random, now the records should be
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2008-12-17 10:21:38 +0000
+++ b/bzrlib/bzrdir.py 2008-12-23 03:44:45 +0000
@@ -2592,10 +2592,15 @@
# TODO: conversions of Branch and Tree should be done by
# InterXFormat lookups
if (isinstance(tree, workingtree.WorkingTree3) and
- not isinstance(tree, workingtree_4.WorkingTree4) and
+ not isinstance(tree, workingtree_4.DirStateWorkingTree) and
isinstance(self.target_format.workingtree_format,
- workingtree_4.WorkingTreeFormat4)):
+ workingtree_4.DirStateWorkingTreeFormat)):
workingtree_4.Converter3to4().convert(tree)
+ if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
+ not isinstance(tree, workingtree_4.WorkingTree5) and
+ isinstance(self.target_format.workingtree_format,
+ workingtree_4.WorkingTreeFormat5)):
+ workingtree_4.Converter4to5().convert(tree)
return to_convert
@@ -3096,6 +3101,21 @@
branch_format='bzrlib.branch.BzrBranchFormat7',
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
)
+format_registry.register_metadir('1.12-preview',
+ 'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
+ help='A working-tree format that supports views and content filtering.',
+ branch_format='bzrlib.branch.BzrBranchFormat7',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
+ experimental=True,
+ )
+format_registry.register_metadir('1.12-preview-rich-root',
+ 'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
+ help='A variant of 1.12-preview that supports rich-root data '
+ '(needed for bzr-svn).',
+ branch_format='bzrlib.branch.BzrBranchFormat7',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
+ experimental=True,
+ )
# The following two formats should always just be aliases.
format_registry.register_metadir('development',
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
=== modified file 'bzrlib/tests/test_info.py'
--- a/bzrlib/tests/test_info.py 2008-10-31 07:45:09 +0000
+++ b/bzrlib/tests/test_info.py 2008-12-16 06:31:33 +0000
@@ -152,8 +152,10 @@
'1.9 or 1.9-rich-root or ' \
'dirstate or dirstate-tags or pack-0.92 or'\
' rich-root or rich-root-pack'
- if key in ('knit', 'metaweave'):
+ elif key in ('knit', 'metaweave'):
expected = 'knit or metaweave'
+ elif key in ('1.12-preview', '1.12-preview-rich-root'):
+ expected = '1.12-preview or 1.12-preview-rich-root'
self.assertCheckoutDescription(key, expected)
def test_describe_branch_format(self):
@@ -163,6 +165,10 @@
expected = None
if key in ('dirstate', 'knit'):
expected = 'dirstate or knit'
+ elif key in ('1.9', '1.12-preview'):
+ expected = '1.12-preview or 1.9'
+ elif key in ('1.9-rich-root', '1.12-preview-rich-root'):
+ expected = '1.12-preview-rich-root or 1.9-rich-root'
self.assertBranchDescription(key, expected)
def test_describe_repo_format(self):
@@ -172,6 +178,10 @@
expected = None
if key in ('dirstate', 'knit', 'dirstate-tags'):
expected = 'dirstate or dirstate-tags or knit'
+ elif key in ('1.9', '1.12-preview'):
+ expected = '1.12-preview or 1.9'
+ elif key in ('1.9-rich-root', '1.12-preview-rich-root'):
+ expected = '1.12-preview-rich-root or 1.9-rich-root'
self.assertRepoDescription(key, expected)
format = bzrdir.format_registry.make_bzrdir('metaweave')
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2008-10-01 08:03:36 +0000
+++ b/bzrlib/tests/test_selftest.py 2008-12-23 06:46:34 +0000
@@ -422,7 +422,7 @@
tests = list(iter(suite))
# XXX We should not have tests fail as we add more scenarios
# abentley 20080412
- self.assertEqual(6, len(tests))
+ self.assertEqual(7, len(tests))
# this must match the default format setp up in
# TreeTestProviderAdapter.adapt
default_format = workingtree.WorkingTreeFormat3
=== modified file 'bzrlib/tests/tree_implementations/__init__.py'
--- a/bzrlib/tests/tree_implementations/__init__.py 2008-09-08 11:53:40 +0000
+++ b/bzrlib/tests/tree_implementations/__init__.py 2008-12-22 08:44:20 +0000
@@ -54,6 +54,7 @@
from bzrlib.workingtree_4 import (
DirStateRevisionTree,
WorkingTreeFormat4,
+ WorkingTreeFormat5,
)
@@ -346,6 +347,9 @@
self.scenarios.append(self.create_tree_scenario(
DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
WorkingTreeFormat4()))
+ self.scenarios.append(self.create_tree_scenario(
+ DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
+ WorkingTreeFormat5()))
self.scenarios.append(self.create_tree_scenario('PreviewTree',
preview_tree_pre))
self.scenarios.append(self.create_tree_scenario('PreviewTreePost',
=== modified file 'bzrlib/tests/workingtree_implementations/test_add.py'
--- a/bzrlib/tests/workingtree_implementations/test_add.py 2007-03-21 03:31:37 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_add.py 2008-12-22 08:44:20 +0000
@@ -24,7 +24,6 @@
osutils,
tests,
)
-from bzrlib.workingtree_4 import WorkingTreeFormat4
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/workingtree_implementations/test_basis_inventory.py'
--- a/bzrlib/tests/workingtree_implementations/test_basis_inventory.py 2008-05-12 04:07:49 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_basis_inventory.py 2008-12-22 08:44:20 +0000
@@ -30,7 +30,7 @@
# This test is not applicable to DirState based trees: the basis is
# not separate is mandatory.
if isinstance(self.workingtree_format,
- bzrlib.workingtree_4.WorkingTreeFormat4):
+ bzrlib.workingtree_4.DirStateWorkingTreeFormat):
raise TestNotApplicable("not applicable to %r"
% (self.workingtree_format,))
# TODO: jam 20051218 this probably should add more than just
@@ -69,7 +69,7 @@
# This test is not applicable to DirState based trees: the basis is
# not separate and ignorable.
if isinstance(self.workingtree_format,
- bzrlib.workingtree_4.WorkingTreeFormat4):
+ bzrlib.workingtree_4.DirStateWorkingTreeFormat):
raise TestNotApplicable("not applicable to %r"
% (self.workingtree_format,))
t = self.make_branch_and_tree('.')
=== modified file 'bzrlib/tests/workingtree_implementations/test_move.py'
--- a/bzrlib/tests/workingtree_implementations/test_move.py 2007-04-25 18:41:56 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_move.py 2008-12-22 08:44:20 +0000
@@ -23,7 +23,7 @@
osutils,
)
-from bzrlib.workingtree_4 import WorkingTreeFormat4
+from bzrlib.workingtree_4 import DirStateWorkingTreeFormat
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
@@ -99,9 +99,10 @@
tree.move, ['a1'], to_name='sub1',
after=False)
except TypeError:
- # WorkingTreeFormat4 doesn't have to maintain api compatibility
- # since it was deprecated before the class was introduced.
- if not isinstance(self.workingtree_format, WorkingTreeFormat4):
+ # WorkingTreeFormat4 and later don't have to maintain api
+ # compatibility since it was deprecated before they were introduced.
+ if not isinstance(self.workingtree_format,
+ DirStateWorkingTreeFormat):
raise
tree._validate()
=== modified file 'bzrlib/tests/workingtree_implementations/test_rename_one.py'
--- a/bzrlib/tests/workingtree_implementations/test_rename_one.py 2008-09-08 13:04:27 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_rename_one.py 2008-12-22 08:44:20 +0000
@@ -24,7 +24,6 @@
tests,
)
-from bzrlib.workingtree_4 import WorkingTreeFormat4
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2008-10-28 09:16:22 +0000
+++ b/bzrlib/tree.py 2008-12-18 06:58:37 +0000
@@ -564,6 +564,9 @@
"""
raise NotImplementedError(self.walkdirs)
+ def supports_content_filtering(self):
+ return False
+
def iter_search_rules(self, path_names, pref_names=None,
_default_searcher=rules._per_user_searcher):
"""Find the preferences for filenames in a tree.
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2008-11-17 03:21:53 +0000
+++ b/bzrlib/workingtree.py 2008-12-22 08:44:20 +0000
@@ -79,7 +79,7 @@
import bzrlib.branch
from bzrlib.transport import get_transport
import bzrlib.ui
-from bzrlib.workingtree_4 import WorkingTreeFormat4
+from bzrlib.workingtree_4 import WorkingTreeFormat4, WorkingTreeFormat5
""")
from bzrlib import symbol_versioning
@@ -284,6 +284,12 @@
def supports_tree_reference(self):
return False
+ def supports_content_filtering(self):
+ return self._format.supports_content_filtering()
+
+ def supports_views(self):
+ return self._format.supports_views()
+
def _set_inventory(self, inv, dirty):
"""Set the internal cached inventory.
@@ -2714,6 +2720,14 @@
"""
return True
+ def supports_content_filtering(self):
+ """True if this format supports content filtering."""
+ return False
+
+ def supports_views(self):
+ """True if this format supports stored views."""
+ return False
+
@classmethod
def register_format(klass, format):
klass._formats[format.get_format_string()] = format
@@ -2942,6 +2956,7 @@
__default_format = WorkingTreeFormat4()
WorkingTreeFormat.register_format(__default_format)
+WorkingTreeFormat.register_format(WorkingTreeFormat5())
WorkingTreeFormat.register_format(WorkingTreeFormat3())
WorkingTreeFormat.set_default_format(__default_format)
# formats which have no format string are not discoverable
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2008-11-17 03:21:53 +0000
+++ b/bzrlib/workingtree_4.py 2008-12-22 08:44:20 +0000
@@ -96,18 +96,7 @@
from bzrlib.workingtree import WorkingTree, WorkingTree3, WorkingTreeFormat3
-class WorkingTree4(WorkingTree3):
- """This is the Format 4 working tree.
-
- This differs from WorkingTree3 by:
- - Having a consolidated internal dirstate, stored in a
- randomly-accessible sorted file on disk.
- - Not having a regular inventory attribute. One can be synthesized
- on demand but this is expensive and should be avoided.
-
- This is new in bzr 0.15.
- """
-
+class DirStateWorkingTree(WorkingTree3):
def __init__(self, basedir,
branch,
_control_files=None,
@@ -894,7 +883,8 @@
for tree in trees:
if not (isinstance(tree, DirStateRevisionTree) and tree._revision_id in
parents):
- return super(WorkingTree4, self).paths2ids(paths, trees, require_versioned)
+ return super(DirStateWorkingTree, self).paths2ids(paths,
+ trees, require_versioned)
search_indexes = [0] + [1 + parents.index(tree._revision_id) for tree in trees]
# -- make all paths utf8 --
paths_utf8 = set()
@@ -1291,30 +1281,32 @@
self.flush()
-class WorkingTreeFormat4(WorkingTreeFormat3):
- """The first consolidated dirstate working tree format.
-
- This format:
- - exists within a metadir controlling .bzr
- - includes an explicit version marker for the workingtree control
- files, separate from the BzrDir format
- - modifies the hash cache format
- - is new in bzr 0.15
- - uses a LockDir to guard access to it.
- """
-
- upgrade_recommended = False
-
- _tree_class = WorkingTree4
-
- def get_format_string(self):
- """See WorkingTreeFormat.get_format_string()."""
- return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
-
- def get_format_description(self):
- """See WorkingTreeFormat.get_format_description()."""
- return "Working tree format 4"
-
+class WorkingTree4(DirStateWorkingTree):
+ """This is the Format 4 working tree.
+
+ This differs from WorkingTree3 by:
+ - Having a consolidated internal dirstate, stored in a
+ randomly-accessible sorted file on disk.
+ - Not having a regular inventory attribute. One can be synthesized
+ on demand but this is expensive and should be avoided.
+
+ This is new in bzr 0.15.
+ """
+
+
+class WorkingTree5(DirStateWorkingTree):
+ """This is the Format 5 working tree.
+
+ This differs from WorkingTree4 by:
+ - Supporting content filtering.
+ - Supporting a current view that may mask the set of files in a tree
+ impacted by most user operations.
+
+ This is new in bzr 1.11.
+ """
+
+
+class DirStateWorkingTreeFormat(WorkingTreeFormat3):
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
accelerator_tree=None, hardlink=False):
"""See WorkingTreeFormat.initialize().
@@ -1431,6 +1423,58 @@
_matchingbzrdir = property(__get_matchingbzrdir)
+class WorkingTreeFormat4(DirStateWorkingTreeFormat):
+ """The first consolidated dirstate working tree format.
+
+ This format:
+ - exists within a metadir controlling .bzr
+ - includes an explicit version marker for the workingtree control
+ files, separate from the BzrDir format
+ - modifies the hash cache format
+ - is new in bzr 0.15
+ - uses a LockDir to guard access to it.
+ """
+
+ upgrade_recommended = False
+
+ _tree_class = WorkingTree4
+
+ def get_format_string(self):
+ """See WorkingTreeFormat.get_format_string()."""
+ return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
+
+ def get_format_description(self):
+ """See WorkingTreeFormat.get_format_description()."""
+ return "Working tree format 4"
+
+
+class WorkingTreeFormat5(DirStateWorkingTreeFormat):
+ """WorkingTree format supporting views.
+ """
+
+ upgrade_recommended = False
+
+ _tree_class = WorkingTree5
+
+ def get_format_string(self):
+ """See WorkingTreeFormat.get_format_string()."""
+ return "Bazaar Working Tree Format 5 (bzr 1.11)\n"
+
+ def get_format_description(self):
+ """See WorkingTreeFormat.get_format_description()."""
+ return "Working tree format 5"
+
+ def _init_custom_control_files(self, wt):
+ """Subclasses with custom control files should override this method."""
+ wt._transport.put_bytes('views', '', mode=wt.bzrdir._get_file_mode())
+
+ def supports_content_filtering(self):
+ return True
+
+ def supports_views(self):
+ return True
+
+
class DirStateRevisionTree(Tree):
"""A revision tree pulling the inventory from a dirstate."""
@@ -1946,9 +1990,9 @@
@staticmethod
def is_compatible(source, target):
# the target must be a dirstate working tree
- if not isinstance(target, WorkingTree4):
+ if not isinstance(target, DirStateWorkingTree):
return False
- # the source must be a revtreee or dirstate rev tree.
+ # the source must be a revtree or dirstate rev tree.
if not isinstance(source,
(revisiontree.RevisionTree, DirStateRevisionTree)):
return False
@@ -2006,3 +2050,32 @@
tree._transport.put_bytes('format',
self.target_format.get_format_string(),
mode=tree.bzrdir._get_file_mode())
+
+
+class Converter4to5(object):
+ """Perform an in-place upgrade of format 4 to format 5 trees."""
+
+ def __init__(self):
+ self.target_format = WorkingTreeFormat5()
+
+ def convert(self, tree):
+ # lock the control files not the tree, so that we don't get tree
+ # on-unlock behaviours, and so that no-one else diddles with the
+ # tree during upgrade.
+ tree._control_files.lock_write()
+ try:
+ self.init_custom_control_files(tree)
+ self.update_format(tree)
+ finally:
+ tree._control_files.unlock()
+
+ def init_custom_control_files(self, tree):
+ """Initialize custom control files."""
+ tree._transport.put_bytes('views', '',
+ mode=tree.bzrdir._get_file_mode())
+
+ def update_format(self, tree):
+ """Change the format marker."""
+ tree._transport.put_bytes('format',
+ self.target_format.get_format_string(),
+ mode=tree.bzrdir._get_file_mode())
More information about the bazaar-commits
mailing list