~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Aaron Bentley
  • Date: 2006-06-23 17:22:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1810.
  • Revision ID: abentley@panoramicfeedback.com-20060623172259-e34bbebf91d9d0f8
Sort revisions at each depth, instead of just mainline revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
 
283
283
    if direction == 'forward':
284
284
        # forward means oldest first.
285
 
        merge_sorted_revisions = reverse_zero_depth(merge_sorted_revisions)
 
285
        merge_sorted_revisions = reverse_by_depth(merge_sorted_revisions)
286
286
    elif direction != 'reverse':
287
287
        raise ValueError('invalid direction %r' % direction)
288
288
 
292
292
        yield rev_id, rev_nos.get(rev_id), merge_depth
293
293
 
294
294
 
295
 
def reverse_zero_depth(merge_sorted_revisions):
296
 
    """Reverse zero-depth revisions.
 
295
def reverse_by_depth(merge_sorted_revisions, _depth=0):
 
296
    """Reverse revisions by depth.
297
297
 
298
 
    Revisions with a depth > 0 are sorted as a group with the previous i
299
 
    zero-depth revision.  There may be no topological justification for this,
 
298
    Revisions with a different depth are sorted as a group with the previous
 
299
    revision of that depth.  There may be no topological justification for this,
300
300
    but it looks much nicer.
301
301
    """
302
302
    zd_revisions = []
303
303
    for val in merge_sorted_revisions:
304
 
        if val[2] == 0:
 
304
        if val[2] == _depth:
305
305
            zd_revisions.append([val])
306
306
        else:
 
307
            assert val[2] > _depth
307
308
            zd_revisions[-1].append(val)
 
309
    for revisions in zd_revisions:
 
310
        if len(revisions) > 1:
 
311
            revisions[1:] = reverse_by_depth(revisions[1:], _depth + 1)
308
312
    zd_revisions.reverse()
309
313
    result = []
310
314
    for chunk in zd_revisions: