Rev 2984: (Daniel Watkins) Fix bug #103023 by giving a nice way of resolving in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Nov 13 20:49:42 GMT 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2984
revision-id: pqm at pqm.ubuntu.com-20071113204938-n5t7vld9jwo0hv4v
parent: pqm at pqm.ubuntu.com-20071113183931-av8ih92ad65slodl
parent: d.m.watkins at warwick.ac.uk-20071113014934-a0p3t1i9nfrsci40
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-11-13 20:49:38 +0000
message:
(Daniel Watkins) Fix bug #103023 by giving a nice way of resolving
when a plugin has a bad name
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/plugin.py plugin.py-20050622060424-829b654519533d69
bzrlib/tests/test_plugins.py plugins.py-20050622075746-32002b55e5e943e9
------------------------------------------------------------
revno: 2967.4.10
merged: d.m.watkins at warwick.ac.uk-20071113014934-a0p3t1i9nfrsci40
parent: d.m.watkins at warwick.ac.uk-20071113013258-9bkvnis7d08dfaea
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-13 01:49:34 +0000
message:
Fixed message.
------------------------------------------------------------
revno: 2967.4.9
merged: d.m.watkins at warwick.ac.uk-20071113013258-9bkvnis7d08dfaea
parent: d.m.watkins at warwick.ac.uk-20071113013032-a70dix21254icx27
parent: pqm at pqm.ubuntu.com-20071113005140-mp4owdlrd1ccnqc9
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-13 01:32:58 +0000
message:
Merged bzr.dev.
------------------------------------------------------------
revno: 2967.4.8
merged: d.m.watkins at warwick.ac.uk-20071113013032-a70dix21254icx27
parent: d.m.watkins at warwick.ac.uk-20071113012636-mfy26i3kp235kbf4
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-13 01:30:32 +0000
message:
Moved NEWS item to potentially better place.
------------------------------------------------------------
revno: 2967.4.7
merged: d.m.watkins at warwick.ac.uk-20071113012636-mfy26i3kp235kbf4
parent: d.m.watkins at warwick.ac.uk-20071113012344-jg905q2tnxreeib1
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-13 01:26:36 +0000
message:
Converted from nasty chained replaces to re.sub.
------------------------------------------------------------
revno: 2967.4.6
merged: d.m.watkins at warwick.ac.uk-20071113012344-jg905q2tnxreeib1
parent: d.m.watkins at warwick.ac.uk-20071113012255-q21vsslly7pwbhlm
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-13 01:23:44 +0000
message:
Cleaned up dodgy indentation.
------------------------------------------------------------
revno: 2967.4.5
merged: d.m.watkins at warwick.ac.uk-20071113012255-q21vsslly7pwbhlm
parent: d.m.watkins at warwick.ac.uk-20071109105732-hr26fbuzk4mikzvg
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-13 01:22:55 +0000
message:
Added test for badly-named plugins.
------------------------------------------------------------
revno: 2967.4.4
merged: d.m.watkins at warwick.ac.uk-20071109105732-hr26fbuzk4mikzvg
parent: d.m.watkins at warwick.ac.uk-20071106133827-ghog6ei3vzsh4wy9
parent: pqm at pqm.ubuntu.com-20071109031316-n814a39wmtxvybyw
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Fri 2007-11-09 10:57:32 +0000
message:
Merged bzr.dev.
------------------------------------------------------------
revno: 2967.4.3
merged: d.m.watkins at warwick.ac.uk-20071106133827-ghog6ei3vzsh4wy9
parent: d.m.watkins at warwick.ac.uk-20071106112201-vwooertpex8p2sqm
parent: pqm at pqm.ubuntu.com-20071106124804-ehlreba0lfp3kab9
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-06 13:38:27 +0000
message:
Merged bzr.dev and moved NEWS item to appropriate location.
------------------------------------------------------------
revno: 2967.4.2
merged: d.m.watkins at warwick.ac.uk-20071106112201-vwooertpex8p2sqm
parent: d.m.watkins at warwick.ac.uk-20071106091414-dtqvext36lwlu1ud
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-06 11:22:01 +0000
message:
Added a NEWS item.
------------------------------------------------------------
revno: 2967.4.1
merged: d.m.watkins at warwick.ac.uk-20071106091414-dtqvext36lwlu1ud
parent: pqm at pqm.ubuntu.com-20071105211156-bwx6vf8f88m247cy
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 103023
timestamp: Tue 2007-11-06 09:14:14 +0000
message:
Improved error message when a plugin has an invalid name, fixing bug #103023.
=== modified file 'NEWS'
--- a/NEWS 2007-11-13 02:10:22 +0000
+++ b/NEWS 2007-11-13 20:49:38 +0000
@@ -58,6 +58,9 @@
* FTP server errors don't error in the error handling code.
(Robert Collins, #161240)
+ * It is clearer when a plugin cannot be loaded because of its name, and a
+ suggestion for an acceptable name is given. (Daniel Watkins, #103023)
+
* Obsolete packs are now cleaned up by pack and autopack operations.
(Robert Collins, #153789)
=== modified file 'bzrlib/plugin.py'
--- a/bzrlib/plugin.py 2007-08-29 01:50:37 +0000
+++ b/bzrlib/plugin.py 2007-11-13 01:49:34 +0000
@@ -191,8 +191,10 @@
except Exception, e:
## import pdb; pdb.set_trace()
if re.search('\.|-| ', name):
- warning('Unable to load plugin %r from %r: '
- 'It is not a valid python module name.' % (name, d))
+ sanitised_name = re.sub('[-. ]', '_', name)
+ warning("Unable to load %r in %r as a plugin because file path"
+ " isn't a valid module name; try renaming it to %r."
+ % (name, d, sanitised_name))
else:
warning('Unable to load plugin %r from %r' % (name, d))
log_exception_quietly()
=== modified file 'bzrlib/tests/test_plugins.py'
--- a/bzrlib/tests/test_plugins.py 2007-10-16 18:26:12 +0000
+++ b/bzrlib/tests/test_plugins.py 2007-11-13 01:49:34 +0000
@@ -20,6 +20,7 @@
# affects the global state of the process. See bzrlib/plugins.py for more
# comments.
+import logging
import os
from StringIO import StringIO
import sys
@@ -188,6 +189,30 @@
del bzrlib.plugins.ts_plugin
self.failIf(getattr(bzrlib.plugins, 'ts_plugin', None))
+ def test_plugin_with_bad_name_does_not_load(self):
+ # Create badly-named plugin
+ file('bad plugin-name..py', 'w').close()
+
+ # Capture output
+ stream = StringIO()
+ handler = logging.StreamHandler(stream)
+ log = logging.getLogger('bzr')
+ log.addHandler(handler)
+
+ bzrlib.plugin.load_from_dir('.')
+
+ # Stop capturing output
+ handler.flush()
+ handler.close()
+ log.removeHandler(handler)
+
+ self.assertContainsRe(stream.getvalue(),
+ r"Unable to load 'bad plugin-name\.' in '\.' as a plugin because"
+ " file path isn't a valid module name; try renaming it to"
+ " 'bad_plugin_name_'\.")
+
+ stream.close()
+
class TestAllPlugins(TestCaseInTempDir):
More information about the bazaar-commits
mailing list