Merge lp:~jelmer/bzr/merge-ping into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 6559
Proposed branch: lp:~jelmer/bzr/merge-ping
Merge into: lp:bzr
Diff against target: 135 lines (+94/-0)
5 files modified
bzrlib/builtins.py (+1/-0)
bzrlib/smart/ping.py (+53/-0)
bzrlib/tests/blackbox/__init__.py (+1/-0)
bzrlib/tests/blackbox/test_ping.py (+37/-0)
doc/en/release-notes/bzr-2.6.txt (+2/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/merge-ping
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Review via email: mp+123415@code.launchpad.net

Commit message

Merge the ping plugin.

Description of the change

Merge the ping plugin into bzr core.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks reasonable, do we want to add any documentation for this somewhere?

+ except errors.NoSmartMedium, e:
+ raise errors.BzrCommandError(str(e))

This is slightly odd, should NoSmartMedium just be a non-internal error? Or this might be a special case because a smart transport url is required?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2012-09-05 20:52:26 +0000
+++ bzrlib/builtins.py 2012-09-14 16:45:40 +0000
@@ -6727,6 +6727,7 @@
6727 ('cmd_version_info', [], 'bzrlib.cmd_version_info'),6727 ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6728 ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),6728 ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6729 ('cmd_conflicts', [], 'bzrlib.conflicts'),6729 ('cmd_conflicts', [], 'bzrlib.conflicts'),
6730 ('cmd_ping', [], 'bzrlib.smart.ping'),
6730 ('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),6731 ('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
6731 ('cmd_verify_signatures', [], 'bzrlib.commit_signature_commands'),6732 ('cmd_verify_signatures', [], 'bzrlib.commit_signature_commands'),
6732 ('cmd_test_script', [], 'bzrlib.cmd_test_script'),6733 ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
67336734
=== added file 'bzrlib/smart/ping.py'
--- bzrlib/smart/ping.py 1970-01-01 00:00:00 +0000
+++ bzrlib/smart/ping.py 2012-09-14 16:45:40 +0000
@@ -0,0 +1,53 @@
1# Copyright (C) 2008-2012 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""Ping plugin for bzr."""
18
19from __future__ import absolute_import
20
21from bzrlib.commands import Command
22from bzrlib.lazy_import import lazy_import
23
24lazy_import(globals(), """
25from bzrlib import errors
26from bzrlib.smart.client import _SmartClient
27from bzrlib.transport import get_transport
28""")
29
30
31class cmd_ping(Command):
32 """Pings a Bazaar smart server.
33
34 This command sends a 'hello' request to the given location using the bzr
35 smart protocol, and reports the response.
36 """
37
38 takes_args = ['location']
39
40 def run(self, location):
41 transport = get_transport(location)
42 try:
43 medium = transport.get_smart_medium()
44 except errors.NoSmartMedium, e:
45 raise errors.BzrCommandError(str(e))
46 client = _SmartClient(medium)
47 # Use call_expecting_body (even though we don't expect a body) so that
48 # we can see the response headers (if any) via the handler object.
49 response, handler = client.call_expecting_body('hello')
50 handler.cancel_read_body()
51 self.outf.write('Response: %r\n' % (response,))
52 if getattr(handler, 'headers', None) is not None:
53 self.outf.write('Headers: %r\n' % (handler.headers,))
054
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- bzrlib/tests/blackbox/__init__.py 2011-12-29 21:03:53 +0000
+++ bzrlib/tests/blackbox/__init__.py 2012-09-14 16:45:40 +0000
@@ -92,6 +92,7 @@
92 'test_non_ascii',92 'test_non_ascii',
93 'test_outside_wt',93 'test_outside_wt',
94 'test_pack',94 'test_pack',
95 'test_ping',
95 'test_pull',96 'test_pull',
96 'test_push',97 'test_push',
97 'test_reconcile',98 'test_reconcile',
9899
=== added file 'bzrlib/tests/blackbox/test_ping.py'
--- bzrlib/tests/blackbox/test_ping.py 1970-01-01 00:00:00 +0000
+++ bzrlib/tests/blackbox/test_ping.py 2012-09-14 16:45:40 +0000
@@ -0,0 +1,37 @@
1# Copyright (C) 2012 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""External tests of 'bzr ping'"""
18
19from bzrlib import tests
20
21
22class TestSmartServerPing(tests.TestCaseWithTransport):
23
24 def test_simple_ping(self):
25 self.setup_smart_server_with_call_log()
26 t = self.make_branch_and_tree('branch')
27 self.build_tree_contents([('branch/foo', 'thecontents')])
28 t.add("foo")
29 t.commit("message")
30 self.reset_smart_call_log()
31 out, err = self.run_bzr(['ping', self.get_url('branch')])
32 self.assertLength(1, self.hpss_calls)
33 self.assertLength(1, self.hpss_connections)
34 self.assertEquals(out,
35 "Response: ('ok', '2')\n"
36 "Headers: {'Software version': '2.6.0dev3'}\n")
37 self.assertEquals(err, "")
038
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- doc/en/release-notes/bzr-2.6.txt 2012-09-05 16:53:58 +0000
+++ doc/en/release-notes/bzr-2.6.txt 2012-09-14 16:45:40 +0000
@@ -25,6 +25,8 @@
25 context (i.e. showing lines that have not changed). Also available as the 25 context (i.e. showing lines that have not changed). Also available as the
26 named parameter 'context_lines' to bzrlib.diff.internal_diff(). (Paul Nixon)26 named parameter 'context_lines' to bzrlib.diff.internal_diff(). (Paul Nixon)
2727
28* The 'ping' plugin is now shipped with bzr. (Jelmer Vernooij)
29
28Improvements30Improvements
29************31************
3032