~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Martin Pool
  • Date: 2010-06-02 05:03:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5279.
  • Revision ID: mbp@canonical.com-20100602050331-n2p1qt8hfsahspnv
Correct more sloppy use of the term 'Linux'

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
    if sequence_matcher is None:
100
100
        sequence_matcher = patiencediff.PatienceSequenceMatcher
101
101
    ud = patiencediff.unified_diff(oldlines, newlines,
102
 
                      fromfile=old_filename.encode(path_encoding, 'replace'),
103
 
                      tofile=new_filename.encode(path_encoding, 'replace'),
 
102
                      fromfile=old_filename.encode(path_encoding),
 
103
                      tofile=new_filename.encode(path_encoding),
104
104
                      sequencematcher=sequence_matcher)
105
105
 
106
106
    ud = list(ud)
420
420
 
421
421
    # Get the specific files (all files is None, no files is [])
422
422
    if make_paths_wt_relative and working_tree is not None:
423
 
        other_paths = working_tree.safe_relpath_files(
424
 
            other_paths,
 
423
        try:
 
424
            from bzrlib.builtins import safe_relpath_files
 
425
            other_paths = safe_relpath_files(working_tree, other_paths,
425
426
            apply_view=apply_view)
 
427
        except errors.FileInWrongBranch:
 
428
            raise errors.BzrCommandError("Files are in different branches")
426
429
    specific_files.extend(other_paths)
427
430
    if len(specific_files) == 0:
428
431
        specific_files = None
710
713
            from_text = _get_text(self.old_tree, from_file_id, from_path)
711
714
            to_text = _get_text(self.new_tree, to_file_id, to_path)
712
715
            self.text_differ(from_label, from_text, to_label, to_text,
713
 
                             self.to_file, path_encoding=self.path_encoding)
 
716
                             self.to_file)
714
717
        except errors.BinaryFile:
715
718
            self.to_file.write(
716
719
                  ("Binary files %s and %s differ\n" %
717
 
                  (from_label, to_label)).encode(self.path_encoding,'replace'))
 
720
                  (from_label, to_label)).encode(self.path_encoding))
718
721
        return self.CHANGED
719
722
 
720
723
 
736
739
                     path_encoding)
737
740
 
738
741
    @classmethod
739
 
    def make_from_diff_tree(klass, command_string, external_diff_options=None):
 
742
    def make_from_diff_tree(klass, command_string):
740
743
        def from_diff_tree(diff_tree):
741
 
            full_command_string = [command_string]
742
 
            if external_diff_options is not None:
743
 
                full_command_string += ' ' + external_diff_options
744
 
            return klass.from_string(full_command_string, diff_tree.old_tree,
 
744
            return klass.from_string(command_string, diff_tree.old_tree,
745
745
                                     diff_tree.new_tree, diff_tree.to_file)
746
746
        return from_diff_tree
747
747
 
915
915
        :param using: Commandline to use to invoke an external diff tool
916
916
        """
917
917
        if using is not None:
918
 
            extra_factories = [DiffFromTool.make_from_diff_tree(using, external_diff_options)]
 
918
            extra_factories = [DiffFromTool.make_from_diff_tree(using)]
919
919
        else:
920
920
            extra_factories = []
921
921
        if external_diff_options:
922
922
            opts = external_diff_options.split()
923
 
            def diff_file(olab, olines, nlab, nlines, to_file, path_encoding=None):
924
 
                """:param path_encoding: not used but required
925
 
                        to match the signature of internal_diff.
926
 
                """
 
923
            def diff_file(olab, olines, nlab, nlines, to_file):
927
924
                external_diff(olab, olines, nlab, nlines, to_file, opts)
928
925
        else:
929
926
            diff_file = internal_diff