/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: Martin Pool
  • Date: 2009-11-16 03:39:24 UTC
  • mto: This revision was merged to the branch mainline in revision 4880.
  • Revision ID: mbp@sourcefrog.net-20091116033924-i8fiwzpufzovjgsi
Send Command.outf through UIFactory

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."""