Rev 2161: Various small changes in aid of making tests pass (including deleting one invalid test). in sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/
Andrew Bennetts
andrew.bennetts at canonical.com
Tue Mar 6 13:44:07 GMT 2007
At sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/
------------------------------------------------------------
revno: 2161
revision-id: andrew.bennetts at canonical.com-20070306133649-2371mkrfnrxcqjnn
parent: andrew.bennetts at canonical.com-20070306112113-9pow71l4euaiftth
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss
timestamp: Wed 2007-03-07 00:36:49 +1100
message:
Various small changes in aid of making tests pass (including deleting one invalid test).
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-03-06 07:13:40 +0000
+++ b/bzrlib/bzrdir.py 2007-03-06 13:36:49 +0000
@@ -654,7 +654,9 @@
except errors.NoRepositoryPresent:
pass
else:
- result_format.repository_format = source_repository._format
+ repo_format = source_repository._format
+ if not isinstance(repo_format, remote.RemoteRepositoryFormat):
+ result_format.repository_format = repo_format
return result_format
def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py 2007-03-05 06:04:19 +0000
+++ b/bzrlib/fetch.py 2007-03-06 13:36:49 +0000
@@ -44,6 +44,10 @@
from bzrlib.trace import mutter
import bzrlib.ui
+from bzrlib.lazy_import import lazy_import
+lazy_import(globals(), '''
+from bzrlib.remote import RemoteRepository
+''')
# TODO: Avoid repeatedly opening weaves so many times.
@@ -88,6 +92,12 @@
# result variables.
self.failed_revisions = []
self.count_copied = 0
+ if isinstance(to_repository, RemoteRepository):
+ to_repository._ensure_real()
+ to_repository = to_repository._real_repository
+ if isinstance(from_repository, RemoteRepository):
+ from_repository._ensure_real()
+ from_repository = from_repository._real_repository
if to_repository.control_files._transport.base == from_repository.control_files._transport.base:
# check that last_revision is in 'from' and then return a no-operation.
if last_revision not in (None, NULL_REVISION):
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2007-03-05 05:15:57 +0000
+++ b/bzrlib/remote.py 2007-03-06 13:36:49 +0000
@@ -138,6 +138,16 @@
"""Upgrading of remote bzrdirs is not supported yet."""
return False
+ def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
+ self._ensure_real()
+ return self._real_bzrdir.clone(url, revision_id=revision_id,
+ basis=basis, force_new_repo=force_new_repo)
+
+ #def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
+ # self._ensure_real()
+ # return self._real_bzrdir.sprout(url, revision_id=revision_id,
+ # basis=basis, force_new_repo=force_new_repo)
+
class RemoteRepositoryFormat(repository.RepositoryFormat):
"""Format for repositories accessed over rpc.
@@ -799,6 +809,17 @@
def get_config(self):
return RemoteBranchConfig(self)
+ def sprout(self, to_bzrdir, revision_id=None):
+ # Like Branch.sprout, except that it sprouts a branch in the default
+ # format, because RemoteBranches can't be created at arbitrary URLs.
+ # XXX: if to_bzrdir is a RemoteBranch, this should perhaps do
+ # to_bzrdir.create_branch...
+ self._ensure_real()
+ result = branch.BranchFormat.get_default_format().initialize(to_bzrdir)
+ self._real_branch.copy_content_into(result, revision_id=revision_id)
+ result.set_parent(self.bzrdir.root_transport.base)
+ return result
+
@needs_write_lock
def append_revision(self, *revision_ids):
self._ensure_real()
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2007-03-05 07:48:29 +0000
+++ b/bzrlib/tests/__init__.py 2007-03-06 13:36:49 +0000
@@ -1669,7 +1669,7 @@
# branch and create a local checkout.
if not os.path.exists('_checkouts'):
os.mkdir('_checkouts')
- return b.create_checkout('_checkouts/' + relpath)
+ return b.create_checkout('_checkouts/' + relpath, lightweight=True)
def assertIsDirectory(self, relpath, transport):
"""Assert that relpath within transport is a directory.
=== modified file 'bzrlib/tests/branch_implementations/test_branch.py'
--- a/bzrlib/tests/branch_implementations/test_branch.py 2007-03-01 05:08:32 +0000
+++ b/bzrlib/tests/branch_implementations/test_branch.py 2007-03-06 13:36:49 +0000
@@ -152,13 +152,11 @@
def get_unbalanced_tree_pair(self):
"""Return two branches, a and b, with one file in a."""
- get_transport(self.get_url()).mkdir('a')
tree_a = self.make_branch_and_tree('a')
- file('a/b', 'wb').write('b')
+ tree_a.bzrdir.root_transport.put_bytes_non_atomic('b', 'b')
tree_a.add('b')
tree_a.commit("silly commit", rev_id='A')
- get_transport(self.get_url()).mkdir('b')
tree_b = self.make_branch_and_tree('b')
return tree_a, tree_b
@@ -182,16 +180,25 @@
"""Copy only part of the history of a branch."""
# TODO: RBC 20060208 test with a revision not on revision-history.
# what should that behaviour be ? Emailed the list.
+ # First, make a branch with two commits.
wt_a = self.make_branch_and_tree('a')
- self.build_tree(['a/one'])
+ transport = wt_a.bzrdir.root_transport
+ self.build_tree(['one'], transport=transport)
wt_a.add(['one'])
wt_a.commit('commit one', rev_id='1')
- self.build_tree(['a/two'])
+ self.build_tree(['two'], transport=transport)
wt_a.add(['two'])
wt_a.commit('commit two', rev_id='2')
+ # Now make a copy of the repository.
repo_b = self.make_repository('b')
- wt_a.bzrdir.open_repository().copy_content_into(repo_b)
- br_b = wt_a.bzrdir.open_branch().clone(repo_b.bzrdir, revision_id='1')
+ wt_a.branch.repository.copy_content_into(repo_b)
+ # wt_a might be a lightweight checkout, so get a hold of the actual
+ # branch (because you can't do a partial clone of a lightweight
+ # checkout).
+ branch = wt_a.branch.bzrdir.open_branch()
+ # Then make a branch where the new repository is, but specify a revision
+ # ID. The new branch's history will stop at the specified revision.
+ br_b = branch.clone(repo_b.bzrdir, revision_id='1')
self.assertEqual('1', br_b.last_revision())
def test_sprout_partial(self):
@@ -211,7 +218,7 @@
def get_parented_branch(self):
wt_a = self.make_branch_and_tree('a')
- self.build_tree(['a/one'])
+ self.build_tree(['one'], transport=wt_a.bzrdir.root_transport)
wt_a.add(['one'])
wt_a.commit('commit one', rev_id='1')
@@ -240,19 +247,6 @@
branch_d = branch_b.clone(repo_d.bzrdir)
self.assertEqual(random_parent, branch_d.get_parent())
- def test_copy_content_incomplete(self):
- tree = self.make_branch_and_tree('commit_tree')
- self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
- 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)
-
-
def test_sprout_branch_nickname(self):
# test the nick name is reset always
raise TestSkipped('XXX branch sprouting is not yet tested..')
@@ -333,13 +327,13 @@
def test_branch_keeps_signatures(self):
wt = self.make_branch_and_tree('source')
wt.commit('A', allow_pointless=True, rev_id='A')
- wt.branch.repository.sign_revision('A',
- gpg.LoopbackGPGStrategy(None))
+ repo = wt.branch.repository
+ repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
#FIXME: clone should work to urls,
# wt.clone should work to disks.
self.build_tree(['target/'])
- d2 = wt.bzrdir.clone('target')
- self.assertEqual(wt.branch.repository.get_signature_text('A'),
+ d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target'))
+ self.assertEqual(repo.get_signature_text('A'),
d2.open_repository().get_signature_text('A'))
def test_nicks(self):
@@ -467,7 +461,7 @@
tree_a = self.make_branch_and_tree('a')
rev_id = tree_a.commit('put some content in the branch')
source_branch = bzrlib.branch.Branch.open(
- 'readonly+' + tree_a.bzrdir.root_transport.base)
+ 'readonly+' + tree_a.branch.bzrdir.root_transport.base)
# sanity check that the test will be valid
self.assertRaises((errors.LockError, errors.TransportNotPossible),
source_branch.lock_write)
=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py 2007-03-01 05:08:32 +0000
+++ b/bzrlib/transport/remote.py 2007-03-06 13:36:49 +0000
@@ -33,7 +33,8 @@
from bzrlib.smart import client, medium, protocol
# must do this otherwise urllib can't parse the urls properly :(
-for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh', 'bzr+http']:
+for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh', 'bzr+http',
+ 'readonly+bzr']:
transport.register_urlparse_netloc_protocol(scheme)
del scheme
More information about the bazaar-commits
mailing list