/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: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
342
342
 
343
343
class LogFormatter(object):
344
344
    """Abstract class to display log messages."""
 
345
 
345
346
    def __init__(self, to_file, show_ids=False, show_timezone='original'):
346
347
        self.to_file = to_file
347
348
        self.show_ids = show_ids
348
349
        self.show_timezone = show_timezone
349
350
 
350
 
 
351
351
    def show(self, revno, rev, delta):
352
352
        raise NotImplementedError('not implemented in abstract base')
353
353
 
424
424
            delta.show(to_file, self.show_ids)
425
425
        print >>to_file, ''
426
426
 
 
427
 
427
428
class LineLogFormatter(LogFormatter):
428
429
    def truncate(self, str, max_len):
429
430
        if len(str) <= max_len:
443
444
            return rev.message
444
445
 
445
446
    def show(self, revno, rev, delta):
446
 
        print >> self.to_file, self.log_string(rev, 79) 
 
447
        from bzrlib.osutils import terminal_width
 
448
        print >> self.to_file, self.log_string(revno, rev, terminal_width()-1)
447
449
 
448
 
    def log_string(self, rev, max_chars):
449
 
        out = [self.truncate(self.short_committer(rev), 20)]
 
450
    def log_string(self, revno, rev, max_chars):
 
451
        """Format log info into one string. Truncate tail of string
 
452
        :param  revno:      revision number (int) or None.
 
453
                            Revision numbers counts from 1.
 
454
        :param  rev:        revision info object
 
455
        :param  max_chars:  maximum length of resulting string
 
456
        :return:            formatted truncated string
 
457
        """
 
458
        out = []
 
459
        if revno:
 
460
            # show revno only when is not None
 
461
            out.append("%d:" % revno)
 
462
        out.append(self.truncate(self.short_committer(rev), 20))
450
463
        out.append(self.date_string(rev))
451
464
        out.append(self.message(rev).replace('\n', ' '))
452
465
        return self.truncate(" ".join(out).rstrip('\n'), max_chars)
453
466
 
 
467
 
454
468
def line_log(rev, max_chars):
455
469
    lf = LineLogFormatter(None)
456
 
    return lf.log_string(rev, max_chars)
 
470
    return lf.log_string(None, rev, max_chars)
457
471
 
458
472
FORMATTERS = {
459
473
              'long': LongLogFormatter,