54
54
from itertools import izip
57
from bzrlib import symbol_versioning
57
58
import bzrlib.errors as errors
59
from bzrlib.symbol_versioning import deprecated_method, zero_eleven
58
60
from bzrlib.trace import mutter
59
61
from bzrlib.tsort import merge_sort
202
204
mainline_revs.insert(0, None)
204
206
mainline_revs.insert(0, which_revs[start_revision-2][1])
205
if getattr(lf, 'show_merge', None) is not None:
206
include_merges = True
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
208
include_merges = False
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)
209
221
view_revisions = list(get_view_revisions(mainline_revs, rev_nos, branch,
210
222
direction, include_merges=include_merges))
254
266
lf.show(revno, rev, delta)
256
lf.show_merge(rev, merge_depth)
268
if show_merge_revno is None:
269
lf.show_merge(rev, merge_depth)
271
lf.show_merge_revno(rev, merge_depth, revno)
259
274
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
267
282
if direction == 'reverse':
268
283
revision_ids.reverse()
269
284
for revision_id in revision_ids:
270
yield revision_id, rev_nos[revision_id], 0
285
yield revision_id, str(rev_nos[revision_id]), 0
272
287
merge_sorted_revisions = merge_sort(
273
288
branch.repository.get_revision_graph(mainline_revs[-1]),
274
289
mainline_revs[-1],
277
293
if direction == 'forward':
278
294
# forward means oldest first.
283
299
revision_history = branch.revision_history()
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
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
289
305
def reverse_by_depth(merge_sorted_revisions, _depth=0):
329
345
def show(self, revno, rev, delta):
330
346
return self._show_helper(revno=revno, rev=rev, delta=delta)
348
@deprecated_method(zero_eleven)
332
349
def show_merge(self, rev, merge_depth):
333
350
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)
335
357
def _show_helper(self, rev=None, revno=None, indent='', merged=False, delta=None):
336
358
"""Show a revision, either merged or not."""
337
359
from bzrlib.osutils import format_date
338
360
to_file = self.to_file
339
361
print >>to_file, indent+'-' * 60
340
362
if revno is not None:
341
print >>to_file, 'revno:', revno
363
print >>to_file, indent+'revno:', revno
343
365
print >>to_file, indent+'merged:', rev.revision_id
344
366
elif self.show_ids:
375
397
to_file = self.to_file
376
398
date_str = format_date(rev.timestamp, rev.timezone or 0,
377
399
self.show_timezone)
378
print >>to_file, "%5d %s\t%s" % (revno, self.short_committer(rev),
400
print >>to_file, "%5s %s\t%s" % (revno, self.short_committer(rev),
379
401
format_date(rev.timestamp, rev.timezone or 0,
380
402
self.show_timezone, date_fmt="%Y-%m-%d",
381
403
show_offset=False))
430
452
# show revno only when is not None
431
out.append("%d:" % revno)
453
out.append("%s:" % revno)
432
454
out.append(self.truncate(self.short_committer(rev), 20))
433
455
out.append(self.date_string(rev))
434
456
out.append(rev.get_summary())