Rev 6559: (jelmer) Merge the ping plugin. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Sep 14 17:22:35 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6559 [merge]
revision-id: pqm at pqm.ubuntu.com-20120914172235-tvv720qmlchw8270
parent: pqm at pqm.ubuntu.com-20120905205226-8s3bzolvduug3ifj
parent: jelmer at samba.org-20120914164312-fgjk4tf8hotw8eh9
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2012-09-14 17:22:35 +0000
message:
(jelmer) Merge the ping plugin. (Jelmer Vernooij)
added:
bzrlib/smart/ping.py __init__.py-20080708000159-umiec8fghx2umgyn-1
bzrlib/tests/blackbox/test_ping.py test_ping.py-20120908132607-5uyvtj9w5pu96g34-1
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
doc/en/release-notes/bzr-2.6.txt bzr2.6.txt-20120116134316-8w1xxom1c7vcu1t5-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2012-09-05 20:52:26 +0000
+++ b/bzrlib/builtins.py 2012-09-14 17:22:35 +0000
@@ -6727,6 +6727,7 @@
('cmd_version_info', [], 'bzrlib.cmd_version_info'),
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
('cmd_conflicts', [], 'bzrlib.conflicts'),
+ ('cmd_ping', [], 'bzrlib.smart.ping'),
('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
('cmd_verify_signatures', [], 'bzrlib.commit_signature_commands'),
('cmd_test_script', [], 'bzrlib.cmd_test_script'),
=== added file 'bzrlib/smart/ping.py'
--- a/bzrlib/smart/ping.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/smart/ping.py 2012-09-14 16:43:12 +0000
@@ -0,0 +1,53 @@
+# Copyright (C) 2008-2012 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Ping plugin for bzr."""
+
+from __future__ import absolute_import
+
+from bzrlib.commands import Command
+from bzrlib.lazy_import import lazy_import
+
+lazy_import(globals(), """
+from bzrlib import errors
+from bzrlib.smart.client import _SmartClient
+from bzrlib.transport import get_transport
+""")
+
+
+class cmd_ping(Command):
+ """Pings a Bazaar smart server.
+
+ This command sends a 'hello' request to the given location using the bzr
+ smart protocol, and reports the response.
+ """
+
+ takes_args = ['location']
+
+ def run(self, location):
+ transport = get_transport(location)
+ try:
+ medium = transport.get_smart_medium()
+ except errors.NoSmartMedium, e:
+ raise errors.BzrCommandError(str(e))
+ client = _SmartClient(medium)
+ # Use call_expecting_body (even though we don't expect a body) so that
+ # we can see the response headers (if any) via the handler object.
+ response, handler = client.call_expecting_body('hello')
+ handler.cancel_read_body()
+ self.outf.write('Response: %r\n' % (response,))
+ if getattr(handler, 'headers', None) is not None:
+ self.outf.write('Headers: %r\n' % (handler.headers,))
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py 2011-12-29 21:03:53 +0000
+++ b/bzrlib/tests/blackbox/__init__.py 2012-09-08 13:26:18 +0000
@@ -92,6 +92,7 @@
'test_non_ascii',
'test_outside_wt',
'test_pack',
+ 'test_ping',
'test_pull',
'test_push',
'test_reconcile',
=== added file 'bzrlib/tests/blackbox/test_ping.py'
--- a/bzrlib/tests/blackbox/test_ping.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_ping.py 2012-09-08 13:26:18 +0000
@@ -0,0 +1,37 @@
+# Copyright (C) 2012 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""External tests of 'bzr ping'"""
+
+from bzrlib import tests
+
+
+class TestSmartServerPing(tests.TestCaseWithTransport):
+
+ def test_simple_ping(self):
+ self.setup_smart_server_with_call_log()
+ t = self.make_branch_and_tree('branch')
+ self.build_tree_contents([('branch/foo', 'thecontents')])
+ t.add("foo")
+ t.commit("message")
+ self.reset_smart_call_log()
+ out, err = self.run_bzr(['ping', self.get_url('branch')])
+ self.assertLength(1, self.hpss_calls)
+ self.assertLength(1, self.hpss_connections)
+ self.assertEquals(out,
+ "Response: ('ok', '2')\n"
+ "Headers: {'Software version': '2.6.0dev3'}\n")
+ self.assertEquals(err, "")
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- a/doc/en/release-notes/bzr-2.6.txt 2012-09-05 16:53:58 +0000
+++ b/doc/en/release-notes/bzr-2.6.txt 2012-09-14 17:22:35 +0000
@@ -25,6 +25,8 @@
context (i.e. showing lines that have not changed). Also available as the
named parameter 'context_lines' to bzrlib.diff.internal_diff(). (Paul Nixon)
+* The 'ping' plugin is now shipped with bzr. (Jelmer Vernooij)
+
Improvements
************
More information about the bazaar-commits
mailing list