/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: Robert Collins
  • Date: 2007-09-04 04:12:07 UTC
  • mfrom: (2794 +trunk)
  • mto: (2592.3.126 repository)
  • mto: This revision was merged to the branch mainline in revision 2795.
  • Revision ID: robertc@robertcollins.net-20070904041207-zb3l8hfco0sp6hu8
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
    else:
86
86
        trace.log_error('Two plugins defined the same command: %r' % k)
87
87
        trace.log_error('Not loading the one in %r' % sys.modules[cmd.__module__])
 
88
        trace.log_error('Previously this command was registered from %r' %
 
89
                        sys.modules[plugin_cmds[k_unsquished].__module__])
88
90
 
89
91
 
90
92
def _squish_command_name(cmd):
238
240
        """Construct an instance of this command."""
239
241
        if self.__doc__ == Command.__doc__:
240
242
            warn("No help message set for %r" % self)
 
243
        # List of standard options directly supported
 
244
        self.supported_std_options = []
241
245
 
242
246
    def _maybe_expand_globs(self, file_list):
243
247
        """Glob expand file_list if the platform does not do that itself.
417
421
        """Return dict of valid options for this command.
418
422
 
419
423
        Maps from long option name to option object."""
420
 
        r = dict()
421
 
        r['help'] = option._help_option
 
424
        r = Option.STD_OPTIONS.copy()
 
425
        std_names = r.keys()
422
426
        for o in self.takes_options:
423
427
            if isinstance(o, basestring):
424
428
                o = option.Option.OPTIONS[o]
425
429
            r[o.name] = o
 
430
            if o.name in std_names:
 
431
                self.supported_std_options.append(o.name)
426
432
        return r
427
433
 
428
434
    def _setup_outf(self):
458
464
                 DeprecationWarning, stacklevel=2)
459
465
            argv = []
460
466
        args, opts = parse_args(self, argv, alias_argv)
 
467
 
 
468
        # Process the standard options
461
469
        if 'help' in opts:  # e.g. bzr add --help
462
470
            sys.stdout.write(self.get_help_text())
463
471
            return 0
 
472
        trace.set_verbosity_level(option._verbosity_level)
 
473
        if 'verbose' in self.supported_std_options:
 
474
            opts['verbose'] = trace.is_verbose()
 
475
        elif opts.has_key('verbose'):
 
476
            del opts['verbose']
 
477
        if 'quiet' in self.supported_std_options:
 
478
            opts['quiet'] = trace.is_quiet()
 
479
        elif opts.has_key('quiet'):
 
480
            del opts['quiet']
 
481
 
464
482
        # mix arguments and options into one dictionary
465
483
        cmdargs = _match_argform(self.name(), self.takes_args, args)
466
484
        cmdopts = {}
691
709
            opt_no_aliases = True
692
710
        elif a == '--builtin':
693
711
            opt_builtin = True
694
 
        elif a in ('--quiet', '-q'):
695
 
            trace.be_quiet()
696
712
        elif a.startswith('-D'):
697
713
            debug.debug_flags.add(a[2:])
698
714
        else:
744
760
        return ret or 0
745
761
    finally:
746
762
        # reset, in case we may do other commands later within the same process
747
 
        trace.be_quiet(False)
 
763
        option._verbosity_level = 0
748
764
 
749
765
def display_command(func):
750
766
    """Decorator that suppresses pipe/interrupt errors."""