Rev 7: Add new command plugin-info. in http://people.ubuntu.com/~robertc/baz2.0/plugins/plugin_info/trunk
Robert Collins
robertc at robertcollins.net
Fri Feb 29 19:00:42 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/plugin_info/trunk
------------------------------------------------------------
revno: 7
revision-id:robertc at robertcollins.net-20080229190041-8v9umdqr7iu85jfd
parent: robertc at robertcollins.net-20080229175431-26xlcybidbny0a4z
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Sat 2008-03-01 06:00:41 +1100
message:
Add new command plugin-info.
added:
commands.py commands.py-20080229185857-m3j6ficrf7se6ms4-1
tests/test_blackbox.py test_blackbox.py-20080229185857-m3j6ficrf7se6ms4-2
modified:
NEWS news-20080229113630-0dhvipp22wlcjolw-2
README readme-20080229113630-0dhvipp22wlcjolw-3
__init__.py __init__.py-20080229113630-0dhvipp22wlcjolw-4
setup.py setup.py-20080229113630-0dhvipp22wlcjolw-5
tests/__init__.py __init__.py-20080229113630-0dhvipp22wlcjolw-7
=== modified file 'NEWS'
--- a/NEWS 2008-02-29 16:07:13 +0000
+++ b/NEWS 2008-02-29 19:00:41 +0000
@@ -13,6 +13,9 @@
FEATURES:
+ * New command ``bzr plugin_info`` which will dump plugin details for any
+ number of URL's. (Robert Collins)
+
IMPROVEMENTS:
BUGFIXES:
=== modified file 'README'
--- a/README 2008-02-29 11:37:16 +0000
+++ b/README 2008-02-29 19:00:41 +0000
@@ -28,10 +28,12 @@
Commands
========
-No commands are currently provided.
+`bzr plugin-info` will extract information about plugins from directories and
+branches.
Documentation
=============
See pydoc bzrlib.plugins.plugin_info for programmer documentation.
+See `bzr help plugin-info` for help on the plugin-info command.
=== modified file '__init__.py'
--- a/__init__.py 2008-02-29 12:10:09 +0000
+++ b/__init__.py 2008-02-29 19:00:41 +0000
@@ -17,12 +17,24 @@
"""plugin-info is a bzr plugin for working with the bzr plugins.
-Currently no new commands are added, but various library facilities in
-bzrlib.plugins.plugin_info.
+The command ``plugin-info`` provides information about plugins when given one
+or more local paths or URL's to plugin branches.
:seealso: bzrlib.plugins.plugin_info.extract
"""
+import bzrlib.commands
+
+# Relative because at __init__ time the module does not exist.
+import commands
+
+
+for command in [
+ 'plugin_info',
+ ]:
+ bzrlib.commands.register_command(getattr(commands, 'cmd_' + command))
+
+
version_info = (1, 3, 0, 'dev', 0)
=== added file 'commands.py'
--- a/commands.py 1970-01-01 00:00:00 +0000
+++ b/commands.py 2008-02-29 19:00:41 +0000
@@ -0,0 +1,46 @@
+# plugin_info, a plugin for working with information about plugins.
+# Copyright (C) 2006 Canonical Limited.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+#
+# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+"""plugin-info commands."""
+
+from bzrlib.branch import Branch
+from bzrlib import errors
+import bzrlib.commands
+from bzrlib.plugins.plugin_info.extract import *
+
+
+class cmd_plugin_info(bzrlib.commands.Command):
+ """Report the metadata for a plugin.
+
+ This reads the metadata for a plugin from a branch or directory containing
+ the plugin and reports it to stdout.
+ """
+
+ takes_args = ['location+']
+
+ def run(self, location_list=[]):
+ for url in location_list:
+ try:
+ self.outf.write(str(extract_info_local(url)))
+ except IOError:
+ try:
+ branch = Branch.open(url)
+ except errors.NotBranchError:
+ raise
+ else:
+ self.outf.write(str(extract_info_branch(branch)))
+ self.outf.write('\n')
=== modified file 'setup.py'
--- a/setup.py 2008-02-29 11:37:16 +0000
+++ b/setup.py 2008-02-29 19:00:41 +0000
@@ -4,6 +4,7 @@
bzr_plugin_name = 'plugin_info'
bzr_plugin_version = (1, 3, 0, 'dev', 0)
+bzr_commands = ['plugin-info']
if __name__ == 'main':
setup(name="bzr plugin info",
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2008-02-29 12:10:09 +0000
+++ b/tests/__init__.py 2008-02-29 19:00:41 +0000
@@ -21,6 +21,7 @@
def load_tests(standard_tests, module, loader):
test_modules = [
+ 'blackbox',
'extract',
]
standard_tests.addTests(loader.loadTestsFromModuleNames(
=== added file 'tests/test_blackbox.py'
--- a/tests/test_blackbox.py 1970-01-01 00:00:00 +0000
+++ b/tests/test_blackbox.py 2008-02-29 19:00:41 +0000
@@ -0,0 +1,50 @@
+# plugin_info, a plugin for working with information about plugins.
+# Copyright (C) 2008 Canonical Limited.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+#
+# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+"""Tests for the commands supplied by plugin-info."""
+
+from bzrlib.tests import TestCaseWithTransport
+
+
+class TestPluginInfo(TestCaseWithTransport):
+
+ def sample_setup(self):
+ return """
+bzr_plugin_name = "foo_bar"
+bzr_commands = ["a-command"]
+bzr_plugin_version = (1, 2, 3, 'dev', 0)
+bzr_minimum_version = (1, 2, 0)
+bzr_maximum_version = (1, 3, 0)
+bzr_control_formats = {"bzr-meta":{".bzr/branch-format":"Bazaar-NG meta directory, format 1\\n"}}
+bzr_checkout_formats = {"Bazaar Working Tree Format 4 (bzr 0.15)\\n":"dirstate"}
+bzr_branch_formats = {"Bazaar Branch Format 6 (bzr 0.15)\\n":"branch 6"}
+bzr_repository_formats = {"Bazaar pack repository format 1 (needs bzr 0.92)\\n":"packs"}
+"""
+
+ def test_extract_info_branch(self):
+ tree = self.make_branch_and_tree('plugin')
+ self.build_tree_contents([('plugin/setup.py', self.sample_setup())])
+ tree.add(['setup.py'])
+ tree.commit('yay history')
+ self.build_tree(['plugin2/'])
+ self.build_tree_contents([('plugin2/setup.py', self.sample_setup())])
+ out, err = self.run_bzr(['plugin-info', 'plugin', 'plugin2'])
+ self.assertEqual(
+"""foo_bar(1.2.3dev0) from plugin supplies commands("a-command"), control formats("bzr-meta"), checkout formats("dirstate"), branch formats("branch 6"), repository formats("packs").
+foo_bar(1.2.3dev0) from plugin2 supplies commands("a-command"), control formats("bzr-meta"), checkout formats("dirstate"), branch formats("branch 6"), repository formats("packs").
+""", out)
+ self.assertEqual('', err)
More information about the bazaar-commits
mailing list