Rev 3296: (James Westby) Strip "bzr_" from the start of the suggested plugin in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Mar 18 20:00:47 GMT 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3296
revision-id:pqm at pqm.ubuntu.com-20080318200038-jo7mqokvib9aojt9
parent: pqm at pqm.ubuntu.com-20080318091102-7qlikly0ytens0we
parent: bialix at ukr.net-20080318174156-b36d5894ia6q4xvr
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-03-18 20:00:38 +0000
message:
  (James Westby) Strip "bzr_" from the start of the suggested plugin
   name.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
  bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
    ------------------------------------------------------------
    revno: 3290.1.2
    revision-id:bialix at ukr.net-20080318174156-b36d5894ia6q4xvr
    parent: jw+debian at jameswestby.net-20080317131032-8meoti7nsremfjn3
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: bzr.dev.plugins
    timestamp: Tue 2008-03-18 19:41:56 +0200
    message:
      fix markup in NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3290.1.1
    revision-id:jw+debian at jameswestby.net-20080317131032-8meoti7nsremfjn3
    parent: pqm at pqm.ubuntu.com-20080317054003-mzukdvwi1d2icd4c
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: bzr.dev.plugins
    timestamp: Mon 2008-03-17 13:10:32 +0000
    message:
      Strip "bzr_" from the start of the suggested plugin name.
      
      When bzr tries to load a plugin from a path that isn't a valid python
      module name it will suggest the user renames it to one that is.
      
      A bzr- prefix is often not wanted, and may be a common error, so 
      suggest stripping it.
    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	2008-03-18 06:48:18 +0000
+++ b/NEWS	2008-03-18 20:00:38 +0000
@@ -12,6 +12,14 @@
 
   CHANGES:
 
+   * When a plugin cannot be loaded as the file path is not a valid
+     python module name bzr will now strip a ``bzr_`` prefix from the
+     front of the suggested name, as many plugins (e.g. bzr-svn)
+     want to be installed without this prefix. It is a common mistake
+     to have a folder named "bzr-svn" for that plugin, especially
+     as this is what bzr branch lp:bzr-svn will give you. (James Westby,
+     Andrew Cowie)
+
   FEATURES:
 
   IMPROVEMENTS:

=== modified file 'bzrlib/plugin.py'
--- a/bzrlib/plugin.py	2008-02-20 10:36:15 +0000
+++ b/bzrlib/plugin.py	2008-03-17 13:10:32 +0000
@@ -199,9 +199,11 @@
             ## import pdb; pdb.set_trace()
             if re.search('\.|-| ', name):
                 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))
+                if sanitised_name.startswith('bzr_'):
+                    sanitised_name = sanitised_name[len('bzr_'):]
+                warning("Unable to load %r in %r as a plugin because the "
+                        "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	2008-02-20 10:36:15 +0000
+++ b/bzrlib/tests/test_plugins.py	2008-03-17 13:10:32 +0000
@@ -191,7 +191,7 @@
 
     def test_plugin_with_bad_name_does_not_load(self):
         # Create badly-named plugin
-        file('bad plugin-name..py', 'w').close()
+        file('bzr-bad plugin-name..py', 'w').close()
 
         # Capture output
         stream = StringIO()
@@ -207,9 +207,9 @@
         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_'\.")
+            r"Unable to load 'bzr-bad plugin-name\.' in '\.' as a plugin "
+            "because the file path isn't a valid module name; try renaming "
+            "it to 'bad_plugin_name_'\.")
 
         stream.close()
 




More information about the bazaar-commits mailing list