Rev 4621: (robertc) Multiple 2a-as-default fixes. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Aug 17 23:43:31 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4621 [merge]
revision-id: pqm at pqm.ubuntu.com-20090817224326-uhljmr5me5x3xyda
parent: pqm at pqm.ubuntu.com-20090817210655-w8d1xxic3wi6gs61
parent: robertc at robertcollins.net-20090817205359-h4ktk6mw9p2mb1ql
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-08-17 23:43:26 +0100
message:
(robertc) Multiple 2a-as-default fixes. (Robert Collins)
modified:
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/per_branch/__init__.py __init__.py-20060123013057-b12a52c3f361daf4
bzrlib/tests/per_branch/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
bzrlib/tests/per_bzrdir/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
bzrlib/tests/per_workingtree/test_basis_inventory.py test_basis_inventory.py-20051218151655-3650468941091309
bzrlib/tests/test_commit.py test_commit.py-20050914060732-279f057f8c295434
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2009-08-13 20:10:26 +0000
+++ b/bzrlib/branch.py 2009-08-17 06:17:21 +0000
@@ -1147,6 +1147,9 @@
revision_id: if not None, the revision history in the new branch will
be truncated to end with revision_id.
"""
+ if (repository_policy is not None and
+ repository_policy.requires_stacking()):
+ to_bzrdir._format.require_stacking(_skip_repo=True)
result = to_bzrdir.create_branch()
result.lock_write()
try:
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2009-08-14 09:31:37 +0000
+++ b/bzrlib/bzrdir.py 2009-08-17 06:17:21 +0000
@@ -3549,6 +3549,10 @@
if self._require_stacking:
raise
+ def requires_stacking(self):
+ """Return True if this policy requires stacking."""
+ return self._stack_on is not None and self._require_stacking
+
def _get_full_stack_on(self):
"""Get a fully-qualified URL for the stack_on location."""
if self._stack_on is None:
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2009-08-14 09:37:57 +0000
+++ b/bzrlib/repository.py 2009-08-17 20:53:59 +0000
@@ -3057,6 +3057,8 @@
# help), and for fetching when data won't have come from the same
# compressor.
pack_compresses = False
+ # Does the repository inventory storage understand references to trees?
+ supports_tree_reference = None
def __str__(self):
return "<%s>" % self.__class__.__name__
=== modified file 'bzrlib/tests/per_branch/__init__.py'
--- a/bzrlib/tests/per_branch/__init__.py 2009-07-10 10:46:00 +0000
+++ b/bzrlib/tests/per_branch/__init__.py 2009-08-17 06:17:21 +0000
@@ -78,7 +78,9 @@
return self.branch
def make_branch(self, relpath, format=None):
- repo = self.make_repository(relpath, format=format)
+ if format is not None:
+ return TestCaseWithBzrDir.make_branch(self, relpath, format)
+ repo = self.make_repository(relpath)
# fixme RBC 20060210 this isnt necessarily a fixable thing,
# Skipped is the wrong exception to raise.
try:
=== modified file 'bzrlib/tests/per_branch/test_stacking.py'
--- a/bzrlib/tests/per_branch/test_stacking.py 2009-08-14 13:55:30 +0000
+++ b/bzrlib/tests/per_branch/test_stacking.py 2009-08-17 06:17:21 +0000
@@ -278,14 +278,28 @@
self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),
cloned_bzrdir.open_branch().get_stacked_on_url)
+ def make_stacked_on_matching(self, source):
+ if source.repository.supports_rich_root():
+ if source.repository._format.supports_chks:
+ format = "2a"
+ else:
+ format = "1.9-rich-root"
+ else:
+ format = "1.9"
+ return self.make_branch('stack-on', format)
+
def test_sprout_stacking_policy_handling(self):
"""Obey policy where possible, ignore otherwise."""
- stack_on = self.make_branch('stack-on')
+ if isinstance(self.branch_format, branch.BzrBranchFormat4):
+ raise TestNotApplicable('Branch format 4 does not autoupgrade.')
+ source = self.make_branch('source')
+ stack_on = self.make_stacked_on_matching(source)
parent_bzrdir = self.make_bzrdir('.', format='default')
parent_bzrdir.get_config().set_default_stack_on('stack-on')
- source = self.make_branch('source')
target = source.bzrdir.sprout('target').open_branch()
- if self.branch_format.supports_stacking():
+ # When we sprout we upgrade the branch when there is a default stack_on
+ # set by a config *and* the targeted branch supports stacking.
+ if stack_on._format.supports_stacking():
self.assertEqual('../stack-on', target.get_stacked_on_url())
else:
self.assertRaises(
@@ -293,13 +307,17 @@
def test_clone_stacking_policy_handling(self):
"""Obey policy where possible, ignore otherwise."""
+ if isinstance(self.branch_format, branch.BzrBranchFormat4):
+ raise TestNotApplicable('Branch format 4 does not autoupgrade.')
self.thisFailsStrictLockCheck()
- stack_on = self.make_branch('stack-on')
+ source = self.make_branch('source')
+ stack_on = self.make_stacked_on_matching(source)
parent_bzrdir = self.make_bzrdir('.', format='default')
parent_bzrdir.get_config().set_default_stack_on('stack-on')
- source = self.make_branch('source')
target = source.bzrdir.clone('target').open_branch()
- if self.branch_format.supports_stacking():
+ # When we clone we upgrade the branch when there is a default stack_on
+ # set by a config *and* the targeted branch supports stacking.
+ if stack_on._format.supports_stacking():
self.assertEqual('../stack-on', target.get_stacked_on_url())
else:
self.assertRaises(
@@ -309,13 +327,15 @@
"""Obey policy where possible, ignore otherwise."""
if isinstance(self.branch_format, branch.BzrBranchFormat4):
raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
- stack_on = self.make_branch('stack-on')
+ source = self.make_branch('source')
+ stack_on = self.make_stacked_on_matching(source)
parent_bzrdir = self.make_bzrdir('.', format='default')
parent_bzrdir.get_config().set_default_stack_on('stack-on')
- source = self.make_branch('source')
url = self.make_smart_server('target').base
target = source.bzrdir.sprout(url).open_branch()
- if self.branch_format.supports_stacking():
+ # When we sprout we upgrade the branch when there is a default stack_on
+ # set by a config *and* the targeted branch supports stacking.
+ if stack_on._format.supports_stacking():
self.assertEqual('../stack-on', target.get_stacked_on_url())
else:
self.assertRaises(
@@ -352,10 +372,10 @@
# repository boundaries. however, i didn't actually get this test to
# fail on that code. -- mbp
# see https://bugs.launchpad.net/bzr/+bug/252821
- if not self.branch_format.supports_stacking():
+ stack_on = self.make_branch_and_tree('stack-on')
+ if not stack_on.branch._format.supports_stacking():
raise TestNotApplicable("%r does not support stacking"
% self.branch_format)
- stack_on = self.make_branch_and_tree('stack-on')
text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
stack_on.add('a')
=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
--- a/bzrlib/tests/per_bzrdir/test_bzrdir.py 2009-08-14 13:55:30 +0000
+++ b/bzrlib/tests/per_bzrdir/test_bzrdir.py 2009-08-17 07:46:03 +0000
@@ -1258,7 +1258,7 @@
# repository is the same as the external location of the stacked-on
# branch.
balloon = self.make_bzrdir('balloon')
- if isinstance(balloon, bzrdir.BzrDirMetaFormat1):
+ if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1):
stack_on = self.make_branch('stack-on', format='1.9')
else:
stack_on = self.make_branch('stack-on')
=== modified file 'bzrlib/tests/per_workingtree/test_basis_inventory.py'
--- a/bzrlib/tests/per_workingtree/test_basis_inventory.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_basis_inventory.py 2009-08-17 06:58:22 +0000
@@ -49,7 +49,7 @@
self.assertEquals('r1', basis_inv.revision_id)
store_inv = b.repository.get_inventory('r1')
- self.assertEquals(store_inv._byid, basis_inv._byid)
+ self.assertEqual([], store_inv._make_delta(basis_inv))
open('b', 'wb').write('b\n')
t.add('b')
@@ -62,7 +62,7 @@
self.assertEquals('r2', basis_inv.revision_id)
store_inv = b.repository.get_inventory('r2')
- self.assertEquals(store_inv._byid, basis_inv._byid)
+ self.assertEqual([], store_inv._make_delta(basis_inv))
def test_wrong_format(self):
"""WorkingTree.basis safely ignores junk basis inventories"""
=== modified file 'bzrlib/tests/test_commit.py'
--- a/bzrlib/tests/test_commit.py 2009-06-10 03:56:49 +0000
+++ b/bzrlib/tests/test_commit.py 2009-08-17 03:58:18 +0000
@@ -708,9 +708,10 @@
cb = self.Callback(u'commit 2', self)
repository = tree.branch.repository
# simulate network failure
- def raise_(self, arg, arg2):
+ def raise_(self, arg, arg2, arg3=None, arg4=None):
raise errors.NoSuchFile('foo')
repository.add_inventory = raise_
+ repository.add_inventory_by_delta = raise_
self.assertRaises(errors.NoSuchFile, tree.commit, message_callback=cb)
self.assertFalse(cb.called)
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2009-07-28 08:09:13 +0000
+++ b/bzrlib/tests/test_knit.py 2009-08-17 06:51:15 +0000
@@ -366,7 +366,7 @@
:return: (versioned_file, reload_counter)
versioned_file a KnitVersionedFiles using the packs for access
"""
- builder = self.make_branch_builder('.')
+ builder = self.make_branch_builder('.', format="1.9")
builder.start_series()
builder.build_snapshot('rev-1', None, [
('add', ('', 'root-id', 'directory', None)),
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2009-08-14 04:11:42 +0000
+++ b/bzrlib/tests/test_repository.py 2009-08-17 20:53:59 +0000
@@ -486,6 +486,8 @@
_serializer = None
def supports_rich_root(self):
+ if self._format is not None:
+ return self._format.rich_root_data
return False
def get_graph(self):
@@ -542,11 +544,17 @@
# pair that it returns true on for the is_compatible static method
# check
dummy_a = DummyRepository()
+ dummy_a._format = RepositoryFormat()
dummy_b = DummyRepository()
+ dummy_b._format = RepositoryFormat()
repo = self.make_repository('.')
# hack dummies to look like repo somewhat.
dummy_a._serializer = repo._serializer
+ dummy_a._format.supports_tree_reference = repo._format.supports_tree_reference
+ dummy_a._format.rich_root_data = repo._format.rich_root_data
dummy_b._serializer = repo._serializer
+ dummy_b._format.supports_tree_reference = repo._format.supports_tree_reference
+ dummy_b._format.rich_root_data = repo._format.rich_root_data
repository.InterRepository.register_optimiser(InterDummy)
try:
# we should get the default for something InterDummy returns False
@@ -1033,7 +1041,7 @@
def make_packs_and_alt_repo(self, write_lock=False):
"""Create a pack repo with 3 packs, and access it via a second repo."""
- tree = self.make_branch_and_tree('.')
+ tree = self.make_branch_and_tree('.', format=self.get_format())
tree.lock_write()
self.addCleanup(tree.unlock)
rev1 = tree.commit('one')
@@ -1349,7 +1357,7 @@
"""Tests for the packs repository Packer class."""
def test_pack_optimizes_pack_order(self):
- builder = self.make_branch_builder('.')
+ builder = self.make_branch_builder('.', format="1.9")
builder.start_series()
builder.build_snapshot('A', None, [
('add', ('', 'root-id', 'directory', None)),
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2009-08-07 04:17:51 +0000
+++ b/bzrlib/tests/test_smart.py 2009-08-17 20:53:59 +0000
@@ -202,7 +202,7 @@
self.make_bzrdir('.')
request_class = bzrlib.smart.bzrdir.SmartServerRequestCreateRepository
request = request_class(backing)
- reference_bzrdir_format = bzrdir.format_registry.get('default')()
+ reference_bzrdir_format = bzrdir.format_registry.get('pack-0.92')()
reference_format = reference_bzrdir_format.repository_format
network_name = reference_format.network_name()
expected = SuccessfulSmartServerResponse(
@@ -247,17 +247,21 @@
subtrees = 'yes'
else:
subtrees = 'no'
+ if repo._format.supports_external_lookups:
+ external = 'yes'
+ else:
+ external = 'no'
if (smart.bzrdir.SmartServerRequestFindRepositoryV3 ==
self._request_class):
return SuccessfulSmartServerResponse(
- ('ok', '', rich_root, subtrees, 'no',
+ ('ok', '', rich_root, subtrees, external,
repo._format.network_name()))
elif (smart.bzrdir.SmartServerRequestFindRepositoryV2 ==
self._request_class):
# All tests so far are on formats, and for non-external
# repositories.
return SuccessfulSmartServerResponse(
- ('ok', '', rich_root, subtrees, 'no'))
+ ('ok', '', rich_root, subtrees, external))
else:
return SuccessfulSmartServerResponse(('ok', '', rich_root, subtrees))
More information about the bazaar-commits
mailing list