~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2006-06-20 03:57:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: mbp@sourcefrog.net-20060620035711-400bb6b6bc6ff95b
Add pyflakes makefile target; fix many warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
 
53
53
# TODO: option to show delta summaries for merged-in revisions
 
54
#
 
55
# TODO: deltas_for_log_reverse seems no longer called; delete it?
 
56
 
54
57
import re
55
58
 
56
59
from bzrlib.delta import compare_trees
258
261
            lf.show_merge(rev, merge_depth)
259
262
 
260
263
 
261
 
def deltas_for_log_dummy(branch, which_revs):
262
 
    """Return all the revisions without intermediate deltas.
263
 
 
264
 
    Useful for log commands that won't need the delta information.
265
 
    """
266
 
    
267
 
    for revno, revision_id in which_revs:
268
 
        yield revno, branch.get_revision(revision_id), None
269
 
 
270
 
 
271
 
def deltas_for_log_reverse(branch, which_revs):
272
 
    """Compute deltas for display in latest-to-earliest order.
273
 
 
274
 
    branch
275
 
        Branch to traverse
276
 
 
277
 
    which_revs
278
 
        Sequence of (revno, revision_id) for the subset of history to examine
279
 
 
280
 
    returns 
281
 
        Sequence of (revno, rev, delta)
282
 
 
283
 
    The delta is from the given revision to the next one in the
284
 
    sequence, which makes sense if the log is being displayed from
285
 
    newest to oldest.
286
 
    """
287
 
    last_revno = last_revision_id = last_tree = None
288
 
    for revno, revision_id in which_revs:
289
 
        this_tree = branch.revision_tree(revision_id)
290
 
        this_revision = branch.get_revision(revision_id)
291
 
        
292
 
        if last_revno:
293
 
            yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
294
 
 
295
 
        this_tree = EmptyTree(branch.get_root_id())
296
 
 
297
 
        last_revno = revno
298
 
        last_revision = this_revision
299
 
        last_tree = this_tree
300
 
 
301
 
    if last_revno:
302
 
        if last_revno == 1:
303
 
            this_tree = EmptyTree(branch.get_root_id())
304
 
        else:
305
 
            this_revno = last_revno - 1
306
 
            this_revision_id = branch.revision_history()[this_revno]
307
 
            this_tree = branch.revision_tree(this_revision_id)
308
 
        yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
309
 
 
310
 
 
311
 
def deltas_for_log_forward(branch, which_revs):
312
 
    """Compute deltas for display in forward log.
313
 
 
314
 
    Given a sequence of (revno, revision_id) pairs, return
315
 
    (revno, rev, delta).
316
 
 
317
 
    The delta is from the given revision to the next one in the
318
 
    sequence, which makes sense if the log is being displayed from
319
 
    newest to oldest.
320
 
    """
321
 
    last_revno = last_revision_id = last_tree = None
322
 
    prev_tree = EmptyTree(branch.get_root_id())
323
 
 
324
 
    for revno, revision_id in which_revs:
325
 
        this_tree = branch.revision_tree(revision_id)
326
 
        this_revision = branch.get_revision(revision_id)
327
 
 
328
 
        if not last_revno:
329
 
            if revno == 1:
330
 
                last_tree = EmptyTree(branch.get_root_id())
331
 
            else:
332
 
                last_revno = revno - 1
333
 
                last_revision_id = branch.revision_history()[last_revno]
334
 
                last_tree = branch.revision_tree(last_revision_id)
335
 
 
336
 
        yield revno, this_revision, compare_trees(last_tree, this_tree, False)
337
 
 
338
 
        last_revno = revno
339
 
        last_revision = this_revision
340
 
        last_tree = this_tree
341
 
 
342
 
 
343
264
class LogFormatter(object):
344
265
    """Abstract class to display log messages."""
345
266