Rev 4401: (andrew) Fix tracebacks when receiving error responses to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jun 3 09:04:39 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4401
revision-id: pqm at pqm.ubuntu.com-20090603080435-2gbqwzvbx31zr7ok
parent: pqm at pqm.ubuntu.com-20090603063817-8ykgnm5181gp6xea
parent: andrew.bennetts at canonical.com-20090603064345-p44bv6u05mkmnox6
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-06-03 09:04:35 +0100
message:
(andrew) Fix tracebacks when receiving error responses to
BzrDirFormat.initialize* RPCs.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 4384.1.5
revision-id: andrew.bennetts at canonical.com-20090603064345-p44bv6u05mkmnox6
parent: andrew.bennetts at canonical.com-20090603044202-bq5pwfme4fve3xbt
parent: pqm at pqm.ubuntu.com-20090603063817-8ykgnm5181gp6xea
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-perm-denied-during-push-create
timestamp: Wed 2009-06-03 16:43:45 +1000
message:
Merge, resolving NEWS conflict.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
------------------------------------------------------------
revno: 4384.1.4
revision-id: andrew.bennetts at canonical.com-20090603044202-bq5pwfme4fve3xbt
parent: andrew.bennetts at canonical.com-20090603044053-bf40971159tse6z1
parent: pqm at pqm.ubuntu.com-20090603004918-k6xr5guhlh4f2dd7
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-perm-denied-during-push-create
timestamp: Wed 2009-06-03 14:42:02 +1000
message:
Merge, resolving NEWS conflict.
added:
bzrlib/send.py send.py-20090521192735-j7cdb33ykmtmzx4w-1
bzrlib/tests/per_repository_reference/test_fetch.py test_fetch.py-20090511214909-25pkgmoam913lrji-1
bzrlib/tests/per_repository_reference/test_initialize.py test_initialize.py-20090527083941-4rz2urcthjet5e2i-1
bzrlib/tests/per_repository_reference/test_unlock.py test_unlock.py-20090526160031-14lvypj5pbrndnyz-1
renamed:
bzrlib/tests/workingtree_implementations/test_get_file_with_stat.py => bzrlib/tests/tree_implementations/test_get_file_with_stat.py test_get_file_with_s-20080922035909-lhdovrr36jpxmu0v-1
modified:
Makefile Makefile-20050805140406-d96e3498bb61c5bb
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/foreign.py foreign.py-20081112170002-olsxmandkk8qyfuq-1
bzrlib/groupcompress.py groupcompress.py-20080705181503-ccbxd6xuy1bdnrpu-8
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/plugins/launchpad/test_register.py test_register.py-20060315182712-40f5dda945c829a8
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/groupcompress_repo.py repofmt.py-20080715094215-wp1qfvoo7093c8qr-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/inventory_implementations/basics.py basics.py-20070903044446-kdjwbiu1p1zi9phs-1
bzrlib/tests/per_repository/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
bzrlib/tests/per_repository/test_fileid_involved.py test_file_involved.py-20051215205901-728a172d1014daaa
bzrlib/tests/per_repository/test_write_group.py test_write_group.py-20070716105516-89n34xtogq5frn0m-1
bzrlib/tests/per_repository_reference/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
bzrlib/tests/per_repository_reference/test_default_stacking.py test_default_stackin-20090311055345-9ajahgm58oq3wh6h-1
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
bzrlib/tests/test_foreign.py test_foreign.py-20081125004048-ywb901edgp9lluxo-1
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
bzrlib/tests/test_groupcompress.py test_groupcompress.p-20080705181503-ccbxd6xuy1bdnrpu-13
bzrlib/tests/test_http.py testhttp.py-20051018020158-b2eef6e867c514d9
bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/tests/tree_implementations/test_get_file_with_stat.py test_get_file_with_s-20080922035909-lhdovrr36jpxmu0v-1
------------------------------------------------------------
revno: 4384.1.3
revision-id: andrew.bennetts at canonical.com-20090603044053-bf40971159tse6z1
parent: andrew.bennetts at canonical.com-20090602060506-jklea3chvqka6tyr
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-perm-denied-during-push-create
timestamp: Wed 2009-06-03 14:40:53 +1000
message:
Add test suggested by John.
modified:
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 4384.1.2
revision-id: andrew.bennetts at canonical.com-20090602060506-jklea3chvqka6tyr
parent: andrew.bennetts at canonical.com-20090602060155-ib17vor7jn1555qh
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-perm-denied-during-push-create
timestamp: Tue 2009-06-02 16:05:06 +1000
message:
Add NEWS entry.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 4384.1.1
revision-id: andrew.bennetts at canonical.com-20090602060155-ib17vor7jn1555qh
parent: pqm at pqm.ubuntu.com-20090527193433-rw9zh1l73zjc9knb
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-perm-denied-during-push-create
timestamp: Tue 2009-06-02 16:01:55 +1000
message:
Translate ErrorFromSmartServer in RemoteBzrDirFormat.
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'NEWS'
--- a/NEWS 2009-06-03 05:44:18 +0000
+++ b/NEWS 2009-06-03 06:43:45 +0000
@@ -62,6 +62,10 @@
succeeded from the user's perspective, no output is written to stderr
or stdout. (Maritza Mendez, #363837)
+* Translate errors received from a smart server in response to a
+ ``BzrDirFormat.initialize`` or ``BzrDirFormat.initialize_ex`` request.
+ This was causing tracebacks even for mundane errors like
+ ``PermissionDenied``. (Andrew Bennetts, #381329)
Documentation
*************
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2009-05-28 11:46:14 +0000
+++ b/bzrlib/bzrdir.py 2009-06-03 04:42:02 +0000
@@ -3049,7 +3049,10 @@
return local_dir_format.initialize_on_transport(transport)
client = _SmartClient(client_medium)
path = client.remote_path_from_transport(transport)
- response = client.call('BzrDirFormat.initialize', path)
+ try:
+ response = client.call('BzrDirFormat.initialize', path)
+ except errors.ErrorFromSmartServer, err:
+ remote._translate_error(err, path=path)
if response[0] != 'ok':
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
format = RemoteBzrDirFormat()
@@ -3115,6 +3118,13 @@
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
make_working_trees=make_working_trees, shared_repo=shared_repo,
vfs_only=True)
+ return self._initialize_on_transport_ex_rpc(client, path, transport,
+ use_existing_dir, create_prefix, force_new_repo, stacked_on,
+ stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
+
+ def _initialize_on_transport_ex_rpc(self, client, path, transport,
+ use_existing_dir, create_prefix, force_new_repo, stacked_on,
+ stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
args = []
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
args.append(self._serialize_NoneTrueFalse(create_prefix))
@@ -3147,6 +3157,8 @@
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
make_working_trees=make_working_trees, shared_repo=shared_repo,
vfs_only=True)
+ except errors.ErrorFromSmartServer, err:
+ remote._translate_error(err, path=path)
repo_path = response[0]
bzrdir_name = response[6]
require_stacking = response[7]
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2009-05-07 05:08:46 +0000
+++ b/bzrlib/tests/test_remote.py 2009-06-03 04:40:53 +0000
@@ -741,6 +741,61 @@
self.assertEqual(network_name, repo._format.network_name())
+class TestBzrDirFormatInitializeEx(TestRemote):
+
+ def test_success(self):
+ """Simple test for typical successful call."""
+ fmt = bzrdir.RemoteBzrDirFormat()
+ default_format_name = BzrDirFormat.get_default_format().network_name()
+ transport = self.get_transport()
+ client = FakeClient(transport.base)
+ client.add_expected_call(
+ 'BzrDirFormat.initialize_ex',
+ (default_format_name, 'path', 'False', 'False', 'False', '',
+ '', '', '', 'False'),
+ 'success',
+ ('.', 'no', 'no', 'yes', 'repo fmt', 'repo bzrdir fmt',
+ 'bzrdir fmt', 'False', '', '', 'repo lock token'))
+ # XXX: It would be better to call fmt.initialize_on_transport_ex, but
+ # it's currently hard to test that without supplying a real remote
+ # transport connected to a real server.
+ result = fmt._initialize_on_transport_ex_rpc(client, 'path',
+ transport, False, False, False, None, None, None, None, False)
+ client.finished_test()
+
+ def test_error(self):
+ """Error responses are translated, e.g. 'PermissionDenied' raises the
+ corresponding error from the client.
+ """
+ fmt = bzrdir.RemoteBzrDirFormat()
+ default_format_name = BzrDirFormat.get_default_format().network_name()
+ transport = self.get_transport()
+ client = FakeClient(transport.base)
+ client.add_expected_call(
+ 'BzrDirFormat.initialize_ex',
+ (default_format_name, 'path', 'False', 'False', 'False', '',
+ '', '', '', 'False'),
+ 'error',
+ ('PermissionDenied', 'path', 'extra info'))
+ # XXX: It would be better to call fmt.initialize_on_transport_ex, but
+ # it's currently hard to test that without supplying a real remote
+ # transport connected to a real server.
+ err = self.assertRaises(errors.PermissionDenied,
+ fmt._initialize_on_transport_ex_rpc, client, 'path', transport,
+ False, False, False, None, None, None, None, False)
+ self.assertEqual('path', err.path)
+ self.assertEqual(': extra info', err.extra)
+ client.finished_test()
+
+ def test_error_from_real_server(self):
+ """Integration test for error translation."""
+ transport = self.make_smart_server('foo')
+ transport = transport.clone('no-such-path')
+ fmt = bzrdir.RemoteBzrDirFormat()
+ err = self.assertRaises(errors.NoSuchFile,
+ fmt.initialize_on_transport_ex, transport, create_prefix=False)
+
+
class OldSmartClient(object):
"""A fake smart client for test_old_version that just returns a version one
response to the 'hello' (query version) command.
More information about the bazaar-commits
mailing list