853
853
def run(self, revision=None, file_list=None, diff_options=None):
854
from bzrlib.diff import show_diff
854
from bzrlib.diff import diff_cmd_helper, show_diff_trees
856
tree, file_list = internal_tree_files(file_list)
856
tree1, file_list = internal_tree_files(file_list)
859
860
except FileInWrongBranch:
860
861
if len(file_list) != 2:
861
862
raise BzrCommandError("Files are in different branches")
863
b, file1 = Branch.open_containing(file_list[0])
864
b2, file2 = Branch.open_containing(file_list[1])
864
tree1, file1 = WorkingTree.open_containing(file_list[0])
865
tree2, file2 = WorkingTree.open_containing(file_list[1])
865
866
if file1 != "" or file2 != "":
866
867
# FIXME diff those two files. rbc 20051123
867
868
raise BzrCommandError("Files are in different branches")
869
870
if revision is not None:
871
if tree2 is not None:
871
872
raise BzrCommandError("Can't specify -r with two branches")
872
873
if (len(revision) == 1) or (revision[1].spec is None):
873
return show_diff(tree.branch, revision[0], specific_files=file_list,
874
external_diff_options=diff_options)
874
return diff_cmd_helper(tree1, file_list, diff_options,
875
876
elif len(revision) == 2:
876
return show_diff(tree.branch, revision[0], specific_files=file_list,
877
external_diff_options=diff_options,
878
revision2=revision[1])
877
return diff_cmd_helper(tree1, file_list, diff_options,
878
revision[0], revision[1])
880
880
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
883
return show_diff(b, None, specific_files=file_list,
884
external_diff_options=diff_options, b2=b2)
882
if tree2 is not None:
883
return show_diff_trees(tree1, tree2, sys.stdout,
884
specific_files=file_list,
885
external_diff_options=diff_options)
886
return show_diff(tree.branch, None, specific_files=file_list,
887
external_diff_options=diff_options)
887
return diff_cmd_helper(tree1, file_list, diff_options)
890
890
class cmd_deleted(Command):