86
86
def show_log(branch,
87
88
specific_fileid=None,
88
show_timezone='original',
92
90
direction='reverse',
93
91
start_revision=None,
94
92
end_revision=None):
95
93
"""Write out human-readable log of commits to this branch.
96
LogFormatter object to show the output.
98
99
If true, list only the commits affecting the specified
99
100
file, rather than all commits.
102
'original' (committer's timezone),
103
'utc' (universal time), or
104
'local' (local user's timezone)
107
103
If true show added/changed/deleted/renamed files.
110
If true, show revision and file ids.
113
File to send log to; by default stdout.
116
106
'reverse' (default) is latest to earliest;
117
107
'forward' is earliest to latest.
123
113
If not None, only show revisions <= end_revision
125
from osutils import format_date
126
from errors import BzrCheckError
127
from textui import show_status
115
from bzrlib.osutils import format_date
116
from bzrlib.errors import BzrCheckError
117
from bzrlib.textui import show_status
119
from warnings import warn
121
if not isinstance(lf, LogFormatter):
122
warn("not a LogFormatter instance: %r" % lf)
130
124
if specific_fileid:
131
125
mutter('get log for file_id %r' % specific_fileid)
137
127
which_revs = branch.enum_history(direction)
139
129
if not (verbose or specific_fileid):
203
def show_one_log(revno, rev, delta, show_ids, to_file, show_timezone):
204
from osutils import format_date
193
class LogFormatter(object):
194
"""Abstract class to display log messages."""
195
def __init__(self, to_file, show_ids=False, show_timezone=False):
196
self.to_file = to_file
197
self.show_ids = show_ids
198
self.show_timezone = show_timezone
205
class LongLogFormatter(LogFormatter):
206
def show(self, revno, rev, delta):
207
from osutils import format_date
209
to_file = self.to_file
211
print >>to_file, '-' * 60
212
print >>to_file, 'revno:', revno
214
print >>to_file, 'revision-id:', rev.revision_id
215
print >>to_file, 'committer:', rev.committer
216
print >>to_file, 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
219
print >>to_file, 'message:'
221
print >>to_file, ' (no message)'
223
for l in rev.message.split('\n'):
224
print >>to_file, ' ' + l
227
delta.show(to_file, self.show_ids)
231
class ShortLogFormatter(LogFormatter):
232
def show(self, revno, rev, delta):
233
from bzrlib.osutils import format_date
235
to_file = self.to_file
237
print >>to_file, "%5d %s\t%s" % (revno, rev.committer,
238
format_date(rev.timestamp, rev.timezone or 0,
241
print >>to_file, ' revision-id:', rev.revision_id
243
print >>to_file, ' (no message)'
245
for l in rev.message.split('\n'):
246
print >>to_file, ' ' + l
249
delta.show(to_file, self.show_ids)
254
FORMATTERS = {'long': LongLogFormatter,
255
'short': ShortLogFormatter,
259
def log_formatter(name, *args, **kwargs):
260
from bzrlib.errors import BzrCommandError
206
print >>to_file, '-' * 60
207
print >>to_file, 'revno:', revno
209
print >>to_file, 'revision-id:', rev.revision_id
210
print >>to_file, 'committer:', rev.committer
211
print >>to_file, 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
214
print >>to_file, 'message:'
216
print >>to_file, ' (no message)'
218
for l in rev.message.split('\n'):
219
print >>to_file, ' ' + l
222
delta.show(to_file, show_ids)
263
return FORMATTERS[name](*args, **kwargs)
265
raise BzrCommandError("unknown log formatter: %r" % name)