[PATCH] show full name of plugin in help

Alexander Belchenko bialix at ukr.net
Wed Oct 4 09:04:45 BST 2006

Martin Pool пишет:
> On  3 Oct 2006, Alexander Belchenko <bialix at ukr.net> wrote:
>> Attached patch provide support for show full name of plugin (plugin
>> directory) in help even if it contains dot separated version number
>> (e.g. myplug-1.2.3). With test, of course.
>> Also this test fixes cleanup after test in test_plugin_help_shows_plugin.
> That sounds reasonable.
>> === modified file bzrlib/commands.py // last-changed:bialix at ukr.net-20061003150
>> ... 147-970c4b9b12a5e6b9
>> --- bzrlib/commands.py
>> +++ bzrlib/commands.py
>> @@ -311,7 +311,14 @@
>>          """
>>          mod_parts = self.__module__.split('.')
>>          if len(mod_parts) >= 3 and mod_parts[1] == 'plugins':
>> -            return mod_parts[2]
>> +            name = [mod_parts[2]]
>> +            for m in mod_parts[3:]:
>> +                try:
>> +                    n = int(m)
>> +                except ValueError:
>> +                    break
>> +                name.append(m)
>> +            return '.'.join(name)
>>          else:
>>              return None
> Why the int()/ValueError block?

I need to get only digits from mod_parts. Some plugin commands (e.g.
rspush in bzrtools) declared in modules inside packages (not in
__init__.py). If we simply collect tail of mod_parts as
'.'.join(modparts[2:]) then we get incorrect result:

D:\Bazaar\sandbox\bzr.dev.dot.wrong>python bzr help rspush
usage: bzr rspush [LOCATION]

(From plugin "bzrtools.rspush")

Upload this branch to another location using rsync.

I'm sure it will be wrong.

But if user unpack tar of 0.11 release of bzrtools and copy it to
plugins directory (e.g. ~/.bazaar/plugins/) then there is directory
called bzrtools-0.11.0 but in help it shown as "bzrtools-0". I think
it's also wrong.

> Since your code changes Command, I think it would be a better test to
> just check the behaviour of Command.plugin_name() instead, rather than
> the help command.

Well, I make my changes primarily for help. And it seems that
Command.plugin_name() used only in help.

I could move my test to test_commands.py but I think that in
test_plugins.py it more appropriate. Also because there is already
exists similar test (based on which I wrote my test case). If you think
that I need to rework test to get +1 I'll certainly do it.


More information about the bazaar mailing list