~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

Removed changes from bzr.ab 1529..1536

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import errno
35
35
 
36
36
import bzrlib
37
 
from bzrlib.config import GlobalConfig
38
37
import bzrlib.trace
39
38
from bzrlib.trace import mutter, note, log_error, warning, be_quiet
40
39
from bzrlib.errors import (BzrError, 
41
40
                           BzrCheckError,
42
41
                           BzrCommandError,
43
42
                           BzrOptionError,
44
 
                           NotBranchError,
45
 
                           CommandDefaultSyntax,
46
 
                           )
 
43
                           NotBranchError)
47
44
from bzrlib.revisionspec import RevisionSpec
48
45
from bzrlib import BZRDIR
49
46
from bzrlib.option import Option
211
208
            r[o.name] = o
212
209
        return r
213
210
 
214
 
    def run_argv(self, argv, defaults=None):
 
211
    def run_argv(self, argv):
215
212
        """Parse command line and run."""
216
 
        if defaults is not None:
217
 
            args, opts = parse_args(self, defaults)
218
 
        else:
219
 
            args = []
220
 
            opts = {}
221
 
        cmd_args, cmd_opts = parse_args(self, argv)
222
 
        args.extend(cmd_args)
223
 
        opts.update(cmd_opts)
 
213
        args, opts = parse_args(self, argv)
224
214
        if 'help' in opts:  # e.g. bzr add --help
225
215
            from bzrlib.help import help_on_command
226
216
            help_on_command(self.name())
494
484
    argv = [a.decode(bzrlib.user_encoding) for a in argv]
495
485
 
496
486
    opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = False
497
 
    opt_no_defaults = False
498
487
 
499
488
    # --no-plugins is handled specially at a very early stage. We need
500
489
    # to load plugins before doing other command parsing so that they
501
490
    # can override commands, but this needs to happen first.
502
491
 
503
 
    for a in argv[:]:
 
492
    for a in argv:
504
493
        if a == '--profile':
505
494
            opt_profile = True
506
495
        elif a == '--lsprof':
511
500
            opt_builtin = True
512
501
        elif a in ('--quiet', '-q'):
513
502
            be_quiet()
514
 
        elif a in ('--no-defaults',):
515
 
            opt_no_defaults = True
516
503
        else:
517
504
            continue
518
505
        argv.remove(a)
540
527
    cmd = str(argv.pop(0))
541
528
 
542
529
    cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
543
 
    if opt_no_defaults is True:
544
 
        cmd_defaults = []
545
 
    else:
546
 
        cmd_defaults = GlobalConfig().get_command_defaults(cmd_obj.name())
 
530
 
547
531
    try:
548
532
        if opt_lsprof:
549
 
            ret = apply_lsprofiled(cmd_obj.run_argv, argv, cmd_defaults)
 
533
            ret = apply_lsprofiled(cmd_obj.run_argv, argv)
550
534
        elif opt_profile:
551
 
            ret = apply_profiled(cmd_obj.run_argv, argv, cmd_defaults)
 
535
            ret = apply_profiled(cmd_obj.run_argv, argv)
552
536
        else:
553
 
            ret = cmd_obj.run_argv(argv, cmd_defaults)
 
537
            ret = cmd_obj.run_argv(argv)
554
538
        return ret or 0
555
539
    finally:
556
540
        # reset, in case we may do other commands later within the same process