/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: John Arbash Meinel
  • Date: 2009-12-10 17:16:19 UTC
  • mfrom: (4884 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4889.
  • Revision ID: john@arbash-meinel.com-20091210171619-ehdcxjbl8afhq9g1
Bring in bzr.dev 4884

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2006, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
45
45
    option,
46
46
    osutils,
47
47
    trace,
 
48
    ui,
48
49
    win32utils,
49
50
    )
50
51
""")
56
57
from bzrlib.symbol_versioning import (
57
58
    deprecated_function,
58
59
    deprecated_in,
 
60
    deprecated_method,
59
61
    suppress_deprecation_warnings,
60
62
    )
61
63
 
101
103
            registry.Registry.register(self, k_unsquished, cmd,
102
104
                                       override_existing=decorate, info=info)
103
105
        except KeyError:
104
 
            trace.log_error('Two plugins defined the same command: %r' % k)
105
 
            trace.log_error('Not loading the one in %r' %
106
 
                            sys.modules[cmd.__module__])
107
 
            trace.log_error('Previously this command was registered from %r' %
108
 
                            sys.modules[previous.__module__])
 
106
            trace.warning('Two plugins defined the same command: %r' % k)
 
107
            trace.warning('Not loading the one in %r' %
 
108
                sys.modules[cmd.__module__])
 
109
            trace.warning('Previously this command was registered from %r' %
 
110
                sys.modules[previous.__module__])
109
111
        return previous
110
112
 
111
113
    def register_lazy(self, command_name, aliases, module_name):
383
385
        # List of standard options directly supported
384
386
        self.supported_std_options = []
385
387
 
 
388
    @deprecated_method(deprecated_in((2, 1, 0)))
386
389
    def _maybe_expand_globs(self, file_list):
387
390
        """Glob expand file_list if the platform does not do that itself.
388
391
 
 
392
        Not used anymore, now that the bzr command-line parser globs on
 
393
        Windows.
 
394
 
389
395
        :return: A possibly empty list of unicode paths.
390
396
 
391
397
        Introduced in bzrlib 0.18.
392
398
        """
393
 
        if not file_list:
394
 
            file_list = []
395
 
        if sys.platform == 'win32':
396
 
            file_list = win32utils.glob_expand(file_list)
397
 
        return list(file_list)
 
399
        return file_list
398
400
 
399
401
    def _usage(self):
400
402
        """Return single-line grammar for this command.
594
596
 
595
597
    def _setup_outf(self):
596
598
        """Return a file linked to stdout, which has proper encoding."""
597
 
        # Originally I was using self.stdout, but that looks
598
 
        # *way* too much like sys.stdout
599
 
        if self.encoding_type == 'exact':
600
 
            # force sys.stdout to be binary stream on win32
601
 
            if sys.platform == 'win32':
602
 
                fileno = getattr(sys.stdout, 'fileno', None)
603
 
                if fileno:
604
 
                    import msvcrt
605
 
                    msvcrt.setmode(fileno(), os.O_BINARY)
606
 
            self.outf = sys.stdout
607
 
            return
608
 
 
609
 
        output_encoding = osutils.get_terminal_encoding()
610
 
 
611
 
        self.outf = codecs.getwriter(output_encoding)(sys.stdout,
612
 
                        errors=self.encoding_type)
613
 
        # For whatever reason codecs.getwriter() does not advertise its encoding
614
 
        # it just returns the encoding of the wrapped file, which is completely
615
 
        # bogus. So set the attribute, so we can find the correct encoding later.
616
 
        self.outf.encoding = output_encoding
 
599
        self.outf = ui.ui_factory.make_output_stream(
 
600
            encoding_type=self.encoding_type)
617
601
 
618
602
    def run_argv_aliases(self, argv, alias_argv=None):
619
603
        """Parse the command line and run with extra aliases in alias_argv."""
939
923
 
940
924
    --coverage
941
925
        Generate line coverage report in the specified directory.
 
926
 
 
927
    --concurrency
 
928
        Specify the number of processes that can be run concurrently (selftest).
942
929
    """
943
930
    argv = list(argv)
944
931
    trace.mutter("bzr arguments: %r", argv)
969
956
            opt_no_aliases = True
970
957
        elif a == '--builtin':
971
958
            opt_builtin = True
 
959
        elif a == '--concurrency':
 
960
            os.environ['BZR_CONCURRENCY'] = argv[i + 1]
 
961
            i += 1
972
962
        elif a == '--coverage':
973
963
            opt_coverage_dir = argv[i + 1]
974
964
            i += 1
1035
1025
            ret = apply_coveraged(opt_coverage_dir, run, *run_argv)
1036
1026
        else:
1037
1027
            ret = run(*run_argv)
1038
 
        if 'memory' in debug.debug_flags:
1039
 
            trace.debug_memory('Process status after command:', short=False)
1040
1028
        return ret or 0
1041
1029
    finally:
1042
1030
        # reset, in case we may do other commands later within the same
1043
1031
        # process. Commands that want to execute sub-commands must propagate
1044
1032
        # --verbose in their own way.
 
1033
        if 'memory' in debug.debug_flags:
 
1034
            trace.debug_memory('Process status after command:', short=False)
1045
1035
        option._verbosity_level = saved_verbosity_level
1046
1036
 
1047
1037
 
1114
1104
        argv = new_argv
1115
1105
    ret = run_bzr_catch_errors(argv)
1116
1106
    trace.mutter("return code %d", ret)
 
1107
    osutils.report_extension_load_failures()
1117
1108
    return ret
1118
1109
 
1119
1110