/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/log.py

  • Committer: Martin Pool
  • Date: 2009-12-08 09:06:02 UTC
  • mto: This revision was merged to the branch mainline in revision 4880.
  • Revision ID: mbp@sourcefrog.net-20091208090602-ss0uypbt5v3wlw8d
Give LogFormatters a second byte output stream for their diffs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1291
1291
    preferred_levels = 0
1292
1292
 
1293
1293
    def __init__(self, to_file, show_ids=False, show_timezone='original',
1294
 
                 delta_format=None, levels=None, show_advice=False):
 
1294
                 delta_format=None, levels=None, show_advice=False,
 
1295
                 to_exact_file=None):
1295
1296
        """Create a LogFormatter.
1296
1297
 
1297
1298
        :param to_file: the file to output to
 
1299
        :param to_exact_file: if set, gives an output stream to which 
 
1300
             non-Unicode diffs are written.
1298
1301
        :param show_ids: if True, revision-ids are to be displayed
1299
1302
        :param show_timezone: the timezone to use
1300
1303
        :param delta_format: the level of delta information to display
1307
1310
        self.to_file = to_file
1308
1311
        # 'exact' stream used to show diff, it should print content 'as is'
1309
1312
        # and should not try to decode/encode it to unicode to avoid bug #328007
1310
 
        self.to_exact_file = getattr(to_file, 'stream', to_file)
 
1313
        if to_exact_file is not None:
 
1314
            self.to_exact_file = to_exact_file
 
1315
        else:
 
1316
            self.to_exact_file = getattr(to_file, 'stream', to_file)
1311
1317
        self.show_ids = show_ids
1312
1318
        self.show_timezone = show_timezone
1313
1319
        if delta_format is None:
1463
1469
                                short_status=False)
1464
1470
        if revision.diff is not None:
1465
1471
            to_file.write(indent + 'diff:\n')
 
1472
            to_file.flush()
1466
1473
            # Note: we explicitly don't indent the diff (relative to the
1467
1474
            # revision information) so that the output can be fed to patch -p0
1468
1475
            self.show_diff(self.to_exact_file, revision.diff, indent)
 
1476
            self.to_exact_file.flush()
1469
1477
 
1470
1478
    def get_advice_separator(self):
1471
1479
        """Get the text separating the log from the closing advice."""