~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Robert Collins
  • Date: 2006-02-28 04:31:50 UTC
  • mto: This revision was merged to the branch mainline in revision 1583.
  • Revision ID: robertc@robertcollins.net-20060228043150-fdb9c7f7231b271b
Bugfix aliases to be backwards compatible with plugins providing command.run_argv.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import errno
35
35
 
36
36
import bzrlib
37
 
import bzrlib.trace
38
 
from bzrlib.trace import mutter, note, log_error, warning, be_quiet
39
37
from bzrlib.errors import (BzrError, 
40
38
                           BzrCheckError,
41
39
                           BzrCommandError,
42
40
                           BzrOptionError,
43
41
                           NotBranchError)
 
42
from bzrlib.option import Option
44
43
from bzrlib.revisionspec import RevisionSpec
45
 
from bzrlib.option import Option
 
44
from bzrlib.symbol_versioning import *
 
45
import bzrlib.trace
 
46
from bzrlib.trace import mutter, note, log_error, warning, be_quiet
46
47
 
47
48
plugin_cmds = {}
48
49
 
207
208
            r[o.name] = o
208
209
        return r
209
210
 
210
 
    def run_argv(self, argv, alias_argv=None):
211
 
        """Parse command line and run."""
 
211
    @deprecated_method(zero_eight)
 
212
    def run_argv(self, argv):
 
213
        """Parse command line and run.
 
214
        
 
215
        See run_argv_aliases for the 0.8 and beyond api.
 
216
        """
 
217
        return self.run_argv_aliases(argv)
 
218
 
 
219
    def run_argv_aliases(self, argv, alias_argv=None):
 
220
        """Parse the command line and run with extra aliases in alias_argv."""
212
221
        args, opts = parse_args(self, argv, alias_argv)
213
222
        if 'help' in opts:  # e.g. bzr add --help
214
223
            from bzrlib.help import help_on_command
584
593
    cmd = str(argv.pop(0))
585
594
 
586
595
    cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
 
596
    if not getattr(cmd_obj.run_argv, 'is_deprecated', False):
 
597
        run = cmd_obj.run_argv
 
598
        run_argv = [argv]
 
599
    else:
 
600
        run = cmd_obj.run_argv_aliases
 
601
        run_argv = [argv, alias_argv]
587
602
 
588
603
    try:
589
604
        if opt_lsprof:
590
 
            ret = apply_lsprofiled(opt_lsprof_file, cmd_obj.run_argv, argv, 
591
 
                                   alias_argv)
 
605
            ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv)
592
606
        elif opt_profile:
593
 
            ret = apply_profiled(cmd_obj.run_argv, argv, alias_argv)
 
607
            ret = apply_profiled(run, *run_argv)
594
608
        else:
595
 
            ret = cmd_obj.run_argv(argv, alias_argv)
 
609
            ret = run(*run_argv)
596
610
        return ret or 0
597
611
    finally:
598
612
        # reset, in case we may do other commands later within the same process