Rev 5286: (vila) Catch the wrong path descriptions in BZR_PLUGINS_AT in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jun 11 08:55:56 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5286 [merge]
revision-id: pqm at pqm.ubuntu.com-20100611075555-qtmp0wp9atss3vkc
parent: pqm at pqm.ubuntu.com-20100610171327-tmvcodt4s6m9snsr
parent: v.ladeuil+lp at free.fr-20100611063924-zi7m1449blz5slv4
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-06-11 08:55:55 +0100
message:
(vila) Catch the wrong path descriptions in BZR_PLUGINS_AT
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/plugin.py plugin.py-20050622060424-829b654519533d69
bzrlib/tests/test_plugins.py plugins.py-20050622075746-32002b55e5e943e9
=== modified file 'NEWS'
--- a/NEWS 2010-06-10 15:56:06 +0000
+++ b/NEWS 2010-06-11 06:39:24 +0000
@@ -32,6 +32,10 @@
linear ancetries.
(Vincent Ladeuil, #575631)
+* Ensure that wrong path specifications in ``BZR_PLUGINS_AT`` display
+ proper error messages.
+ (Vincent Ladeuil, #591215)
+
* Final fix for 'no help for command' issue. We now show a clean message
when a command has no help, document how to set help more clearly, and
test that all commands available to the test suite have help.
=== modified file 'bzrlib/plugin.py'
--- a/bzrlib/plugin.py 2010-04-06 07:22:31 +0000
+++ b/bzrlib/plugin.py 2010-06-09 18:08:25 +0000
@@ -81,6 +81,33 @@
return path.rstrip("\\/")
+def _get_specific_plugin_paths(paths):
+ """Returns the plugin paths from a string describing the associations.
+
+ :param paths: A string describing the paths associated with the plugins.
+
+ :returns: A list of (plugin name, path) tuples.
+
+ For example, if paths is my_plugin@/test/my-test:her_plugin@/production/her,
+ [('my_plugin', '/test/my-test'), ('her_plugin', '/production/her')]
+ will be returned.
+
+ Note that ':' in the example above depends on the os.
+ """
+ if not paths:
+ return []
+ specs = []
+ for spec in paths.split(os.pathsep):
+ try:
+ name, path = spec.split('@')
+ except ValueError:
+ raise errors.BzrCommandError(
+ '"%s" is not a valid <plugin_name>@<plugin_path> description '
+ % spec)
+ specs.append((name, path))
+ return specs
+
+
def set_plugins_path(path=None):
"""Set the path for plugins to be loaded from.
@@ -98,10 +125,8 @@
for name in disabled_plugins.split(os.pathsep):
PluginImporter.blacklist.add('bzrlib.plugins.' + name)
# Set up a the specific paths for plugins
- specific_plugins = os.environ.get('BZR_PLUGINS_AT', None)
- if specific_plugins is not None:
- for spec in specific_plugins.split(os.pathsep):
- plugin_name, plugin_path = spec.split('@')
+ for plugin_name, plugin_path in _get_specific_plugin_paths(os.environ.get(
+ 'BZR_PLUGINS_AT', None)):
PluginImporter.specific_paths[
'bzrlib.plugins.%s' % plugin_name] = plugin_path
return path
=== modified file 'bzrlib/tests/test_plugins.py'
--- a/bzrlib/tests/test_plugins.py 2010-05-16 13:49:19 +0000
+++ b/bzrlib/tests/test_plugins.py 2010-06-09 18:08:25 +0000
@@ -27,6 +27,7 @@
import bzrlib
from bzrlib import (
+ errors,
osutils,
plugin,
plugins,
@@ -798,6 +799,29 @@
self.assertLength(0, self.warnings)
+class TestLoadPluginAtSyntax(tests.TestCase):
+
+ def _get_paths(self, paths):
+ return plugin._get_specific_plugin_paths(paths)
+
+ def test_empty(self):
+ self.assertEquals([], self._get_paths(None))
+ self.assertEquals([], self._get_paths(''))
+
+ def test_one_path(self):
+ self.assertEquals([('b', 'man')], self._get_paths('b at man'))
+
+ def test_bogus_path(self):
+ # We need a '@'
+ self.assertRaises(errors.BzrCommandError, self._get_paths, 'batman')
+ # Too much '@' isn't good either
+ self.assertRaises(errors.BzrCommandError, self._get_paths,
+ 'batman at mobile@cave')
+ # An empty description probably indicates a problem
+ self.assertRaises(errors.BzrCommandError, self._get_paths,
+ os.pathsep.join(['batman at cave', '', 'robin at mobile']))
+
+
class TestLoadPluginAt(tests.TestCaseInTempDir, TestPluginMixin):
def setUp(self):
More information about the bazaar-commits
mailing list