/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/builtins.py

  • Committer: Martin Pool
  • Date: 2006-04-28 09:35:20 UTC
  • mto: This revision was merged to the branch mainline in revision 1690.
  • Revision ID: mbp@sourcefrog.net-20060428093520-facdfa15d5007057
(patch) --diff-prefix option (goffredo, alexander)

Show diffs side-by-side

added added

removed removed

Lines of Context:
997
997
    # TODO: This probably handles non-Unix newlines poorly.
998
998
    
999
999
    takes_args = ['file*']
1000
 
    takes_options = ['revision', 'diff-options']
 
1000
    takes_options = ['revision', 'diff-options', 'diff-prefix']
1001
1001
    aliases = ['di', 'dif']
1002
1002
 
1003
1003
    @display_command
1004
 
    def run(self, revision=None, file_list=None, diff_options=None):
 
1004
    def run(self, revision=None, file_list=None, diff_options=None,
 
1005
       diff_prefix=None):
1005
1006
        from bzrlib.diff import diff_cmd_helper, show_diff_trees
 
1007
 
 
1008
        if diff_prefix:
 
1009
            if not ':' in diff_prefix:
 
1010
                 raise BzrError("--diff-prefix expects two values separated by a colon")            
 
1011
            old_label,new_label=diff_prefix.split(":")
 
1012
        else:
 
1013
            old_label='a/'
 
1014
            new_label='b/'
 
1015
        
1006
1016
        try:
1007
1017
            tree1, file_list = internal_tree_files(file_list)
1008
1018
            tree2 = None
1023
1033
                raise BzrCommandError("Can't specify -r with two branches")
1024
1034
            if (len(revision) == 1) or (revision[1].spec is None):
1025
1035
                return diff_cmd_helper(tree1, file_list, diff_options,
1026
 
                                       revision[0])
 
1036
                                       revision[0], 
 
1037
                                       old_label=old_label, new_label=new_label)
1027
1038
            elif len(revision) == 2:
1028
1039
                return diff_cmd_helper(tree1, file_list, diff_options,
1029
 
                                       revision[0], revision[1])
 
1040
                                       revision[0], revision[1],
 
1041
                                       old_label=old_label, new_label=new_label)
1030
1042
            else:
1031
1043
                raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
1032
1044
        else:
1033
1045
            if tree2 is not None:
1034
1046
                return show_diff_trees(tree1, tree2, sys.stdout, 
1035
1047
                                       specific_files=file_list,
1036
 
                                       external_diff_options=diff_options)
 
1048
                                       external_diff_options=diff_options,
 
1049
                                       old_label=old_label, new_label=new_label)
1037
1050
            else:
1038
 
                return diff_cmd_helper(tree1, file_list, diff_options)
 
1051
                return diff_cmd_helper(tree1, file_list, diff_options,
 
1052
                                       old_label=old_label, new_label=new_label)
1039
1053
 
1040
1054
 
1041
1055
class cmd_deleted(Command):