Rev 2199: Make all BzrDir implementation tests pass on RemoteBzrDir - fix some things, and remove the incomplete_with_basis tests as cruft. in http://bazaar.launchpad.net/~bzr/bzr/hpss
Robert Collins
robertc at robertcollins.net
Thu Mar 29 09:59:50 BST 2007
At http://bazaar.launchpad.net/~bzr/bzr/hpss
------------------------------------------------------------
revno: 2199
revision-id: robertc at robertcollins.net-20070329085846-0tmwanst070lb0e5
parent: andrew.bennetts at canonical.com-20070329084623-ruqx0po8q3lxw0b7
committer: Robert Collins <robertc at robertcollins.net>
branch nick: hpss
timestamp: Thu 2007-03-29 18:58:46 +1000
message:
Make all BzrDir implementation tests pass on RemoteBzrDir - fix some things, and remove the incomplete_with_basis tests as cruft.
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2007-03-29 06:46:28 +0000
+++ b/bzrlib/remote.py 2007-03-29 08:58:46 +0000
@@ -94,22 +94,32 @@
b = self.open_branch()
return b._format
- def open_branch(self, _unsupported=False):
- assert _unsupported == False, 'unsupported flag support not implemented yet.'
+ def get_branch_reference(self):
+ """See BzrDir.get_branch_reference()."""
path = self._path_for_remote_call(self._client)
response = self._client.call('BzrDir.open_branch', path)
if response[0] == 'ok':
if response[1] == '':
# branch at this location.
- return RemoteBranch(self, self.find_repository())
+ return None
else:
# a branch reference, use the existing BranchReference logic.
- format = BranchReferenceFormat()
- return format.open(self, _found=True, location=response[1])
+ return response[1]
elif response == ('nobranch',):
raise errors.NotBranchError(path=self.root_transport.base)
else:
assert False, 'unexpected response code %r' % (response,)
+
+ def open_branch(self, _unsupported=False):
+ assert _unsupported == False, 'unsupported flag support not implemented yet.'
+ reference_url = self.get_branch_reference()
+ if reference_url is None:
+ # branch at this location.
+ return RemoteBranch(self, self.find_repository())
+ else:
+ # a branch reference, use the existing BranchReference logic.
+ format = BranchReferenceFormat()
+ return format.open(self, _found=True, location=reference_url)
def open_repository(self):
path = self._path_for_remote_call(self._client)
@@ -128,7 +138,7 @@
raise errors.NoRepositoryPresent(self)
def open_workingtree(self):
- return RemoteWorkingTree(self, self._real_bzrdir.open_workingtree())
+ raise errors.NotLocalUrl(self.root_transport)
def _path_for_remote_call(self, client):
"""Return the path to be used for this bzrdir in a remote call."""
@@ -935,18 +945,6 @@
other, stop_revision=stop_revision)
-class RemoteWorkingTree(object):
-
- def __init__(self, remote_bzrdir, real_workingtree):
- self.real_workingtree = real_workingtree
- self.bzrdir = remote_bzrdir
-
- def __getattr__(self, name):
- # XXX: temporary way to lazily delegate everything to the real
- # workingtree
- return getattr(self.real_workingtree, name)
-
-
class RemoteBranchConfig(BranchConfig):
def username(self):
=== modified file 'bzrlib/tests/bzrdir_implementations/test_bzrdir.py'
--- a/bzrlib/tests/bzrdir_implementations/test_bzrdir.py 2007-03-28 22:54:43 +0000
+++ b/bzrlib/tests/bzrdir_implementations/test_bzrdir.py 2007-03-29 08:58:46 +0000
@@ -51,6 +51,7 @@
from bzrlib.trace import mutter
from bzrlib.transport import get_transport
from bzrlib.upgrade import upgrade
+from bzrlib.remote import RemoteBzrDir
from bzrlib.repofmt import weaverepo
@@ -243,7 +244,7 @@
tree.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
- tree.bzrdir.open_repository().copy_content_into(shared_repo)
+ tree.branch.bzrdir.open_repository().copy_content_into(shared_repo)
dir = self.make_bzrdir('shared/source')
dir.create_branch()
target = dir.clone(self.get_url('shared/target'))
@@ -257,15 +258,16 @@
except errors.IncompatibleFormat:
return
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
- tree.bzrdir.open_branch().set_revision_history([])
+ tree.branch.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
- tree.bzrdir.open_repository().copy_content_into(shared_repo)
- shared_repo.set_make_working_trees(False)
- self.assertFalse(shared_repo.make_working_trees())
+ tree.branch.bzrdir.open_repository().copy_content_into(shared_repo)
+ if shared_repo.make_working_trees():
+ shared_repo.set_make_working_trees(False)
+ self.assertFalse(shared_repo.make_working_trees())
self.assertTrue(shared_repo.has_revision('1'))
dir = self.make_bzrdir('shared/source')
dir.create_branch()
@@ -279,7 +281,7 @@
def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
dir = self.make_bzrdir('source')
@@ -302,21 +304,21 @@
# and clone it with a revision limit.
#
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
- tree.bzrdir.open_branch().set_revision_history([])
+ tree.branch.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
source = self.make_repository('source')
- tree.bzrdir.open_repository().copy_content_into(source)
+ tree.branch.bzrdir.open_repository().copy_content_into(source)
dir = source.bzrdir
target = dir.clone(self.get_url('target'), revision_id='2')
raise TestSkipped('revision limiting not strict yet')
def test_clone_bzrdir_branch_and_repo(self):
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1')
source = self.make_branch('source')
@@ -337,7 +339,7 @@
def test_clone_bzrdir_branch_and_repo_into_shared_repo(self):
# by default cloning into a shared repo uses the shared repo.
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1')
source = self.make_branch('source')
@@ -357,7 +359,7 @@
def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self):
# by default cloning into a shared repo uses the shared repo.
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1')
source = self.make_branch('source')
@@ -397,7 +399,7 @@
# and clone it with a revision limit.
#
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.commit('revision 2', rev_id='2', allow_pointless=True)
@@ -409,8 +411,8 @@
self.assertEqual('1', target.open_branch().last_revision())
def test_clone_bzrdir_tree_branch_repo(self):
- tree = self.make_branch_and_tree('sourcce')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ tree = self.make_branch_and_tree('source')
+ self.build_tree(['source/foo'])
tree.add('foo')
tree.commit('revision 1')
dir = tree.bzrdir
@@ -429,8 +431,8 @@
target.open_workingtree().revert([])
def test_revert_inventory(self):
- tree = self.make_branch_and_tree('sourcce')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ tree = self.make_branch_and_tree('source')
+ self.build_tree(['source/foo'])
tree.add('foo')
tree.commit('revision 1')
dir = tree.bzrdir
@@ -485,7 +487,7 @@
# This smoke test just checks the revision-id is right. Tree specific
# tests will check corner cases.
tree = self.make_branch_and_tree('source')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['source/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.commit('revision 2', rev_id='2', allow_pointless=True)
@@ -494,30 +496,6 @@
self.skipIfNoWorkingTree(target)
self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
- def test_clone_bzrdir_incomplete_source_with_basis(self):
- # ensure that basis really does grab from the basis by having incomplete source
- tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
- tree.add('foo')
- tree.commit('revision 1', rev_id='1')
- source = self.make_branch_and_tree('source')
- # this gives us an incomplete repository
- tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
- tree.commit('revision 2', rev_id='2', allow_pointless=True)
- tree.bzrdir.open_branch().copy_content_into(source.branch)
- tree.copy_content_into(source)
- self.assertFalse(source.branch.repository.has_revision('2'))
- dir = source.bzrdir
- target = dir.clone(self.get_url('target'), basis=tree.bzrdir)
- self.assertEqual('2', target.open_branch().last_revision())
- try:
- self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
- except errors.NoWorkingTree:
- # It should have a working tree if it's able to have one, so if
- # we're here make sure it really can't have one.
- self.assertRaises(errors.NotLocalUrl, target.create_workingtree)
- self.assertTrue(target.open_branch().repository.has_revision('2'))
-
def test_get_branch_reference_on_reference(self):
"""get_branch_reference should return the right url."""
referenced_branch = self.make_branch('referenced')
@@ -563,7 +541,12 @@
target = self.sproutOrSkip(dir, self.get_url('target/child'))
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
target.open_branch()
- target.open_workingtree()
+ try:
+ target.open_workingtree()
+ except errors.NotLocalUrl:
+ # bzrdir's that test against non-local urls are allowed to pass:
+ # whitelist them for now
+ self.assertIsInstance(target, RemoteBzrDir)
def test_sprout_bzrdir_empty_under_shared_repo_force_new(self):
# the force_new_repo parameter should force use of a new repo in an empty
@@ -617,14 +600,14 @@
def test_sprout_bzrdir_with_repository_to_shared(self):
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
source = self.make_repository('source')
- tree.bzrdir.open_repository().copy_content_into(source)
+ tree.branch.bzrdir.open_repository().copy_content_into(source)
dir = source.bzrdir
try:
shared_repo = self.make_repository('target', shared=True)
@@ -640,13 +623,13 @@
except errors.IncompatibleFormat:
return
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
- tree.bzrdir.open_repository().copy_content_into(shared_repo)
+ tree.branch.bzrdir.open_repository().copy_content_into(shared_repo)
dir = self.make_bzrdir('shared/source')
dir.create_branch()
target = self.sproutOrSkip(dir, self.get_url('shared/target'))
@@ -660,15 +643,16 @@
except errors.IncompatibleFormat:
return
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
- tree.bzrdir.open_repository().copy_content_into(shared_repo)
- shared_repo.set_make_working_trees(False)
- self.assertFalse(shared_repo.make_working_trees())
+ tree.branch.bzrdir.open_repository().copy_content_into(shared_repo)
+ if shared_repo.make_working_trees():
+ shared_repo.set_make_working_trees(False)
+ self.assertFalse(shared_repo.make_working_trees())
self.assertTrue(shared_repo.has_revision('1'))
dir = self.make_bzrdir('shared/source')
dir.create_branch()
@@ -677,19 +661,20 @@
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
branch = target.open_branch()
self.assertTrue(branch.repository.has_revision('1'))
- self.assertTrue(branch.repository.make_working_trees())
+ if not isinstance(branch.bzrdir, RemoteBzrDir):
+ self.assertTrue(branch.repository.make_working_trees())
self.assertFalse(branch.repository.is_shared())
def test_sprout_bzrdir_repository_under_shared_force_new_repo(self):
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
source = self.make_repository('source')
- tree.bzrdir.open_repository().copy_content_into(source)
+ tree.branch.bzrdir.open_repository().copy_content_into(source)
dir = source.bzrdir
try:
shared_repo = self.make_repository('target', shared=True)
@@ -706,25 +691,25 @@
# and sprout it with a revision limit.
#
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.bzrdir.open_branch().set_revision_history([])
tree.set_parent_trees([])
tree.commit('revision 2', rev_id='2')
source = self.make_repository('source')
- tree.bzrdir.open_repository().copy_content_into(source)
+ tree.branch.bzrdir.open_repository().copy_content_into(source)
dir = source.bzrdir
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='2')
raise TestSkipped('revision limiting not strict yet')
def test_sprout_bzrdir_branch_and_repo(self):
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1')
source = self.make_branch('source')
- tree.bzrdir.open_repository().copy_content_into(source.repository)
+ tree.branch.bzrdir.open_repository().copy_content_into(source.repository)
tree.bzrdir.open_branch().copy_content_into(source)
dir = source.bzrdir
target = self.sproutOrSkip(dir, self.get_url('target'))
@@ -748,11 +733,11 @@
# sprouting a branch with a repo into a shared repo uses the shared
# repo
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
source = self.make_branch('source')
- tree.bzrdir.open_repository().copy_content_into(source.repository)
+ tree.branch.bzrdir.open_repository().copy_content_into(source.repository)
tree.bzrdir.open_branch().copy_content_into(source)
dir = source.bzrdir
try:
@@ -766,11 +751,11 @@
# sprouting a branch with a repo into a shared repo uses the shared
# repo
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
source = self.make_branch('source')
- tree.bzrdir.open_repository().copy_content_into(source.repository)
+ tree.branch.bzrdir.open_repository().copy_content_into(source.repository)
tree.bzrdir.open_branch().copy_content_into(source)
dir = source.bzrdir
try:
@@ -859,19 +844,19 @@
# and sprout it with a revision limit.
#
tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
+ self.build_tree(['commit_tree/foo'])
tree.add('foo')
tree.commit('revision 1', rev_id='1')
tree.commit('revision 2', rev_id='2', allow_pointless=True)
source = self.make_branch('source')
- tree.bzrdir.open_repository().copy_content_into(source.repository)
+ tree.branch.bzrdir.open_repository().copy_content_into(source.repository)
tree.bzrdir.open_branch().copy_content_into(source)
dir = source.bzrdir
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
self.assertEqual('1', target.open_branch().last_revision())
def test_sprout_bzrdir_tree_branch_repo(self):
- tree = self.make_branch_and_tree('sourcce')
+ tree = self.make_branch_and_tree('source')
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
tree.add('foo')
tree.commit('revision 1')
@@ -961,26 +946,6 @@
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
- def test_sprout_bzrdir_incomplete_source_with_basis(self):
- # ensure that basis really does grab from the basis by having incomplete source
- tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['commit_tree/foo'])
- tree.add('foo')
- tree.commit('revision 1', rev_id='1')
- source = self.make_branch_and_tree('source')
- # this gives us an incomplete repository
- tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
- tree.commit('revision 2', rev_id='2', allow_pointless=True)
- tree.bzrdir.open_branch().copy_content_into(source.branch)
- tree.copy_content_into(source)
- self.assertFalse(source.branch.repository.has_revision('2'))
- dir = source.bzrdir
- target = self.sproutOrSkip(dir, self.get_url('target'),
- basis=tree.bzrdir)
- self.assertEqual('2', target.open_branch().last_revision())
- self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
- self.assertTrue(target.open_branch().repository.has_revision('2'))
-
def test_format_initialize_find_open(self):
# loopback test to check the current format initializes to itself.
if not self.bzrdir_format.is_supported():
@@ -1117,7 +1082,7 @@
source = self.make_branch_and_tree('source')
source.commit('a', rev_id='a', allow_pointless=True)
source.commit('b', rev_id='b', allow_pointless=True)
- self.build_tree(['new/'])
+ t.mkdir('new')
t_new = t.clone('new')
made_control = self.bzrdir_format.initialize_on_transport(t_new)
source.branch.repository.clone(made_control)
More information about the bazaar-commits
mailing list