~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: John Arbash Meinel
  • Date: 2008-05-23 05:37:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3461.
  • Revision ID: john@arbash-meinel.com-20080523053753-frkmeyg4uowpau6f
bzr uncommit doesn't need to work in terms of 'revision_history()'

Show diffs side-by-side

added added

removed removed

Lines of Context:
335
335
 
336
336
    :return: A (mainline_revs, rev_nos, start_rev_id, end_rev_id) tuple.
337
337
    """
338
 
    which_revs = _enumerate_history(branch)
339
 
    if not which_revs:
 
338
    branch_revno, branch_last_revision = branch.last_revision_info()
 
339
    if branch_revno == 0:
340
340
        return None, None, None, None
341
341
 
342
342
    # For mainline generation, map start_revision and end_revision to 
349
349
    if start_revision is None:
350
350
        start_revno = 1
351
351
    else:
352
 
        if isinstance(start_revision,RevisionInfo):
 
352
        if isinstance(start_revision, RevisionInfo):
353
353
            start_rev_id = start_revision.rev_id
354
354
            start_revno = start_revision.revno or 1
355
355
        else:
360
360
    if end_revision is None:
361
361
        end_revno = len(which_revs)
362
362
    else:
363
 
        if isinstance(end_revision,RevisionInfo):
 
363
        if isinstance(end_revision, RevisionInfo):
364
364
            end_rev_id = end_revision.rev_id
365
365
            end_revno = end_revision.revno or len(which_revs)
366
366
        else:
374
374
        raise BzrCommandError("Start revision must be older than "
375
375
                              "the end revision.")
376
376
 
377
 
    # list indexes are 0-based; revisions are 1-based
378
 
    cut_revs = which_revs[(start_revno-1):(end_revno)]
379
 
    if not cut_revs:
 
377
    if (end_revno < start_revno):
380
378
        return None, None, None, None
 
379
    cur_revno = branch_revno
 
380
    rev_nos = {}
 
381
    mainline_revs = []
 
382
    for revision_id in branch.repository.iter_reverse_revision_history(
 
383
                        branch_last_revision):
 
384
        if cur_revno < start_revno:
 
385
            # We have gone far enough
 
386
            # import pdb; pdb.set_trace()
 
387
            rev_nos[revision_id] = cur_revno
 
388
            mainline_revs.append(revision_id)
 
389
            break
 
390
        if cur_revno <= end_revno:
 
391
            rev_nos[revision_id] = cur_revno
 
392
            mainline_revs.append(revision_id)
 
393
        cur_revno -= 1
381
394
 
382
 
    # convert the revision history to a dictionary:
383
 
    rev_nos = dict((k, v) for v, k in cut_revs)
 
395
    mainline_revs.reverse()
384
396
 
385
397
    # override the mainline to look like the revision history.
386
 
    mainline_revs = [revision_id for index, revision_id in cut_revs]
387
 
    if cut_revs[0][0] == 1:
388
 
        mainline_revs.insert(0, None)
389
 
    else:
390
 
        mainline_revs.insert(0, which_revs[start_revno-2][1])
391
398
    return mainline_revs, rev_nos, start_rev_id, end_rev_id
392
399
 
393
400