/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-08-17 03:31:19 UTC
  • Revision ID: mbp@sourcefrog.net-20050817033119-1976931eac3199db
todo

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
        raise BzrCommandError(msg)
142
142
    
143
143
 
 
144
def get_merge_type(typestring):
 
145
    """Attempt to find the merge class/factory associated with a string."""
 
146
    from merge import merge_types
 
147
    try:
 
148
        return merge_types[typestring][0]
 
149
    except KeyError:
 
150
        templ = '%s%%7s: %%s' % (' '*12)
 
151
        lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
 
152
        type_list = '\n'.join(lines)
 
153
        msg = "No known merge type %s. Supported types are:\n%s" %\
 
154
            (typestring, type_list)
 
155
        raise BzrCommandError(msg)
 
156
    
 
157
 
144
158
 
145
159
def _get_cmd_dict(plugins_override=True):
146
160
    d = {}
837
851
    If files are listed, only the changes in those files are listed.
838
852
    Otherwise, all changes for the tree are listed.
839
853
 
840
 
    TODO: Given two revision arguments, show the difference between them.
841
 
 
842
854
    TODO: Allow diff across branches.
843
855
 
844
856
    TODO: Option to use external diff command; could be GNU diff, wdiff,
853
865
          deleted files.
854
866
 
855
867
    TODO: This probably handles non-Unix newlines poorly.
 
868
 
 
869
    examples:
 
870
        bzr diff
 
871
        bzr diff -r1
 
872
        bzr diff -r1:2
856
873
    """
857
874
    
858
875
    takes_args = ['file*']
871
888
        else:
872
889
            b = find_branch('.')
873
890
 
874
 
        # TODO: Make show_diff support taking 2 arguments
875
 
        base_rev = None
876
891
        if revision is not None:
877
 
            if len(revision) != 1:
878
 
                raise BzrCommandError('bzr diff --revision takes exactly one revision identifier')
879
 
            base_rev = revision[0]
880
 
    
881
 
        show_diff(b, base_rev, specific_files=file_list,
882
 
                  external_diff_options=diff_options)
883
 
 
 
892
            if len(revision) == 1:
 
893
                show_diff(b, revision[0], specific_files=file_list,
 
894
                          external_diff_options=diff_options)
 
895
            elif len(revision) == 2:
 
896
                show_diff(b, revision[0], specific_files=file_list,
 
897
                          external_diff_options=diff_options,
 
898
                          revision2=revision[1])
 
899
            else:
 
900
                raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
 
901
        else:
 
902
            show_diff(b, None, specific_files=file_list,
 
903
                      external_diff_options=diff_options)
884
904
 
885
905
        
886
906
 
967
987
    """
968
988
 
969
989
    takes_args = ['filename?']
970
 
    takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision','long', 'message']
 
990
    takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision',
 
991
                     'long', 'message', 'short',]
971
992
    
972
993
    def run(self, filename=None, timezone='original',
973
994
            verbose=False,
975
996
            forward=False,
976
997
            revision=None,
977
998
            message=None,
978
 
            long=False):
 
999
            long=False,
 
1000
            short=False):
979
1001
        from bzrlib.branch import find_branch
980
1002
        from bzrlib.log import log_formatter, show_log
981
1003
        import codecs
1015
1037
        # in e.g. the default C locale.
1016
1038
        outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout, errors='replace')
1017
1039
 
1018
 
        if long:
 
1040
        if not short:
1019
1041
            log_format = 'long'
1020
1042
        else:
1021
1043
            log_format = 'short'
1514
1536
 
1515
1537
 
1516
1538
 
 
1539
class cmd_missing(Command):
 
1540
    """What is missing in this branch relative to other branch.
 
1541
    """
 
1542
    takes_args = ['remote?']
 
1543
    aliases = ['mis', 'miss']
 
1544
    # We don't have to add quiet to the list, because 
 
1545
    # unknown options are parsed as booleans
 
1546
    takes_options = ['verbose', 'quiet']
 
1547
 
 
1548
    def run(self, remote=None, verbose=False, quiet=False):
 
1549
        from bzrlib.branch import find_branch, DivergedBranches
 
1550
        from bzrlib.errors import BzrCommandError
 
1551
        from bzrlib.missing import get_parent, show_missing
 
1552
 
 
1553
        if verbose and quiet:
 
1554
            raise BzrCommandError('Cannot pass both quiet and verbose')
 
1555
 
 
1556
        b = find_branch('.')
 
1557
        parent = get_parent(b)
 
1558
        if remote is None:
 
1559
            if parent is None:
 
1560
                raise BzrCommandError("No missing location known or specified.")
 
1561
            else:
 
1562
                if not quiet:
 
1563
                    print "Using last location: %s" % parent
 
1564
                remote = parent
 
1565
        elif parent is None:
 
1566
            # We only update x-pull if it did not exist, missing should not change the parent
 
1567
            b.controlfile('x-pull', 'wb').write(remote + '\n')
 
1568
        br_remote = find_branch(remote)
 
1569
 
 
1570
        return show_missing(b, br_remote, verbose=verbose, quiet=quiet)
 
1571
 
 
1572
 
1517
1573
class cmd_plugins(Command):
1518
1574
    """List plugins"""
1519
1575
    hidden = True
1546
1602
    'no-recurse':             None,
1547
1603
    'profile':                None,
1548
1604
    'revision':               _parse_revision_str,
 
1605
    'short':                  None,
1549
1606
    'show-ids':               None,
1550
1607
    'timezone':               str,
1551
1608
    'verbose':                None,