~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-27 20:24:43 UTC
  • mfrom: (3960.2.1 1.12-progress-warnings)
  • Revision ID: pqm@pqm.ubuntu.com-20090127202443-ty2bu1hh91dumasz
(jam) Avoid getting a UserWarning by not creating an unused progress
        bar.

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 (
59
 
    ListOption,
60
 
    Option,
61
 
    RegistryOption,
62
 
    custom_help,
63
 
    _parse_revision_str,
64
 
    )
 
58
from bzrlib.option import ListOption, Option, RegistryOption, custom_help
65
59
from bzrlib.trace import mutter, note, warning, is_quiet, get_verbosity_level
66
60
 
67
61
 
1818
1812
        raise errors.BzrCommandError(msg)
1819
1813
 
1820
1814
 
1821
 
def _parse_levels(s):
1822
 
    try:
1823
 
        return int(s)
1824
 
    except ValueError:
1825
 
        msg = "The levels argument must be an integer."
1826
 
        raise errors.BzrCommandError(msg)
1827
 
 
1828
 
 
1829
1815
class cmd_log(Command):
1830
1816
    """Show log of a branch, file, or directory.
1831
1817
 
1866
1852
                   help='Show just the specified revision.'
1867
1853
                   ' See also "help revisionspec".'),
1868
1854
            'log-format',
1869
 
            Option('levels',
1870
 
                   short_name='n',
1871
 
                   help='Number of levels to display - 0 for all, 1 for flat.',
1872
 
                   argname='N',
1873
 
                   type=_parse_levels),
1874
1855
            Option('message',
1875
1856
                   short_name='m',
1876
1857
                   help='Show revisions whose message matches this '
1881
1862
                   help='Limit the output to the first N revisions.',
1882
1863
                   argname='N',
1883
1864
                   type=_parse_limit),
1884
 
            Option('show-diff',
1885
 
                   short_name='p',
1886
 
                   help='Show changes made in each revision as a patch.'),
1887
1865
            ]
1888
1866
    encoding_type = 'replace'
1889
1867
 
1895
1873
            revision=None,
1896
1874
            change=None,
1897
1875
            log_format=None,
1898
 
            levels=None,
1899
1876
            message=None,
1900
 
            limit=None,
1901
 
            show_diff=False):
1902
 
        from bzrlib.log import show_log, _get_fileid_to_log
 
1877
            limit=None):
 
1878
        from bzrlib.log import show_log
1903
1879
        direction = (forward and 'forward') or 'reverse'
1904
1880
 
1905
1881
        if change is not None:
1919
1895
            tree, b, fp = bzrdir.BzrDir.open_containing_tree_or_branch(
1920
1896
                location)
1921
1897
            if fp != '':
1922
 
                file_id = _get_fileid_to_log(revision, tree, b, fp)
 
1898
                if tree is None:
 
1899
                    tree = b.basis_tree()
 
1900
                file_id = tree.path2id(fp)
1923
1901
                if file_id is None:
1924
1902
                    raise errors.BzrCommandError(
1925
 
                        "Path unknown at end or start of revision range: %s" %
 
1903
                        "Path does not have any revision history: %s" %
1926
1904
                        location)
1927
1905
        else:
1928
1906
            # local dir only
1943
1921
 
1944
1922
            lf = log_format(show_ids=show_ids, to_file=self.outf,
1945
1923
                            show_timezone=timezone,
1946
 
                            delta_format=get_verbosity_level(),
1947
 
                            levels=levels)
 
1924
                            delta_format=get_verbosity_level())
1948
1925
 
1949
1926
            show_log(b,
1950
1927
                     lf,
1954
1931
                     start_revision=rev1,
1955
1932
                     end_revision=rev2,
1956
1933
                     search=message,
1957
 
                     limit=limit,
1958
 
                     show_diff=show_diff)
 
1934
                     limit=limit)
1959
1935
        finally:
1960
1936
            b.unlock()
1961
1937
 
1962
 
 
1963
1938
def _get_revision_range(revisionspec_list, branch, command_name):
1964
1939
    """Take the input of a revision option and turn it into a revision range.
1965
1940
 
1987
1962
            'bzr %s --revision takes one or two values.' % command_name)
1988
1963
    return rev1, rev2
1989
1964
 
1990
 
 
1991
 
def _revision_range_to_revid_range(revision_range):
1992
 
    rev_id1 = None
1993
 
    rev_id2 = None
1994
 
    if revision_range[0] is not None:
1995
 
        rev_id1 = revision_range[0].rev_id
1996
 
    if revision_range[1] is not None:
1997
 
        rev_id2 = revision_range[1].rev_id
1998
 
    return rev_id1, rev_id2
1999
 
 
2000
1965
def get_log_format(long=False, short=False, line=False, default='long'):
2001
1966
    log_format = default
2002
1967
    if long:
3542
3507
 
3543
3508
class cmd_missing(Command):
3544
3509
    """Show unmerged/unpulled revisions between two branches.
3545
 
 
 
3510
    
3546
3511
    OTHER_BRANCH may be local or remote.
3547
 
 
3548
 
    To filter on a range of revirions, you can use the command -r begin..end
3549
 
    -r revision requests a specific revision, -r ..end or -r begin.. are
3550
 
    also valid.
3551
 
 
3552
 
    :Examples:
3553
 
 
3554
 
        Determine the missing revisions between this and the branch at the
3555
 
        remembered pull location::
3556
 
 
3557
 
            bzr missing
3558
 
 
3559
 
        Determine the missing revisions between this and another branch::
3560
 
 
3561
 
            bzr missing http://server/branch
3562
 
 
3563
 
        Determine the missing revisions up to a specific revision on the other
3564
 
        branch::
3565
 
 
3566
 
            bzr missing -r ..-10
3567
 
 
3568
 
        Determine the missing revisions up to a specific revision on this
3569
 
        branch::
3570
 
 
3571
 
            bzr missing --my-revision ..-10
3572
3512
    """
3573
3513
 
3574
3514
    _see_also = ['merge', 'pull']
3575
3515
    takes_args = ['other_branch?']
3576
3516
    takes_options = [
3577
 
        Option('reverse', 'Reverse the order of revisions.'),
3578
 
        Option('mine-only',
3579
 
               'Display changes in the local branch only.'),
3580
 
        Option('this' , 'Same as --mine-only.'),
3581
 
        Option('theirs-only',
3582
 
               'Display changes in the remote branch only.'),
3583
 
        Option('other', 'Same as --theirs-only.'),
3584
 
        'log-format',
3585
 
        'show-ids',
3586
 
        'verbose',
3587
 
        custom_help('revision',
3588
 
             help='Filter on other branch revisions (inclusive). '
3589
 
                'See "help revisionspec" for details.'),
3590
 
        Option('my-revision',
3591
 
            type=_parse_revision_str,
3592
 
            help='Filter on local branch revisions (inclusive). '
3593
 
                'See "help revisionspec" for details.'),
3594
 
        Option('include-merges', 'Show merged revisions.'),
3595
 
        ]
 
3517
            Option('reverse', 'Reverse the order of revisions.'),
 
3518
            Option('mine-only',
 
3519
                   'Display changes in the local branch only.'),
 
3520
            Option('this' , 'Same as --mine-only.'),
 
3521
            Option('theirs-only',
 
3522
                   'Display changes in the remote branch only.'),
 
3523
            Option('other', 'Same as --theirs-only.'),
 
3524
            'log-format',
 
3525
            'show-ids',
 
3526
            'verbose',
 
3527
            Option('include-merges', 'Show merged revisions.'),
 
3528
            ]
3596
3529
    encoding_type = 'replace'
3597
3530
 
3598
3531
    @display_command
3600
3533
            theirs_only=False,
3601
3534
            log_format=None, long=False, short=False, line=False,
3602
3535
            show_ids=False, verbose=False, this=False, other=False,
3603
 
            include_merges=False, revision=None, my_revision=None):
 
3536
            include_merges=False):
3604
3537
        from bzrlib.missing import find_unmerged, iter_log_revisions
3605
3538
        def message(s):
3606
3539
            if not is_quiet():
3634
3567
        remote_branch = Branch.open(other_branch)
3635
3568
        if remote_branch.base == local_branch.base:
3636
3569
            remote_branch = local_branch
3637
 
 
3638
 
        local_revid_range = _revision_range_to_revid_range(
3639
 
            _get_revision_range(my_revision, local_branch,
3640
 
                self.name()))
3641
 
 
3642
 
        remote_revid_range = _revision_range_to_revid_range(
3643
 
            _get_revision_range(revision,
3644
 
                remote_branch, self.name()))
3645
 
 
3646
3570
        local_branch.lock_read()
3647
3571
        try:
3648
3572
            remote_branch.lock_read()
3650
3574
                local_extra, remote_extra = find_unmerged(
3651
3575
                    local_branch, remote_branch, restrict,
3652
3576
                    backward=not reverse,
3653
 
                    include_merges=include_merges,
3654
 
                    local_revid_range=local_revid_range,
3655
 
                    remote_revid_range=remote_revid_range)
 
3577
                    include_merges=include_merges)
3656
3578
 
3657
3579
                if log_format is None:
3658
3580
                    registry = log.log_formatter_registry
4789
4711
                revid1, revid2 = rev1.rev_id, rev2.rev_id
4790
4712
                # only show revisions between revid1 and revid2 (inclusive)
4791
4713
                tags = [(tag, revid) for tag, revid in tags if
4792
 
                    graph.is_between(revid, revid1, revid2)]
 
4714
                     (revid2 is None or
 
4715
                         graph.is_ancestor(revid, revid2)) and
 
4716
                     (revid1 is None or
 
4717
                         graph.is_ancestor(revid1, revid))]
4793
4718
            finally:
4794
4719
                branch.unlock()
4795
4720
        if sort == 'alpha':