~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-18 02:21:57 UTC
  • mfrom: (1787 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1794.
  • Revision ID: john@arbash-meinel.com-20060618022157-6e33aa9b67c25e4f
[merge] bzr.dev 1787

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
all the changes since the previous revision that touched hello.c.
50
50
"""
51
51
 
 
52
 
52
53
# TODO: option to show delta summaries for merged-in revisions
53
 
 
54
 
from itertools import izip
55
54
import re
56
55
 
57
56
from bzrlib.delta import compare_trees
233
232
    for index, rev_id in cut_revs:
234
233
        rev_nos[rev_id] = index
235
234
 
236
 
    def iter_revisions():
237
 
        revision_ids = [r for s, r, m, e in merge_sorted_revisions]
238
 
        num = 9
239
 
        while revision_ids:
240
 
            revisions = branch.repository.get_revisions(revision_ids[:num])
241
 
            for revision in revisions:
242
 
                yield revision
243
 
            revision_ids  = revision_ids[num:]
244
 
            num = int(num * 1.5)
245
 
            
246
 
        revisions = branch.repository.get_revisions()
247
 
        for revision in revisions:
248
 
            yield revision
 
235
    revisions = branch.repository.get_revisions([r for s, r, m, e in
 
236
                                                 merge_sorted_revisions])
 
237
 
249
238
    # now we just print all the revisions
250
239
    for ((sequence, rev_id, merge_depth, end_of_merge), rev) in \
251
 
        izip(merge_sorted_revisions, iter_revisions()):
 
240
        zip(merge_sorted_revisions, revisions):
252
241
 
253
242
        if searchRE:
254
243
            if not searchRE.search(rev.message):
272
261
            lf.show_merge(rev, merge_depth)
273
262
 
274
263
 
 
264
def deltas_for_log_dummy(branch, which_revs):
 
265
    """Return all the revisions without intermediate deltas.
 
266
 
 
267
    Useful for log commands that won't need the delta information.
 
268
    """
 
269
    
 
270
    for revno, revision_id in which_revs:
 
271
        yield revno, branch.get_revision(revision_id), None
 
272
 
 
273
 
 
274
def deltas_for_log_reverse(branch, which_revs):
 
275
    """Compute deltas for display in latest-to-earliest order.
 
276
 
 
277
    branch
 
278
        Branch to traverse
 
279
 
 
280
    which_revs
 
281
        Sequence of (revno, revision_id) for the subset of history to examine
 
282
 
 
283
    returns 
 
284
        Sequence of (revno, rev, delta)
 
285
 
 
286
    The delta is from the given revision to the next one in the
 
287
    sequence, which makes sense if the log is being displayed from
 
288
    newest to oldest.
 
289
    """
 
290
    last_revno = last_revision_id = last_tree = None
 
291
    for revno, revision_id in which_revs:
 
292
        this_tree = branch.revision_tree(revision_id)
 
293
        this_revision = branch.get_revision(revision_id)
 
294
        
 
295
        if last_revno:
 
296
            yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
 
297
 
 
298
        this_tree = EmptyTree(branch.get_root_id())
 
299
 
 
300
        last_revno = revno
 
301
        last_revision = this_revision
 
302
        last_tree = this_tree
 
303
 
 
304
    if last_revno:
 
305
        if last_revno == 1:
 
306
            this_tree = EmptyTree(branch.get_root_id())
 
307
        else:
 
308
            this_revno = last_revno - 1
 
309
            this_revision_id = branch.revision_history()[this_revno]
 
310
            this_tree = branch.revision_tree(this_revision_id)
 
311
        yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
 
312
 
 
313
 
 
314
def deltas_for_log_forward(branch, which_revs):
 
315
    """Compute deltas for display in forward log.
 
316
 
 
317
    Given a sequence of (revno, revision_id) pairs, return
 
318
    (revno, rev, delta).
 
319
 
 
320
    The delta is from the given revision to the next one in the
 
321
    sequence, which makes sense if the log is being displayed from
 
322
    newest to oldest.
 
323
    """
 
324
    last_revno = last_revision_id = last_tree = None
 
325
    prev_tree = EmptyTree(branch.get_root_id())
 
326
 
 
327
    for revno, revision_id in which_revs:
 
328
        this_tree = branch.revision_tree(revision_id)
 
329
        this_revision = branch.get_revision(revision_id)
 
330
 
 
331
        if not last_revno:
 
332
            if revno == 1:
 
333
                last_tree = EmptyTree(branch.get_root_id())
 
334
            else:
 
335
                last_revno = revno - 1
 
336
                last_revision_id = branch.revision_history()[last_revno]
 
337
                last_tree = branch.revision_tree(last_revision_id)
 
338
 
 
339
        yield revno, this_revision, compare_trees(last_tree, this_tree, False)
 
340
 
 
341
        last_revno = revno
 
342
        last_revision = this_revision
 
343
        last_tree = this_tree
 
344
 
 
345
 
275
346
class LogFormatter(object):
276
347
    """Abstract class to display log messages."""
277
348