190
185
yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
187
this_tree = EmptyTree(branch.get_root_id())
192
189
last_revno = revno
193
190
last_revision = this_revision
194
191
last_tree = this_tree
197
this_tree = EmptyTree()
195
this_tree = EmptyTree(branch.get_root_id())
197
this_revno = last_revno - 1
198
this_revision_id = branch.revision_history()[this_revno]
199
this_tree = branch.revision_tree(this_revision_id)
198
200
yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
205
from tree import EmptyTree
206
prev_tree = EmptyTree()
203
def deltas_for_log_forward(branch, which_revs):
204
"""Compute deltas for display in forward log.
206
Given a sequence of (revno, revision_id) pairs, return
209
The delta is from the given revision to the next one in the
210
sequence, which makes sense if the log is being displayed from
213
from tree import EmptyTree
214
from diff import compare_trees
216
last_revno = last_revision_id = last_tree = None
217
prev_tree = EmptyTree(branch.get_root_id())
207
219
for revno, revision_id in which_revs:
208
precursor = revision_id
210
if revision_id != rev.revision_id:
211
raise BzrCheckError("retrieved wrong revision: %r"
212
% (revision_id, rev.revision_id))
215
220
this_tree = branch.revision_tree(revision_id)
216
delta = compare_trees(prev_tree, this_tree, want_unchanged=False)
217
prev_tree = this_tree
223
def show_one_log(revno, rev, delta, show_ids, to_file, show_timezone):
224
from osutils import format_date
221
this_revision = branch.get_revision(revision_id)
225
last_tree = EmptyTree(branch.get_root_id())
227
last_revno = revno - 1
228
last_revision_id = branch.revision_history()[last_revno]
229
last_tree = branch.revision_tree(last_revision_id)
231
yield revno, this_revision, compare_trees(last_tree, this_tree, False)
234
last_revision = this_revision
235
last_tree = this_tree
238
class LogFormatter(object):
239
"""Abstract class to display log messages."""
240
def __init__(self, to_file, show_ids=False, show_timezone=False):
241
self.to_file = to_file
242
self.show_ids = show_ids
243
self.show_timezone = show_timezone
246
def show(self, revno, rev, delta):
247
raise NotImplementedError('not implemented in abstract base')
254
class LongLogFormatter(LogFormatter):
255
def show(self, revno, rev, delta):
256
from osutils import format_date
258
to_file = self.to_file
260
print >>to_file, '-' * 60
261
print >>to_file, 'revno:', revno
263
print >>to_file, 'revision-id:', rev.revision_id
264
print >>to_file, 'committer:', rev.committer
265
print >>to_file, 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
268
print >>to_file, 'message:'
270
print >>to_file, ' (no message)'
272
for l in rev.message.split('\n'):
273
print >>to_file, ' ' + l
276
delta.show(to_file, self.show_ids)
280
class ShortLogFormatter(LogFormatter):
281
def show(self, revno, rev, delta):
282
from bzrlib.osutils import format_date
284
to_file = self.to_file
286
print >>to_file, "%5d %s\t%s" % (revno, rev.committer,
287
format_date(rev.timestamp, rev.timezone or 0,
290
print >>to_file, ' revision-id:', rev.revision_id
292
print >>to_file, ' (no message)'
294
for l in rev.message.split('\n'):
295
print >>to_file, ' ' + l
298
delta.show(to_file, self.show_ids)
303
FORMATTERS = {'long': LongLogFormatter,
304
'short': ShortLogFormatter,
308
def log_formatter(name, *args, **kwargs):
309
from bzrlib.errors import BzrCommandError
226
print >>to_file, '-' * 60
227
print >>to_file, 'revno:', revno
229
print >>to_file, 'revision-id:', rev.revision_id
230
print >>to_file, 'committer:', rev.committer
231
print >>to_file, 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
234
print >>to_file, 'message:'
236
print >>to_file, ' (no message)'
238
for l in rev.message.split('\n'):
239
print >>to_file, ' ' + l
242
delta.show(to_file, show_ids)
312
return FORMATTERS[name](*args, **kwargs)
314
raise BzrCommandError("unknown log formatter: %r" % name)
316
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):
317
# deprecated; for compatability
318
lf = LongLogFormatter(to_file=to_file, show_timezone=show_timezone)
319
lf.show(revno, rev, delta)