~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-20 11:04:44 UTC
  • mfrom: (2178.4.6 win32.binary-stdout)
  • Revision ID: pqm@pqm.ubuntu.com-20061220110444-a991704cfe50d2b3
(bialix) Bugfix #55276: on win32 cat, bundle and diff commands provide
 binary output without mangling line-endings

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
            replace - put in a bogus character (typically '?')
215
215
            exact - do not encode sys.stdout
216
216
 
 
217
            NOTE: by default on Windows, sys.stdout is opened as a text
 
218
            stream, therefore LF line-endings are converted to CRLF.
 
219
            When a command uses encoding_type = 'exact', then
 
220
            sys.stdout is forced to be a binary stream, and line-endings
 
221
            will not mangled.
 
222
 
217
223
    """
218
224
    aliases = []
219
225
    takes_args = []
246
252
        # Originally I was using self.stdout, but that looks
247
253
        # *way* too much like sys.stdout
248
254
        if self.encoding_type == 'exact':
 
255
            # force sys.stdout to be binary stream on win32
 
256
            if sys.platform == 'win32':
 
257
                fileno = getattr(sys.stdout, 'fileno', None)
 
258
                if fileno:
 
259
                    import msvcrt
 
260
                    msvcrt.setmode(fileno(), os.O_BINARY)
249
261
            self.outf = sys.stdout
250
262
            return
251
263