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
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2012-09-05 20:52:26 +0000
3+++ bzrlib/builtins.py 2012-09-14 16:45:40 +0000
4@@ -6727,6 +6727,7 @@
5 ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6 ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
7 ('cmd_conflicts', [], 'bzrlib.conflicts'),
8+ ('cmd_ping', [], 'bzrlib.smart.ping'),
9 ('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
10 ('cmd_verify_signatures', [], 'bzrlib.commit_signature_commands'),
11 ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
12
13=== added file 'bzrlib/smart/ping.py'
14--- bzrlib/smart/ping.py 1970-01-01 00:00:00 +0000
15+++ bzrlib/smart/ping.py 2012-09-14 16:45:40 +0000
16@@ -0,0 +1,53 @@
17+# Copyright (C) 2008-2012 Canonical Ltd
18+#
19+# This program is free software; you can redistribute it and/or modify
20+# it under the terms of the GNU General Public License as published by
21+# the Free Software Foundation; either version 2 of the License, or
22+# (at your option) any later version.
23+#
24+# This program is distributed in the hope that it will be useful,
25+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+# GNU General Public License for more details.
28+#
29+# You should have received a copy of the GNU General Public License
30+# along with this program; if not, write to the Free Software
31+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32+
33+"""Ping plugin for bzr."""
34+
35+from __future__ import absolute_import
36+
37+from bzrlib.commands import Command
38+from bzrlib.lazy_import import lazy_import
39+
40+lazy_import(globals(), """
41+from bzrlib import errors
42+from bzrlib.smart.client import _SmartClient
43+from bzrlib.transport import get_transport
44+""")
45+
46+
47+class cmd_ping(Command):
48+ """Pings a Bazaar smart server.
49+
50+ This command sends a 'hello' request to the given location using the bzr
51+ smart protocol, and reports the response.
52+ """
53+
54+ takes_args = ['location']
55+
56+ def run(self, location):
57+ transport = get_transport(location)
58+ try:
59+ medium = transport.get_smart_medium()
60+ except errors.NoSmartMedium, e:
61+ raise errors.BzrCommandError(str(e))
62+ client = _SmartClient(medium)
63+ # Use call_expecting_body (even though we don't expect a body) so that
64+ # we can see the response headers (if any) via the handler object.
65+ response, handler = client.call_expecting_body('hello')
66+ handler.cancel_read_body()
67+ self.outf.write('Response: %r\n' % (response,))
68+ if getattr(handler, 'headers', None) is not None:
69+ self.outf.write('Headers: %r\n' % (handler.headers,))
70
71=== modified file 'bzrlib/tests/blackbox/__init__.py'
72--- bzrlib/tests/blackbox/__init__.py 2011-12-29 21:03:53 +0000
73+++ bzrlib/tests/blackbox/__init__.py 2012-09-14 16:45:40 +0000
74@@ -92,6 +92,7 @@
75 'test_non_ascii',
76 'test_outside_wt',
77 'test_pack',
78+ 'test_ping',
79 'test_pull',
80 'test_push',
81 'test_reconcile',
82
83=== added file 'bzrlib/tests/blackbox/test_ping.py'
84--- bzrlib/tests/blackbox/test_ping.py 1970-01-01 00:00:00 +0000
85+++ bzrlib/tests/blackbox/test_ping.py 2012-09-14 16:45:40 +0000
86@@ -0,0 +1,37 @@
87+# Copyright (C) 2012 Canonical Ltd
88+#
89+# This program is free software; you can redistribute it and/or modify
90+# it under the terms of the GNU General Public License as published by
91+# the Free Software Foundation; either version 2 of the License, or
92+# (at your option) any later version.
93+#
94+# This program is distributed in the hope that it will be useful,
95+# but WITHOUT ANY WARRANTY; without even the implied warranty of
96+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+# GNU General Public License for more details.
98+#
99+# You should have received a copy of the GNU General Public License
100+# along with this program; if not, write to the Free Software
101+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
102+
103+"""External tests of 'bzr ping'"""
104+
105+from bzrlib import tests
106+
107+
108+class TestSmartServerPing(tests.TestCaseWithTransport):
109+
110+ def test_simple_ping(self):
111+ self.setup_smart_server_with_call_log()
112+ t = self.make_branch_and_tree('branch')
113+ self.build_tree_contents([('branch/foo', 'thecontents')])
114+ t.add("foo")
115+ t.commit("message")
116+ self.reset_smart_call_log()
117+ out, err = self.run_bzr(['ping', self.get_url('branch')])
118+ self.assertLength(1, self.hpss_calls)
119+ self.assertLength(1, self.hpss_connections)
120+ self.assertEquals(out,
121+ "Response: ('ok', '2')\n"
122+ "Headers: {'Software version': '2.6.0dev3'}\n")
123+ self.assertEquals(err, "")
124
125=== modified file 'doc/en/release-notes/bzr-2.6.txt'
126--- doc/en/release-notes/bzr-2.6.txt 2012-09-05 16:53:58 +0000
127+++ doc/en/release-notes/bzr-2.6.txt 2012-09-14 16:45:40 +0000
128@@ -25,6 +25,8 @@
129 context (i.e. showing lines that have not changed). Also available as the
130 named parameter 'context_lines' to bzrlib.diff.internal_diff(). (Paul Nixon)
131
132+* The 'ping' plugin is now shipped with bzr. (Jelmer Vernooij)
133+
134 Improvements
135 ************
136