54
54
from itertools import izip
57
from bzrlib import symbol_versioning
58
57
import bzrlib.errors as errors
59
from bzrlib.symbol_versioning import deprecated_method, zero_eleven
60
58
from bzrlib.trace import mutter
61
59
from bzrlib.tsort import merge_sort
204
202
mainline_revs.insert(0, None)
206
204
mainline_revs.insert(0, which_revs[start_revision-2][1])
207
# how should we show merged revisions ?
208
# old api: show_merge. New api: show_merge_revno
209
show_merge_revno = getattr(lf, 'show_merge_revno', None)
210
show_merge = getattr(lf, 'show_merge', None)
211
if show_merge is None and show_merge_revno is None:
212
# no merged-revno support
213
include_merges = False
205
if getattr(lf, 'show_merge', None) is not None:
206
include_merges = True
215
include_merges = True
216
if show_merge is not None and show_merge_revno is None:
217
# tell developers to update their code
218
symbol_versioning.warn('LogFormatters should provide show_merge_revno '
219
'instead of show_merge since bzr 0.11.',
220
DeprecationWarning, stacklevel=3)
208
include_merges = False
221
209
view_revisions = list(get_view_revisions(mainline_revs, rev_nos, branch,
222
210
direction, include_merges=include_merges))
266
254
lf.show(revno, rev, delta)
268
if show_merge_revno is None:
269
lf.show_merge(rev, merge_depth)
271
lf.show_merge_revno(rev, merge_depth, revno)
256
lf.show_merge(rev, merge_depth)
274
259
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
282
267
if direction == 'reverse':
283
268
revision_ids.reverse()
284
269
for revision_id in revision_ids:
285
yield revision_id, str(rev_nos[revision_id]), 0
270
yield revision_id, rev_nos[revision_id], 0
287
272
merge_sorted_revisions = merge_sort(
288
273
branch.repository.get_revision_graph(mainline_revs[-1]),
289
274
mainline_revs[-1],
293
277
if direction == 'forward':
294
278
# forward means oldest first.
299
283
revision_history = branch.revision_history()
301
for sequence, rev_id, merge_depth, revno, end_of_merge in merge_sorted_revisions:
302
yield rev_id, '.'.join(map(str, revno)), merge_depth
285
for sequence, rev_id, merge_depth, end_of_merge in merge_sorted_revisions:
286
yield rev_id, rev_nos.get(rev_id), merge_depth
305
289
def reverse_by_depth(merge_sorted_revisions, _depth=0):
345
329
def show(self, revno, rev, delta):
346
330
return self._show_helper(revno=revno, rev=rev, delta=delta)
348
@deprecated_method(zero_eleven)
349
332
def show_merge(self, rev, merge_depth):
350
333
return self._show_helper(rev=rev, indent=' '*merge_depth, merged=True, delta=None)
352
def show_merge_revno(self, rev, merge_depth, revno):
353
"""Show a merged revision rev, with merge_depth and a revno."""
354
return self._show_helper(rev=rev, revno=revno,
355
indent=' '*merge_depth, merged=True, delta=None)
357
335
def _show_helper(self, rev=None, revno=None, indent='', merged=False, delta=None):
358
336
"""Show a revision, either merged or not."""
359
337
from bzrlib.osutils import format_date
360
338
to_file = self.to_file
361
339
print >>to_file, indent+'-' * 60
362
340
if revno is not None:
363
print >>to_file, indent+'revno:', revno
341
print >>to_file, 'revno:', revno
365
343
print >>to_file, indent+'merged:', rev.revision_id
366
344
elif self.show_ids:
386
364
message = rev.message.rstrip('\r\n')
387
365
for l in message.split('\n'):
388
366
print >>to_file, indent+' ' + l
389
if delta is not None:
390
368
delta.show(to_file, self.show_ids)
397
375
to_file = self.to_file
398
376
date_str = format_date(rev.timestamp, rev.timezone or 0,
399
377
self.show_timezone)
400
print >>to_file, "%5s %s\t%s" % (revno, self.short_committer(rev),
378
print >>to_file, "%5d %s\t%s" % (revno, self.short_committer(rev),
401
379
format_date(rev.timestamp, rev.timezone or 0,
402
380
self.show_timezone, date_fmt="%Y-%m-%d",
403
381
show_offset=False))
452
430
# show revno only when is not None
453
out.append("%s:" % revno)
431
out.append("%d:" % revno)
454
432
out.append(self.truncate(self.short_committer(rev), 20))
455
433
out.append(self.date_string(rev))
456
434
out.append(rev.get_summary())