Rev 3228: Inspect Repository fetch tests for places where a readonly copy can be a valid check. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
Robert Collins
robertc at robertcollins.net
Mon Feb 18 04:23:55 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
------------------------------------------------------------
revno: 3228
revision-id:robertc at robertcollins.net-20080218042350-hwvgpp0hcbxm682h
parent: robertc at robertcollins.net-20080218035837-6h8bw9pxvxte6gix
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository_implementations.split_read_write
timestamp: Mon 2008-02-18 15:23:50 +1100
message:
Inspect Repository fetch tests for places where a readonly copy can be a valid check.
modified:
bzrlib/tests/repository_implementations/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
=== modified file 'bzrlib/tests/repository_implementations/test_fetch.py'
--- a/bzrlib/tests/repository_implementations/test_fetch.py 2008-01-02 03:08:59 +0000
+++ b/bzrlib/tests/repository_implementations/test_fetch.py 2008-02-18 04:23:50 +0000
@@ -36,22 +36,25 @@
tree_a = self.make_branch_and_tree('a')
self.build_tree(['a/foo'])
tree_a.add('foo', 'file1')
- tree_a.commit('rev1', rev_id='rev1')
+ rev_id = tree_a.commit('rev1')
# fetch with a default limit (grab everything)
repo = self.make_repository('b')
if (tree_a.branch.repository.supports_rich_root() and not
repo.supports_rich_root()):
raise TestSkipped('Cannot fetch from model2 to model1')
- repo.fetch(tree_a.branch.repository,
- revision_id=None)
- ## pb=bzrlib.progress.DummyProgress())
+ repo.fetch(tree_a.branch.repository, revision_id=None)
+ # check the revisions got copied.
+ repo = self._make_test_read_instance(repo)
+ repo.lock_read()
+ self.addCleanup(repo.unlock)
+ self.assertEqual(set([rev_id]), set(repo.all_revision_ids()))
def test_fetch_knit3(self):
# create a repository of the sort we are testing.
tree_a = self.make_branch_and_tree('a', '')
self.build_tree(['a/foo'])
tree_a.add('foo', 'file1')
- tree_a.commit('rev1', rev_id='rev1')
+ rev1_id = tree_a.commit('rev1')
# create a knit-3 based format to fetch into
f = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
try:
@@ -67,8 +70,10 @@
knit3_repo.fetch(tree_a.branch.repository, revision_id=None)
# Reopen to avoid any in-memory caching - ensure its reading from
# disk.
- knit3_repo = b_bzrdir.open_repository()
- rev1_tree = knit3_repo.revision_tree('rev1')
+ knit3_repo = self._make_test_read_instance(b_bzrdir.open_repository())
+ knit3_repo.lock_read()
+ self.addCleanup(knit3_repo.unlock)
+ rev1_tree = knit3_repo.revision_tree(rev1_id)
lines = rev1_tree.get_file_lines(rev1_tree.get_root_id())
self.assertEqual([], lines)
b_branch = b_bzrdir.create_branch()
@@ -79,15 +84,19 @@
raise TestSkipped("cannot make working tree with transport %r"
% b_bzrdir.transport)
tree_b.commit('no change', rev_id='rev2')
+ knit3_repo = self._make_test_read_instance(tree_b.branch.repository)
+ knit3_repo.lock_read()
+ self.addCleanup(knit3_repo.unlock)
rev2_tree = knit3_repo.revision_tree('rev2')
- self.assertEqual('rev1', rev2_tree.inventory.root.revision)
+ self.assertEqual(rev1_id, rev2_tree.inventory.root.revision)
def test_fetch_all_from_self(self):
tree = self.make_branch_and_tree('.')
rev_id = tree.commit('one')
- # This needs to be a new copy of the repository, if this changes, the
- # test needs to be rewritten
- repo = tree.branch.repository.bzrdir.open_repository()
+ # This needs to be a new instance of the repository, if this changes,
+ # the test needs to be rewritten>
+ repo = self._make_test_read_instance(
+ tree.branch.repository.bzrdir.open_repository())
# This fetch should be a no-op see bug #158333
tree.branch.repository.fetch(repo, None)
@@ -100,7 +109,6 @@
def test_fetch_missing_from_self(self):
tree = self.make_branch_and_tree('.')
- rev_id = tree.commit('one')
# Even though the fetch() is a NO-OP it should assert the revision id
# is present
repo = tree.branch.repository.bzrdir.open_repository()
@@ -119,7 +127,8 @@
return repo
def test_fetch_copies_signatures(self):
- source_repo = self.makeARepoWithSignatures()
+ source_repo = self._make_test_read_instance(
+ self.makeARepoWithSignatures())
target_repo = self.make_repository('target')
target_repo.fetch(source_repo, revision_id=None)
self.assertEqual(
@@ -133,7 +142,8 @@
def test_fetch_revision_already_exists(self):
# Make a repository with one revision.
- source_repo = self.make_repository_with_one_revision()
+ source_repo = self._make_test_read_instance(
+ self.make_repository_with_one_revision())
# Fetch that revision into a second repository.
target_repo = self.make_repository('target')
target_repo.fetch(source_repo, revision_id='rev1')
More information about the bazaar-commits
mailing list