54
54
from itertools import izip
57
from bzrlib import symbol_versioning
58
61
import bzrlib.errors as errors
59
62
from bzrlib.symbol_versioning import deprecated_method, zero_eleven
60
63
from bzrlib.trace import mutter
459
462
lf = LineLogFormatter(None)
460
463
return lf.log_string(None, rev, max_chars)
463
'long': LongLogFormatter,
464
'short': ShortLogFormatter,
465
'line': LineLogFormatter,
466
class LogFormatterRegistry(registry.Registry):
467
"""Registry for log formatters"""
469
def make_formatter(self, name, *args, **kwargs):
470
"""Construct a formatter from arguments.
472
:param name: Name of the formatter to construct. 'short', 'long' and
475
return self.get(name)(*args, **kwargs)
477
def get_default(self, branch):
478
return self.get(branch.get_config().log_format())
481
log_formatter_registry = LogFormatterRegistry()
484
log_formatter_registry.register('short', ShortLogFormatter,
485
'Moderately short log format')
486
log_formatter_registry.register('long', LongLogFormatter,
487
'Detailed log format')
488
log_formatter_registry.register('line', LineLogFormatter,
489
'Log format with one line per revision')
468
492
def register_formatter(name, formatter):
469
FORMATTERS[name] = formatter
493
log_formatter_registry.register(name, formatter)
471
496
def log_formatter(name, *args, **kwargs):
472
497
"""Construct a formatter from arguments.
477
502
from bzrlib.errors import BzrCommandError
479
return FORMATTERS[name](*args, **kwargs)
504
return log_formatter_registry.make_formatter(name, *args, **kwargs)
481
506
raise BzrCommandError("unknown log formatter: %r" % name)
483
509
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):
484
510
# deprecated; for compatibility
485
511
lf = LongLogFormatter(to_file=to_file, show_timezone=show_timezone)