~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-03 18:09:01 UTC
  • mfrom: (3159.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20080103180901-w987y1ftqoh02qbm
(vila) Fix #179368 by keeping the current range hint on
        ShortReadvErrors

Show diffs side-by-side

added added

removed removed

Lines of Context:
266
266
    A negative number will count from the end of the branch (-1 is the
267
267
    last revision, -2 the previous one). If the negative number is larger
268
268
    than the branch's history, the first revision is returned.
269
 
    examples:
 
269
    Examples::
 
270
 
270
271
      revno:1                   -> return the first revision
271
272
      revno:3:/path/to/branch   -> return the 3rd revision of
272
273
                                   the branch '/path/to/branch'
370
371
    Supply a specific revision id, that can be used to specify any
371
372
    revision id in the ancestry of the branch. 
372
373
    Including merges, and pending merges.
373
 
    examples:
 
374
    Examples::
 
375
 
374
376
      revid:aaaa@bbbb-123456789 -> Select revision 'aaaa@bbbb-123456789'
375
377
    """    
376
378
    prefix = 'revid:'
392
394
 
393
395
    Supply a positive number to get the nth revision from the end.
394
396
    This is the same as supplying negative numbers to the 'revno:' spec.
395
 
    examples:
 
397
    Examples::
 
398
 
396
399
      last:1        -> return the last revision
397
400
      last:3        -> return the revision 2 before the end.
398
401
    """    
433
436
    This is mostly useful when inspecting revisions that are not in the
434
437
    revision history of a branch.
435
438
 
436
 
    examples:
 
439
    Examples::
 
440
 
437
441
      before:1913    -> Return the parent of revno 1913 (revno 1912)
438
442
      before:revid:aaaa@bbbb-1234567890  -> return the parent of revision
439
443
                                            aaaa@bbbb-1234567890
454
458
            rev = branch.repository.get_revision(r.rev_id)
455
459
            if not rev.parent_ids:
456
460
                revno = 0
457
 
                revision_id = None
 
461
                revision_id = revision.NULL_REVISION
458
462
            else:
459
463
                revision_id = rev.parent_ids[0]
460
464
                try:
521
525
    Matches the first entry after a given date (either at midnight or
522
526
    at a specified time).
523
527
 
524
 
    One way to display all the changes since yesterday would be:
 
528
    One way to display all the changes since yesterday would be::
 
529
 
525
530
        bzr log -r date:yesterday..-1
526
531
 
527
 
    examples:
 
532
    Examples::
 
533
 
528
534
      date:yesterday            -> select the first revision since yesterday
529
535
      date:2006-08-14,17:10:14  -> select the first revision after
530
536
                                   August 14th, 2006 at 5:10pm.
612
618
    that your branch introduces, while excluding the changes that you
613
619
    have not merged from the remote branch.
614
620
 
615
 
    examples:
 
621
    Examples::
 
622
 
616
623
      ancestor:/path/to/branch
617
624
      $ bzr diff -r ancestor:../../mainline/branch
618
625
    """
632
639
        for r, b in ((revision_a, branch), (revision_b, other_branch)):
633
640
            if r in (None, revision.NULL_REVISION):
634
641
                raise errors.NoCommits(b)
635
 
        revision_source = revision.MultipleRevisionSources(
636
 
                branch.repository, other_branch.repository)
637
 
        rev_id = revision.common_ancestor(revision_a, revision_b,
638
 
                                          revision_source)
 
642
        branch.lock_read()
 
643
        other_branch.lock_read()
639
644
        try:
640
 
            revno = branch.revision_id_to_revno(rev_id)
641
 
        except errors.NoSuchRevision:
642
 
            revno = None
643
 
        return RevisionInfo(branch, revno, rev_id)
 
645
            revision_source = revision.MultipleRevisionSources(
 
646
                    branch.repository, other_branch.repository)
 
647
            graph = branch.repository.get_graph(other_branch.repository)
 
648
            revision_a = revision.ensure_null(revision_a)
 
649
            revision_b = revision.ensure_null(revision_b)
 
650
            if revision.NULL_REVISION in (revision_a, revision_b):
 
651
                rev_id = revision.NULL_REVISION
 
652
            else:
 
653
                rev_id = graph.find_unique_lca(revision_a, revision_b)
 
654
                if rev_id == revision.NULL_REVISION:
 
655
                    raise errors.NoCommonAncestor(revision_a, revision_b)
 
656
            try:
 
657
                revno = branch.revision_id_to_revno(rev_id)
 
658
            except errors.NoSuchRevision:
 
659
                revno = None
 
660
            return RevisionInfo(branch, revno, rev_id)
 
661
        finally:
 
662
            branch.unlock()
 
663
            other_branch.unlock()
644
664
 
645
665
 
646
666
SPEC_TYPES.append(RevisionSpec_ancestor)
653
673
 
654
674
    Supply the path to a branch to select its last revision.
655
675
 
656
 
    examples:
 
676
    Examples::
 
677
 
657
678
      branch:/path/to/branch
658
679
    """
659
680
    prefix = 'branch:'
689
710
    branches. Usually this is the branch point, but it could also be
690
711
    a revision that was merged.
691
712
 
692
 
    examples:
 
713
    Examples::
 
714
 
693
715
      $ bzr diff -r submit:
694
716
    """
695
717