/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 bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2006-03-20 23:09:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1621.
  • Revision ID: mbp@sourcefrog.net-20060320230942-152767f76202f543
doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
 
51
51
def register_command(cmd, decorate=False):
52
 
    "Utility function to help register a command"
 
52
    """Utility function to help register a command
 
53
 
 
54
    :param cmd: Command subclass to register
 
55
    :param decorate: If true, allow overriding an existing command
 
56
        of the same name; the old command is returned by this function.
 
57
        Otherwise it is an error to try to override an existing command.
 
58
    """
53
59
    global plugin_cmds
54
60
    k = cmd.__name__
55
61
    if k.startswith("cmd_"):
58
64
        k_unsquished = k
59
65
    if not plugin_cmds.has_key(k_unsquished):
60
66
        plugin_cmds[k_unsquished] = cmd
61
 
        mutter('registered plugin command %s', k_unsquished)      
 
67
        mutter('registered plugin command %s', k_unsquished)
62
68
        if decorate and k_unsquished in builtin_command_names():
63
69
            return _builtin_commands()[k_unsquished]
64
70
    elif decorate:
85
91
    builtins = bzrlib.builtins.__dict__
86
92
    for name in builtins:
87
93
        if name.startswith("cmd_"):
88
 
            real_name = _unsquish_command_name(name)        
 
94
            real_name = _unsquish_command_name(name)
89
95
            r[real_name] = builtins[name]
90
96
    return r
91
 
 
92
97
            
93
98
 
94
99
def builtin_command_names():