Rev 4440: Add a failing test that exposes bug #387294. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-bug387294
John Arbash Meinel
john at arbash-meinel.com
Mon Jun 15 17:11:46 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.17-bug387294
------------------------------------------------------------
revno: 4440
revision-id: john at arbash-meinel.com-20090615161127-9qexcwnyh8k2472b
parent: pqm at pqm.ubuntu.com-20090612094207-jk5dodjd19e9h2hk
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-bug387294
timestamp: Mon 2009-06-15 11:11:27 -0500
message:
Add a failing test that exposes bug #387294.
Adding a check that the StreamSource class can faithfully copy
revisions from and to all repository formats.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_repository/__init__.py'
--- a/bzrlib/tests/per_repository/__init__.py 2009-03-30 11:49:32 +0000
+++ b/bzrlib/tests/per_repository/__init__.py 2009-06-15 16:11:27 +0000
@@ -873,6 +873,7 @@
'test_repository',
'test_revision',
'test_statistics',
+ 'test_stream_source',
'test_write_group',
]
# Parameterize per_repository test modules by format.
=== added file 'bzrlib/tests/per_repository/test_stream_source.py'
--- a/bzrlib/tests/per_repository/test_stream_source.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_repository/test_stream_source.py 2009-06-15 16:11:27 +0000
@@ -0,0 +1,63 @@
+# 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 the generic StreamSource class."""
+
+from bzrlib import (
+ graph,
+ repository,
+ )
+from bzrlib.tests.per_repository import TestCaseWithRepository
+
+
+class TestStreamSource(TestCaseWithRepository):
+
+ def make_simple_history(self):
+ # The generic StreamSource class should be able to stream from any repo
+ # to the same repo, even if it isn't optimized.
+ source = self.make_branch_builder('source')
+ source.start_series()
+ source.build_snapshot('A-id', None, [
+ ('add', ('', 'root-id', 'directory', None)),
+ ('add', ('file', 'file-id', 'file', 'content\n')),
+ ('add', ('dir', 'dir-id', 'directory', None)),
+ ('add', ('dir/foo', 'foo-id', 'file', 'content\n')),
+ ])
+ source.build_snapshot('B-id', ['A-id'], [
+ ('modify', ('file-id', 'new-content\n'))])
+ source.finish_series()
+ b = source.get_branch()
+ b.lock_read()
+ self.addCleanup(b.unlock)
+ return b
+
+ def test_simple_fetch(self):
+ source_b = self.make_simple_history()
+ target = self.make_repository('target')
+ target.lock_write()
+ self.addCleanup(target.unlock)
+ stream_source = repository.StreamSource(source_b.repository,
+ target._format)
+ search = graph.PendingAncestryResult(['B-id'], source_b.repository)
+ stream = stream_source.get_stream(search)
+ sink = target._get_sink()
+ sink.insert_stream(stream, source_b.repository._format, [])
+ # Now that it has been inserted, check it
+ rt_a = target.revision_tree('A-id')
+ self.assertEqualDiff('content\n', rt_a.get_file_text('file-id'))
+ rt_b = target.revision_tree('B-id')
+ self.assertEqualDiff('new-content\n', rt_b.get_file_text('file-id'))
More information about the bazaar-commits
mailing list