~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

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
""")
595
596
 
596
597
    def _setup_outf(self):
597
598
        """Return a file linked to stdout, which has proper encoding."""
598
 
        # Originally I was using self.stdout, but that looks
599
 
        # *way* too much like sys.stdout
600
 
        if self.encoding_type == 'exact':
601
 
            # force sys.stdout to be binary stream on win32
602
 
            if sys.platform == 'win32':
603
 
                fileno = getattr(sys.stdout, 'fileno', None)
604
 
                if fileno:
605
 
                    import msvcrt
606
 
                    msvcrt.setmode(fileno(), os.O_BINARY)
607
 
            self.outf = sys.stdout
608
 
            return
609
 
 
610
 
        output_encoding = osutils.get_terminal_encoding()
611
 
 
612
 
        self.outf = codecs.getwriter(output_encoding)(sys.stdout,
613
 
                        errors=self.encoding_type)
614
 
        # For whatever reason codecs.getwriter() does not advertise its encoding
615
 
        # it just returns the encoding of the wrapped file, which is completely
616
 
        # bogus. So set the attribute, so we can find the correct encoding later.
617
 
        self.outf.encoding = output_encoding
 
599
        self.outf = ui.ui_factory.make_output_stream(
 
600
            encoding_type=self.encoding_type)
618
601
 
619
602
    def run_argv_aliases(self, argv, alias_argv=None):
620
603
        """Parse the command line and run with extra aliases in alias_argv."""
940
923
 
941
924
    --coverage
942
925
        Generate line coverage report in the specified directory.
 
926
 
 
927
    --concurrency
 
928
        Specify the number of processes that can be run concurrently (selftest).
943
929
    """
944
930
    argv = list(argv)
945
931
    trace.mutter("bzr arguments: %r", argv)
970
956
            opt_no_aliases = True
971
957
        elif a == '--builtin':
972
958
            opt_builtin = True
 
959
        elif a == '--concurrency':
 
960
            os.environ['BZR_CONCURRENCY'] = argv[i + 1]
 
961
            i += 1
973
962
        elif a == '--coverage':
974
963
            opt_coverage_dir = argv[i + 1]
975
964
            i += 1