~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Robert Collins
  • Date: 2005-10-10 23:18:27 UTC
  • mfrom: (1437)
  • mto: This revision was merged to the branch mainline in revision 1438.
  • Revision ID: robertc@robertcollins.net-20051010231827-f9e2dda2e92bf565
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
"""
51
51
 
52
52
 
 
53
import bzrlib.errors as errors
53
54
from bzrlib.tree import EmptyTree
54
55
from bzrlib.delta import compare_trees
55
56
from bzrlib.trace import mutter
206
207
    else:
207
208
        raise ValueError('invalid direction %r' % direction)
208
209
 
 
210
    revision_history = branch.revision_history()
209
211
    for revno, rev_id in cut_revs:
210
212
        if verbose or specific_fileid:
211
213
            delta = _get_revision_delta(branch, revno)
225
227
                continue
226
228
 
227
229
        lf.show(revno, rev, delta)
228
 
 
 
230
        if revno == 1:
 
231
            excludes = set()
 
232
        else:
 
233
            # revno is 1 based, so -2 to get back 1 less.
 
234
            excludes = set(branch.get_ancestry(revision_history[revno - 2]))
 
235
        pending = list(rev.parent_ids)
 
236
        while pending:
 
237
            rev_id = pending.pop()
 
238
            if rev_id in excludes:
 
239
                continue
 
240
            # prevent showing merged revs twice if they multi-path.
 
241
            excludes.add(rev_id)
 
242
            try:
 
243
                rev = branch.get_revision(rev_id)
 
244
            except errors.NoSuchRevision:
 
245
                continue
 
246
            pending.extend(rev.parent_ids)
 
247
            lf.show_merge(rev)
229
248
 
230
249
 
231
250
def deltas_for_log_dummy(branch, which_revs):
321
340
    def show(self, revno, rev, delta):
322
341
        raise NotImplementedError('not implemented in abstract base')
323
342
 
 
343
    def show_merge(self, rev):
 
344
        pass
 
345
 
324
346
    
325
347
class LongLogFormatter(LogFormatter):
326
348
    def show(self, revno, rev, delta):
353
375
        if delta != None:
354
376
            delta.show(to_file, self.show_ids)
355
377
 
 
378
    def show_merge(self, rev):
 
379
        from osutils import format_date
 
380
 
 
381
        to_file = self.to_file
 
382
 
 
383
        indent = '    '
 
384
 
 
385
        print >>to_file,  indent+'-' * 60
 
386
        print >>to_file,  indent+'merged:', rev.revision_id
 
387
        if self.show_ids:
 
388
            for parent_id in rev.parent_ids:
 
389
                print >>to_file, indent+'parent:', parent_id
 
390
            
 
391
        print >>to_file,  indent+'committer:', rev.committer
 
392
 
 
393
        date_str = format_date(rev.timestamp,
 
394
                               rev.timezone or 0,
 
395
                               self.show_timezone)
 
396
        print >>to_file,  indent+'timestamp: %s' % date_str
 
397
 
 
398
        print >>to_file,  indent+'message:'
 
399
        if not rev.message:
 
400
            print >>to_file,  indent+'  (no message)'
 
401
        else:
 
402
            for l in rev.message.split('\n'):
 
403
                print >>to_file,  indent+'  ' + l
356
404
 
357
405
 
358
406
class ShortLogFormatter(LogFormatter):