Rev 5818: (jelmer) Support lazily setting the default format for working trees. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed May 4 02:29:23 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5818 [merge]
revision-id: pqm at pqm.ubuntu.com-20110504022916-5kjvsleivsy53zox
parent: pqm at pqm.ubuntu.com-20110504004926-sxf2v0q9ldwlqm1m
parent: jelmer at samba.org-20110504014210-k3o9194vcp883b02
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-05-04 02:29:16 +0000
message:
(jelmer) Support lazily setting the default format for working trees.
(Jelmer Vernooij)
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/blackbox/test_exceptions.py test_exceptions.py-20060604211237-yi2cxg0ose3xk4id-1
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
bzrlib/tests/test_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2011-04-05 14:47:30 +0000
+++ b/bzrlib/bzrdir.py 2011-05-03 22:53:39 +0000
@@ -2121,9 +2121,7 @@
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
'above when accessed over the network.',
branch_format='bzrlib.branch.BzrBranchFormat5',
- # this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
- # directly from workingtree_4 triggers a circular import.
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
deprecated=True)
register_metadir(controldir.format_registry, 'dirstate-tags',
@@ -2132,7 +2130,7 @@
'network operations. Additionally adds support for tags.'
' Incompatible with bzr < 0.15.',
branch_format='bzrlib.branch.BzrBranchFormat6',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
deprecated=True)
register_metadir(controldir.format_registry, 'rich-root',
@@ -2140,7 +2138,7 @@
help='New in 1.0. Better handling of tree roots. Incompatible with'
' bzr < 1.0.',
branch_format='bzrlib.branch.BzrBranchFormat6',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
deprecated=True)
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
@@ -2149,7 +2147,7 @@
'network operations. Additionally adds support for versioning nested '
'bzr branches. Incompatible with bzr < 0.15.',
branch_format='bzrlib.branch.BzrBranchFormat6',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
experimental=True,
hidden=True,
)
@@ -2160,7 +2158,7 @@
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
,
branch_format='bzrlib.branch.BzrBranchFormat6',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
)
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
@@ -2169,7 +2167,7 @@
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
,
branch_format='bzrlib.branch.BzrBranchFormat6',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
experimental=True,
)
@@ -2178,7 +2176,7 @@
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
'(needed for bzr-svn and bzr-git).',
branch_format='bzrlib.branch.BzrBranchFormat6',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
)
register_metadir(controldir.format_registry, '1.6',
@@ -2187,7 +2185,7 @@
'(stacked) repository that should be used to access data that is '
'not present locally.',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
)
register_metadir(controldir.format_registry, '1.6.1-rich-root',
@@ -2195,7 +2193,7 @@
help='A variant of 1.6 that supports rich-root data '
'(needed for bzr-svn and bzr-git).',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
)
register_metadir(controldir.format_registry, '1.9',
@@ -2204,7 +2202,7 @@
'are smaller in size, have smarter caching and provide faster '
'performance for most operations.',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
)
register_metadir(controldir.format_registry, '1.9-rich-root',
@@ -2212,21 +2210,21 @@
help='A variant of 1.9 that supports rich-root data '
'(needed for bzr-svn and bzr-git).',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
hidden=True,
)
register_metadir(controldir.format_registry, '1.14',
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
help='A working-tree format that supports content filtering.',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat5',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
)
register_metadir(controldir.format_registry, '1.14-rich-root',
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
help='A variant of 1.14 that supports rich-root data '
'(needed for bzr-svn and bzr-git).',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat5',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
)
# The following un-numbered 'development' formats should always just be aliases.
register_metadir(controldir.format_registry, 'development-subtree',
@@ -2238,7 +2236,7 @@
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
'before use.',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat6',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
experimental=True,
hidden=True,
alias=False, # Restore to being an alias when an actual development subtree format is added
@@ -2254,7 +2252,7 @@
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
'before use.',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat6',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
experimental=True,
hidden=True,
alias=False,
@@ -2271,7 +2269,7 @@
# 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
# 'rich roots. Supported by bzr 1.16 and later.',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat6',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
experimental=False,
)
@@ -2280,7 +2278,7 @@
register_metadir(controldir.format_registry, 'default-rich-root',
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat6',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
alias=True,
hidden=True,
help='Same as 2a.')
=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- a/bzrlib/tests/blackbox/test_exceptions.py 2011-04-15 18:11:36 +0000
+++ b/bzrlib/tests/blackbox/test_exceptions.py 2011-05-03 22:59:49 +0000
@@ -102,7 +102,7 @@
bzrdir.register_metadir(controldir.format_registry, "testobsolete",
"bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
branch_format='bzrlib.branch.BzrBranchFormat7',
- tree_format='bzrlib.workingtree.WorkingTreeFormat6',
+ tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
deprecated=True,
help='Same as 2a, but with an obsolete repo format.')
self.disable_deprecation_warning()
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2011-04-15 07:01:22 +0000
+++ b/bzrlib/tests/test_selftest.py 2011-05-04 01:42:10 +0000
@@ -52,6 +52,7 @@
tests,
transport,
workingtree,
+ workingtree_4,
)
from bzrlib.repofmt import (
groupcompress_repo,
@@ -338,7 +339,7 @@
from bzrlib.tests.per_workingtree import make_scenarios
server1 = "a"
server2 = "b"
- formats = [workingtree.WorkingTreeFormat4(),
+ formats = [workingtree_4.WorkingTreeFormat4(),
workingtree.WorkingTreeFormat3(),]
scenarios = make_scenarios(server1, server2, formats)
self.assertEqual([
@@ -375,13 +376,13 @@
)
server1 = "a"
server2 = "b"
- formats = [workingtree.WorkingTreeFormat4(),
+ formats = [workingtree_4.WorkingTreeFormat4(),
workingtree.WorkingTreeFormat3(),]
scenarios = make_scenarios(server1, server2, formats)
self.assertEqual(7, len(scenarios))
default_wt_format = workingtree.format_registry.get_default()
- wt4_format = workingtree.WorkingTreeFormat4()
- wt5_format = workingtree.WorkingTreeFormat5()
+ wt4_format = workingtree_4.WorkingTreeFormat4()
+ wt5_format = workingtree_4.WorkingTreeFormat5()
expected_scenarios = [
('WorkingTreeFormat4',
{'bzrdir_format': formats[0]._matchingbzrdir,
@@ -453,7 +454,8 @@
from bzrlib.tests.per_intertree import (
make_scenarios,
)
- from bzrlib.workingtree import WorkingTreeFormat3, WorkingTreeFormat4
+ from bzrlib.workingtree import WorkingTreeFormat3
+ from bzrlib.workingtree_4 import WorkingTreeFormat4
input_test = TestInterTreeScenarios(
"test_scenarios")
server1 = "a"
=== modified file 'bzrlib/tests/test_workingtree.py'
--- a/bzrlib/tests/test_workingtree.py 2011-04-15 07:01:22 +0000
+++ b/bzrlib/tests/test_workingtree.py 2011-05-03 22:53:39 +0000
@@ -77,6 +77,27 @@
workingtree.format_registry.set_default(old_format)
self.assertEqual(old_format, workingtree.format_registry.get_default())
+ def test_get_set_default_format_by_key(self):
+ old_format = workingtree.format_registry.get_default()
+ # default is 3
+ format = SampleTreeFormat()
+ workingtree.format_registry.register(format)
+ self.addCleanup(workingtree.format_registry.remove, format)
+ self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
+ workingtree.format_registry.set_default_key(format.get_format_string())
+ try:
+ # the default branch format is used by the meta dir format
+ # which is not the default bzrdir format at this point
+ dir = bzrdir.BzrDirMetaFormat1().initialize('.')
+ dir.create_repository()
+ dir.create_branch()
+ result = dir.create_workingtree()
+ self.assertEqual(result, 'A tree')
+ finally:
+ workingtree.format_registry.set_default_key(
+ old_format.get_format_string())
+ self.assertEqual(old_format, workingtree.format_registry.get_default())
+
def test_open(self):
tree = self.make_branch_and_tree('.')
open_direct = workingtree.WorkingTree.open('.')
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2011-04-20 16:40:53 +0000
+++ b/bzrlib/workingtree.py 2011-05-04 00:03:41 +0000
@@ -68,11 +68,6 @@
xml5,
xml7,
)
-from bzrlib.workingtree_4 import (
- WorkingTreeFormat4,
- WorkingTreeFormat5,
- WorkingTreeFormat6,
- )
""")
from bzrlib import symbol_versioning
@@ -2973,13 +2968,24 @@
def __init__(self, other_registry=None):
super(WorkingTreeFormatRegistry, self).__init__(other_registry)
self._default_format = None
+ self._default_format_key = None
def get_default(self):
"""Return the current default format."""
+ if (self._default_format_key is not None and
+ self._default_format is None):
+ self._default_format = self.get(self._default_format_key)
return self._default_format
def set_default(self, format):
+ """Set the default format."""
self._default_format = format
+ self._default_format_key = None
+
+ def set_default_key(self, format_string):
+ """Set the default format by its format string."""
+ self._default_format_key = format_string
+ self._default_format = None
format_registry = WorkingTreeFormatRegistry()
@@ -3252,7 +3258,6 @@
return self.get_format_string()
-__default_format = WorkingTreeFormat6()
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
"bzrlib.workingtree_4", "WorkingTreeFormat4")
format_registry.register_lazy("Bazaar Working Tree Format 5 (bzr 1.11)\n",
@@ -3260,4 +3265,4 @@
format_registry.register_lazy("Bazaar Working Tree Format 6 (bzr 1.14)\n",
"bzrlib.workingtree_4", "WorkingTreeFormat6")
format_registry.register(WorkingTreeFormat3())
-format_registry.set_default(__default_format)
+format_registry.set_default_key("Bazaar Working Tree Format 6 (bzr 1.14)\n")
More information about the bazaar-commits
mailing list