229
230
lf.show(revno, rev, delta)
233
# revno is 1 based, so -2 to get back 1 less.
234
excludes = set(branch.get_ancestry(revision_history[revno - 2]))
235
pending = list(rev.parent_ids)
237
rev_id = pending.pop()
238
if rev_id in excludes:
240
# prevent showing merged revs twice if they multi-path.
243
rev = branch.get_revision(rev_id)
244
except errors.NoSuchRevision:
246
pending.extend(rev.parent_ids)
231
if hasattr(lf, 'show_merge'):
235
# revno is 1 based, so -2 to get back 1 less.
236
excludes = set(branch.get_ancestry(revision_history[revno - 2]))
237
pending = list(rev.parent_ids)
239
rev_id = pending.pop()
240
if rev_id in excludes:
242
# prevent showing merged revs twice if they multi-path.
245
rev = branch.get_revision(rev_id)
246
except errors.NoSuchRevision:
248
pending.extend(rev.parent_ids)
250
252
def deltas_for_log_dummy(branch, which_revs):
340
342
def show(self, revno, rev, delta):
341
343
raise NotImplementedError('not implemented in abstract base')
343
def show_merge(self, rev):
347
346
class LongLogFormatter(LogFormatter):
348
347
def show(self, revno, rev, delta):
408
407
from bzrlib.osutils import format_date
410
409
to_file = self.to_file
410
date_str = format_date(rev.timestamp, rev.timezone or 0,
412
412
print >>to_file, "%5d %s\t%s" % (revno, rev.committer,
413
413
format_date(rev.timestamp, rev.timezone or 0,
414
414
self.show_timezone))
426
426
delta.show(to_file, self.show_ids)
429
class LineLogFormatter(LogFormatter):
430
def truncate(self, str, max_len):
431
if len(str) <= max_len:
433
return str[:max_len-3]+'...'
435
def date_string(self, rev):
436
from bzrlib.osutils import format_date
437
return format_date(rev.timestamp, rev.timezone or 0,
438
self.show_timezone, date_fmt="%Y-%m-%d",
441
def message(self, rev):
443
return '(no message)'
447
def short_committer(self, rev):
448
return re.sub('<.*@.*>', '', rev.committer).strip(' ')
450
def show(self, revno, rev, delta):
451
print >> self.to_file, self.log_string(rev, 79)
453
def log_string(self, rev, max_chars):
454
out = [self.truncate(self.short_committer(rev), 20)]
455
out.append(self.date_string(rev))
456
out.append(self.message(rev).replace('\n', ' '))
457
return self.truncate(" ".join(out).rstrip('\n'), max_chars)
459
def line_log(rev, max_chars):
460
lf = LineLogFormatter(None)
461
return lf.log_string(rev, max_chars)
431
463
FORMATTERS = {'long': LongLogFormatter,
432
464
'short': ShortLogFormatter,
465
'line': LineLogFormatter,
436
469
def log_formatter(name, *args, **kwargs):
437
470
"""Construct a formatter from arguments.
439
name -- Name of the formatter to construct; currently 'long' and
440
'short' are supported.
472
name -- Name of the formatter to construct; currently 'long', 'short' and
473
'line' are supported.
442
475
from bzrlib.errors import BzrCommandError