~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: 2006-02-28 04:35:06 UTC
  • mfrom: (1551.2.15 Aaron's small fixes)
  • Revision ID: pqm@pqm.ubuntu.com-20060228043506-6627101e946abb2d
Fix diff support of checkouts

Show diffs side-by-side

added added

removed removed

Lines of Context:
851
851
 
852
852
    @display_command
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
855
855
        try:
856
 
            tree, file_list = internal_tree_files(file_list)
 
856
            tree1, file_list = internal_tree_files(file_list)
 
857
            tree2 = None
857
858
            b = None
858
859
            b2 = None
859
860
        except FileInWrongBranch:
860
861
            if len(file_list) != 2:
861
862
                raise BzrCommandError("Files are in different branches")
862
863
 
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")
868
869
            file_list = None
869
870
        if revision is not None:
870
 
            if b2 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
                                       revision[0])
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])
879
879
            else:
880
880
                raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
881
881
        else:
882
 
            if b is not None:
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)
885
886
            else:
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)
888
888
 
889
889
 
890
890
class cmd_deleted(Command):