~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge in aaron's new missing builtin, fix conflict over it in builtins.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import bzrlib.trace
37
37
from bzrlib.trace import mutter, note, log_error, warning, is_quiet
38
38
from bzrlib.workingtree import WorkingTree
 
39
from bzrlib.log import show_one_log
39
40
 
40
41
 
41
42
def tree_files(file_list, default_branch=u'.'):
856
857
                            help='show from oldest to newest'),
857
858
                     'timezone', 'verbose', 
858
859
                     'show-ids', 'revision',
859
 
                     Option('line', help='format with one line per revision'),
860
 
                     'long', 
 
860
                     'line', 'long', 
861
861
                     Option('message',
862
862
                            help='show revisions whose message matches this regexp',
863
863
                            type=str),
864
 
                     Option('short', help='use moderately short format'),
 
864
                     'short',
865
865
                     ]
866
866
    @display_command
867
867
    def run(self, filename=None, timezone='original',
925
925
        # in e.g. the default C locale.
926
926
        outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout, errors='replace')
927
927
 
928
 
        log_format = 'long'
929
 
        if short:
930
 
            log_format = 'short'
931
 
        if line:
932
 
            log_format = 'line'
 
928
        log_format = get_log_format(long=long, short=short, line=line)
933
929
        lf = log_formatter(log_format,
934
930
                           show_ids=show_ids,
935
931
                           to_file=outf,
944
940
                 end_revision=rev2,
945
941
                 search=message)
946
942
 
 
943
def get_log_format(long=False, short=False, line=False, default='long'):
 
944
    log_format = default
 
945
    if long:
 
946
        log_format = 'long'
 
947
    if short:
 
948
        log_format = 'short'
 
949
    if line:
 
950
        log_format = 'line'
 
951
    return log_format
947
952
 
948
953
 
949
954
class cmd_touching_revisions(Command):
1713
1718
 
1714
1719
 
1715
1720
class cmd_missing(Command):
1716
 
    """What is missing in this branch relative to other branch.
1717
 
    """
1718
 
    # TODO: rewrite this in terms of ancestry so that it shows only
1719
 
    # unmerged things
1720
 
    
1721
 
    takes_args = ['remote?']
1722
 
    aliases = ['mis', 'miss']
1723
 
    takes_options = ['verbose']
1724
 
 
1725
 
    @display_command
1726
 
    def run(self, remote=None, verbose=False):
1727
 
        from bzrlib.errors import BzrCommandError
1728
 
        from bzrlib.missing import show_missing
1729
 
 
1730
 
        if verbose and is_quiet():
1731
 
            raise BzrCommandError('Cannot pass both quiet and verbose')
1732
 
 
1733
 
        tree = WorkingTree.open_containing(u'.')[0]
1734
 
        parent = tree.branch.get_parent()
1735
 
        if remote is None:
1736
 
            if parent is None:
1737
 
                raise BzrCommandError("No missing location known or specified.")
1738
 
            else:
1739
 
                if not is_quiet():
1740
 
                    print "Using last location: %s" % parent
1741
 
                remote = parent
1742
 
        elif parent is None:
1743
 
            # We only update parent if it did not exist, missing
1744
 
            # should not change the parent
1745
 
            tree.branch.set_parent(remote)
1746
 
        br_remote = Branch.open_containing(remote)[0]
1747
 
        return show_missing(tree.branch, br_remote, verbose=verbose, 
1748
 
                            quiet=is_quiet())
 
1721
    """Show unmerged/unpulled revisions between two branches.
 
1722
 
 
1723
    OTHER_BRANCH may be local or remote."""
 
1724
    takes_args = ['other_branch?']
 
1725
    takes_options = [Option('reverse', 'Reverse the order of revisions'),
 
1726
                     Option('mine-only', 
 
1727
                            'Display changes in the local branch only'),
 
1728
                     Option('theirs-only', 
 
1729
                            'Display changes in the remote branch only'), 
 
1730
                     'line',
 
1731
                     'long', 
 
1732
                     'short',
 
1733
                     'show-ids',
 
1734
                     ]
 
1735
 
 
1736
    def run(self, other_branch=None, reverse=False, mine_only=False,
 
1737
            theirs_only=False, long=True, short=False, line=False, 
 
1738
            show_ids=False):
 
1739
        from bzrlib.missing import find_unmerged
 
1740
        from bzrlib.log import log_formatter
 
1741
        local_branch = bzrlib.branch.Branch.open_containing(".")[0]
 
1742
        if other_branch is None:
 
1743
            print "Using last location: " + local_branch.get_parent()
 
1744
            other_branch = local_branch.get_parent()
 
1745
        remote_branch = bzrlib.branch.Branch.open(other_branch)
 
1746
        local_extra, remote_extra = find_unmerged(local_branch, remote_branch)
 
1747
        log_format = get_log_format(long=long, short=short, line=line)
 
1748
        lf = log_formatter(log_format, sys.stdout,
 
1749
                           show_ids=show_ids,
 
1750
                           show_timezone='original')
 
1751
        if reverse is False:
 
1752
            local_extra.reverse()
 
1753
            remote_extra.reverse()
 
1754
        if local_extra and not theirs_only:
 
1755
            print "You have the following extra revisions:"
 
1756
            for revno, revision_id in local_extra:
 
1757
                lf.show(revno, local_branch.get_revision(revision_id), None)
 
1758
            printed_local = True
 
1759
        else:
 
1760
            printed_local = False
 
1761
        if remote_extra and not mine_only:
 
1762
            if printed_local is True:
 
1763
                print "\n\n"
 
1764
            print "You are missing the following revisions:"
 
1765
            for revno, revision_id in remote_extra:
 
1766
                lf.show(revno, remote_branch.get_revision(revision_id), None)
 
1767
        if not remote_extra and not local_extra:
 
1768
            print "Branches are up to date."
1749
1769
 
1750
1770
 
1751
1771
class cmd_plugins(Command):