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

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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
703
706
        """
704
707
        def _get_text(tree, file_id, path):
705
708
            if file_id is not None:
706
 
                return tree.get_file_lines(file_id, path)
 
709
                return tree.get_file(file_id, path).readlines()
707
710
            else:
708
711
                return []
709
712
        try:
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
 
917
920
            extra_factories = []
918
921
        if external_diff_options:
919
922
            opts = external_diff_options.split()
920
 
            def diff_file(olab, olines, nlab, nlines, to_file, path_encoding=None):
921
 
                """:param path_encoding: not used but required
922
 
                        to match the signature of internal_diff.
923
 
                """
 
923
            def diff_file(olab, olines, nlab, nlines, to_file):
924
924
                external_diff(olab, olines, nlab, nlines, to_file, opts)
925
925
        else:
926
926
            diff_file = internal_diff