/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 00:52:08 UTC
  • mfrom: (6675 work)
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610005208-dthx80fkolfpsenj
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
from .i18n import gettext
51
51
# Compatibility - Option used to be in commands.
52
52
from .option import Option
53
 
from .plugin import disable_plugins, load_plugins
 
53
from .plugin import disable_plugins, load_plugins, plugin_name
54
54
from . import registry
55
55
from .sixish import (
56
56
    string_types,
169
169
        # only load once
170
170
        return
171
171
    import breezy.builtins
172
 
    for cmd_class in _scan_module_for_commands(breezy.builtins).values():
 
172
    for cmd_class in _scan_module_for_commands(breezy.builtins):
173
173
        builtin_command_registry.register(cmd_class)
174
174
    breezy.builtins._register_lazy_builtins()
175
175
 
176
176
 
177
177
def _scan_module_for_commands(module):
178
 
    r = {}
179
 
    for name, obj in module.__dict__.items():
 
178
    module_dict = module.__dict__
 
179
    for name in module_dict:
180
180
        if name.startswith("cmd_"):
181
 
            real_name = _unsquish_command_name(name)
182
 
            r[real_name] = obj
183
 
    return r
 
181
            yield module_dict[name]
184
182
 
185
183
 
186
184
def _list_bzr_commands(names):
628
626
 
629
627
        Maps from long option name to option object."""
630
628
        r = Option.STD_OPTIONS.copy()
631
 
        std_names = r.keys()
 
629
        std_names = set(r)
632
630
        for o in self.takes_options:
633
631
            if isinstance(o, string_types):
634
632
                o = option.Option.OPTIONS[o]
755
753
 
756
754
        :return: The name of the plugin or None if the command is builtin.
757
755
        """
758
 
        mod_parts = self.__module__.split('.')
759
 
        if len(mod_parts) >= 3 and mod_parts[1] == 'plugins':
760
 
            return mod_parts[2]
761
 
        else:
762
 
            return None
 
756
        return plugin_name(self.__module__)
763
757
 
764
758
 
765
759
class CommandHooks(Hooks):
828
822
        raise errors.BzrCommandError(
829
823
            gettext('Only ASCII permitted in option names'))
830
824
 
831
 
    opts = dict([(k, v) for k, v in options.__dict__.items() if
832
 
                 v is not option.OptionParser.DEFAULT_VALUE])
 
825
    opts = dict((k, v) for k, v in options.__dict__.items() if
 
826
                v is not option.OptionParser.DEFAULT_VALUE)
833
827
    return args, opts
834
828
 
835
829