~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

Merge cleanup into texinfo

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import difflib
18
18
import os
19
19
import re
20
 
import shutil
21
20
import string
22
21
import sys
23
22
 
100
99
    if sequence_matcher is None:
101
100
        sequence_matcher = patiencediff.PatienceSequenceMatcher
102
101
    ud = patiencediff.unified_diff(oldlines, newlines,
103
 
                      fromfile=old_filename.encode(path_encoding),
104
 
                      tofile=new_filename.encode(path_encoding),
 
102
                      fromfile=old_filename.encode(path_encoding, 'replace'),
 
103
                      tofile=new_filename.encode(path_encoding, 'replace'),
105
104
                      sequencematcher=sequence_matcher)
106
105
 
107
106
    ud = list(ud)
707
706
        """
708
707
        def _get_text(tree, file_id, path):
709
708
            if file_id is not None:
710
 
                return tree.get_file(file_id, path).readlines()
 
709
                return tree.get_file_lines(file_id, path)
711
710
            else:
712
711
                return []
713
712
        try:
714
713
            from_text = _get_text(self.old_tree, from_file_id, from_path)
715
714
            to_text = _get_text(self.new_tree, to_file_id, to_path)
716
715
            self.text_differ(from_label, from_text, to_label, to_text,
717
 
                             self.to_file)
 
716
                             self.to_file, path_encoding=self.path_encoding)
718
717
        except errors.BinaryFile:
719
718
            self.to_file.write(
720
719
                  ("Binary files %s and %s differ\n" %
721
 
                  (from_label, to_label)).encode(self.path_encoding))
 
720
                  (from_label, to_label)).encode(self.path_encoding,'replace'))
722
721
        return self.CHANGED
723
722
 
724
723
 
921
920
            extra_factories = []
922
921
        if external_diff_options:
923
922
            opts = external_diff_options.split()
924
 
            def diff_file(olab, olines, nlab, nlines, to_file):
 
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
                """
925
927
                external_diff(olab, olines, nlab, nlines, to_file, opts)
926
928
        else:
927
929
            diff_file = internal_diff