~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-29 05:21:36 UTC
  • mfrom: (3921.3.14 bzr.missing_revision)
  • mto: This revision was merged to the branch mainline in revision 3970.
  • Revision ID: ian.clatworthy@canonical.com-20090129052136-1a0ue2k2rhxznu23
Add local & remote revision filtering to missing (Marius Kruger)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
""")
56
56
 
57
57
from bzrlib.commands import Command, display_command
58
 
from bzrlib.option import ListOption, Option, RegistryOption, custom_help
 
58
from bzrlib.option import (
 
59
    ListOption,
 
60
    Option,
 
61
    RegistryOption,
 
62
    custom_help,
 
63
    _parse_revision_str,
 
64
    )
59
65
from bzrlib.trace import mutter, note, warning, is_quiet, get_verbosity_level
60
66
 
61
67
 
1967
1973
            'bzr %s --revision takes one or two values.' % command_name)
1968
1974
    return rev1, rev2
1969
1975
 
 
1976
 
 
1977
def _revision_range_to_revid_range(revision_range):
 
1978
    rev_id1 = None
 
1979
    rev_id2 = None
 
1980
    if revision_range[0] is not None:
 
1981
        rev_id1 = revision_range[0].rev_id
 
1982
    if revision_range[1] is not None:
 
1983
        rev_id2 = revision_range[1].rev_id
 
1984
    return rev_id1, rev_id2
 
1985
 
1970
1986
def get_log_format(long=False, short=False, line=False, default='long'):
1971
1987
    log_format = default
1972
1988
    if long:
3512
3528
 
3513
3529
class cmd_missing(Command):
3514
3530
    """Show unmerged/unpulled revisions between two branches.
3515
 
    
 
3531
 
3516
3532
    OTHER_BRANCH may be local or remote.
 
3533
 
 
3534
    To filter on a range of revirions, you can use the command -r begin..end
 
3535
    -r revision requests a specific revision, -r ..end or -r begin.. are
 
3536
    also valid.
 
3537
 
 
3538
    :Examples:
 
3539
 
 
3540
        Determine the missing revisions between this and the branch at the
 
3541
        remembered pull location::
 
3542
 
 
3543
            bzr missing
 
3544
 
 
3545
        Determine the missing revisions between this and another branch::
 
3546
 
 
3547
            bzr missing http://server/branch
 
3548
 
 
3549
        Determine the missing revisions up to a specific revision on the other
 
3550
        branch::
 
3551
 
 
3552
            bzr missing -r ..-10
 
3553
 
 
3554
        Determine the missing revisions up to a specific revision on this
 
3555
        branch::
 
3556
 
 
3557
            bzr missing --my-revision ..-10
3517
3558
    """
3518
3559
 
3519
3560
    _see_also = ['merge', 'pull']
3520
3561
    takes_args = ['other_branch?']
3521
3562
    takes_options = [
3522
 
            Option('reverse', 'Reverse the order of revisions.'),
3523
 
            Option('mine-only',
3524
 
                   'Display changes in the local branch only.'),
3525
 
            Option('this' , 'Same as --mine-only.'),
3526
 
            Option('theirs-only',
3527
 
                   'Display changes in the remote branch only.'),
3528
 
            Option('other', 'Same as --theirs-only.'),
3529
 
            'log-format',
3530
 
            'show-ids',
3531
 
            'verbose',
3532
 
            Option('include-merges', 'Show merged revisions.'),
3533
 
            ]
 
3563
        Option('reverse', 'Reverse the order of revisions.'),
 
3564
        Option('mine-only',
 
3565
               'Display changes in the local branch only.'),
 
3566
        Option('this' , 'Same as --mine-only.'),
 
3567
        Option('theirs-only',
 
3568
               'Display changes in the remote branch only.'),
 
3569
        Option('other', 'Same as --theirs-only.'),
 
3570
        'log-format',
 
3571
        'show-ids',
 
3572
        'verbose',
 
3573
        custom_help('revision',
 
3574
             help='Filter on other branch revisions (inclusive). '
 
3575
                'See "help revisionspec" for details.'),
 
3576
        Option('my-revision',
 
3577
            type=_parse_revision_str,
 
3578
            help='Filter on local branch revisions (inclusive). '
 
3579
                'See "help revisionspec" for details.'),
 
3580
        Option('include-merges', 'Show merged revisions.'),
 
3581
        ]
3534
3582
    encoding_type = 'replace'
3535
3583
 
3536
3584
    @display_command
3538
3586
            theirs_only=False,
3539
3587
            log_format=None, long=False, short=False, line=False,
3540
3588
            show_ids=False, verbose=False, this=False, other=False,
3541
 
            include_merges=False):
 
3589
            include_merges=False, revision=None, my_revision=None):
3542
3590
        from bzrlib.missing import find_unmerged, iter_log_revisions
3543
3591
        def message(s):
3544
3592
            if not is_quiet():
3572
3620
        remote_branch = Branch.open(other_branch)
3573
3621
        if remote_branch.base == local_branch.base:
3574
3622
            remote_branch = local_branch
 
3623
 
 
3624
        local_revid_range = _revision_range_to_revid_range(
 
3625
            _get_revision_range(my_revision, local_branch,
 
3626
                self.name()))
 
3627
 
 
3628
        remote_revid_range = _revision_range_to_revid_range(
 
3629
            _get_revision_range(revision,
 
3630
                remote_branch, self.name()))
 
3631
 
3575
3632
        local_branch.lock_read()
3576
3633
        try:
3577
3634
            remote_branch.lock_read()
3579
3636
                local_extra, remote_extra = find_unmerged(
3580
3637
                    local_branch, remote_branch, restrict,
3581
3638
                    backward=not reverse,
3582
 
                    include_merges=include_merges)
 
3639
                    include_merges=include_merges,
 
3640
                    local_revid_range=local_revid_range,
 
3641
                    remote_revid_range=remote_revid_range)
3583
3642
 
3584
3643
                if log_format is None:
3585
3644
                    registry = log.log_formatter_registry
4716
4775
                revid1, revid2 = rev1.rev_id, rev2.rev_id
4717
4776
                # only show revisions between revid1 and revid2 (inclusive)
4718
4777
                tags = [(tag, revid) for tag, revid in tags if
4719
 
                     (revid2 is None or
4720
 
                         graph.is_ancestor(revid, revid2)) and
4721
 
                     (revid1 is None or
4722
 
                         graph.is_ancestor(revid1, revid))]
 
4778
                    graph.is_between(revid, revid1, revid2)]
4723
4779
            finally:
4724
4780
                branch.unlock()
4725
4781
        if sort == 'alpha':