Rev 4545: work out some tests that expose that bundles don't work w/ 2a formats. in http://bazaar.launchpad.net/~jameinel/bzr/1.18-bundle-and-stack-393349

John Arbash Meinel john at arbash-meinel.com
Fri Jul 17 15:42:37 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.18-bundle-and-stack-393349

------------------------------------------------------------
revno: 4545
revision-id: john at arbash-meinel.com-20090717144222-kfmh5bxqnilh14ve
parent: john at arbash-meinel.com-20090717144102-vuwda098cerggygy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.18-bundle-and-stack-393349
timestamp: Fri 2009-07-17 09:42:22 -0500
message:
  work out some tests that expose that bundles don't work w/ 2a formats.
  
  Turns out you have to disable/clear the chk_map cache, because otherwise the target
  repository pulls the root chk page out of the cache, rather than seeing it doesn't
  have the page in the repository.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-07-14 17:33:13 +0000
+++ b/bzrlib/chk_map.py	2009-07-17 14:42:22 +0000
@@ -57,6 +57,9 @@
 # We are caching bytes so len(value) is perfectly accurate
 _page_cache = lru_cache.LRUSizeCache(_PAGE_CACHE_SIZE)
 
+def clear_cache():
+    _page_cache.clear()
+
 # If a ChildNode falls below this many bytes, we check for a remap
 _INTERESTING_NEW_SIZE = 50
 # If a ChildNode shrinks by more than this amount, we check for a remap

=== modified file 'bzrlib/tests/per_repository/__init__.py'
--- a/bzrlib/tests/per_repository/__init__.py	2009-07-10 06:45:04 +0000
+++ b/bzrlib/tests/per_repository/__init__.py	2009-07-17 14:42:22 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2008 Canonical Ltd
+# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
 # Authors: Robert Collins <robert.collins at canonical.com>
 #          and others
 #
@@ -872,6 +872,7 @@
         'test_refresh_data',
         'test_repository',
         'test_revision',
+        'test_send',
         'test_statistics',
         'test_write_group',
         ]

=== added file 'bzrlib/tests/per_repository/test_send.py'
--- a/bzrlib/tests/per_repository/test_send.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_repository/test_send.py	2009-07-17 14:42:22 +0000
@@ -0,0 +1,73 @@
+# Copyright (C) 2009 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for how merge directives interact with various repository formats.
+
+Bundles contain the serialized form, so changes in serialization based on
+repository effects the final bundle.
+"""
+
+from bzrlib import (
+    chk_map,
+    errors,
+    merge_directive,
+    tests,
+    )
+
+from bzrlib.tests.per_repository import TestCaseWithRepository
+
+
+class TestMergeDirective(TestCaseWithRepository):
+
+    def make_two_branches(self):
+        builder = self.make_branch_builder('source')
+        builder.start_series()
+        builder.build_snapshot('A', None, [
+            ('add', ('', 'root-id', 'directory', None)),
+            ('add', ('f', 'f-id', 'file', 'initial content\n')),
+            ])
+        builder.build_snapshot('B', 'A', [
+            ('modify', ('f-id', 'new content\n')),
+            ])
+        builder.finish_series()
+        b1 = builder.get_branch()
+        b2 = b1.bzrdir.sprout('target', revision_id='A').open_branch()
+        return b1, b2
+
+    def create_merge_directive(self, source_branch, submit_url):
+        return merge_directive.MergeDirective2.from_objects(
+            source_branch.repository,
+            source_branch.last_revision(),
+            time=1247775710, timezone=0,
+            target_branch=submit_url)
+
+    def test_create_merge_directive(self):
+        source_branch, target_branch = self.make_two_branches()
+        directive = self.create_merge_directive(source_branch,
+                                                target_branch.base)
+        self.assertIsInstance(directive, merge_directive.MergeDirective2)
+
+
+    def test_create_and_install_directive(self):
+        source_branch, target_branch = self.make_two_branches()
+        directive = self.create_merge_directive(source_branch,
+                                                target_branch.base)
+        chk_map.clear_cache()
+        directive.install_revisions(target_branch.repository)
+        rt = target_branch.repository.revision_tree('B')
+        rt.lock_read()
+        self.assertEqualDiff('new content\n', rt.get_file_text('f-id'))
+        rt.unlock()



More information about the bazaar-commits mailing list