/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: Andrew Bennetts
  • Date: 2010-01-15 03:58:20 UTC
  • mfrom: (4963 +trunk)
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115035820-ilb3t36swgzq6v1l
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1293
1293
    preferred_levels = 0
1294
1294
 
1295
1295
    def __init__(self, to_file, show_ids=False, show_timezone='original',
1296
 
            delta_format=None, levels=None, show_advice=False):
 
1296
            delta_format=None, levels=None, show_advice=False,
 
1297
            to_exact_file=None):
1297
1298
        """Create a LogFormatter.
1298
1299
 
1299
1300
        :param to_file: the file to output to
 
1301
        :param to_exact_file: if set, gives an output stream to which 
 
1302
             non-Unicode diffs are written.
1300
1303
        :param show_ids: if True, revision-ids are to be displayed
1301
1304
        :param show_timezone: the timezone to use
1302
1305
        :param delta_format: the level of delta information to display
1309
1312
        self.to_file = to_file
1310
1313
        # 'exact' stream used to show diff, it should print content 'as is'
1311
1314
        # and should not try to decode/encode it to unicode to avoid bug #328007
1312
 
        self.to_exact_file = getattr(to_file, 'stream', to_file)
 
1315
        if to_exact_file is not None:
 
1316
            self.to_exact_file = to_exact_file
 
1317
        else:
 
1318
            # XXX: somewhat hacky; this assumes it's a codec writer; it's better
 
1319
            # for code that expects to get diffs to pass in the exact file
 
1320
            # stream
 
1321
            self.to_exact_file = getattr(to_file, 'stream', to_file)
1313
1322
        self.show_ids = show_ids
1314
1323
        self.show_timezone = show_timezone
1315
1324
        if delta_format is None:
1494
1503
                                short_status=False)
1495
1504
        if revision.diff is not None:
1496
1505
            to_file.write(indent + 'diff:\n')
 
1506
            to_file.flush()
1497
1507
            # Note: we explicitly don't indent the diff (relative to the
1498
1508
            # revision information) so that the output can be fed to patch -p0
1499
1509
            self.show_diff(self.to_exact_file, revision.diff, indent)
 
1510
            self.to_exact_file.flush()
1500
1511
 
1501
1512
    def get_advice_separator(self):
1502
1513
        """Get the text separating the log from the closing advice."""
1969
1980
 
1970
1981
properties_handler_registry = registry.Registry()
1971
1982
 
 
1983
# Use the properties handlers to print out bug information if available
 
1984
def _bugs_properties_handler(revision):
 
1985
    if revision.properties.has_key('bugs'):
 
1986
        bug_lines = revision.properties['bugs'].split('\n')
 
1987
        bug_rows = [line.split(' ', 1) for line in bug_lines]
 
1988
        fixed_bug_urls = [row[0] for row in bug_rows if
 
1989
                          len(row) > 1 and row[1] == 'fixed']
 
1990
        
 
1991
        if fixed_bug_urls:
 
1992
            return {'fixes bug(s)': ' '.join(fixed_bug_urls)}
 
1993
    return {}
 
1994
 
 
1995
properties_handler_registry.register('bugs_properties_handler',
 
1996
                                     _bugs_properties_handler)
 
1997
 
1972
1998
 
1973
1999
# adapters which revision ids to log are filtered. When log is called, the
1974
2000
# log_rev_iterator is adapted through each of these factory methods.