~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Joe Julian
  • Date: 2010-01-10 02:25:31 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: joe@julianfamily.org-20100110022531-wqk61rsagz8xsiga
Added MANIFEST.in to allow bdist_rpm to have all the required include files and tools. bdist_rpm will still fail to build correctly on some distributions due to a disttools bug http://bugs.python.org/issue644744

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
 
172
172
        if not diff_opts:
173
173
            diff_opts = []
 
174
        if sys.platform == 'win32':
 
175
            # Popen doesn't do the proper encoding for external commands
 
176
            # Since we are dealing with an ANSI api, use mbcs encoding
 
177
            old_filename = old_filename.encode('mbcs')
 
178
            new_filename = new_filename.encode('mbcs')
174
179
        diffcmd = ['diff',
175
180
                   '--label', old_filename,
176
181
                   old_abspath,
367
372
            if view_files:
368
373
                specific_files = view_files
369
374
                view_str = views.view_display_str(view_files)
370
 
                note("*** ignoring files outside view: %s" % view_str)
 
375
                note("*** Ignoring files outside view. View is %s" % view_str)
371
376
 
372
377
    # Get extra trees that ought to be searched for file-ids
373
378
    extra_trees = None
620
625
            return self.CANNOT_DIFF
621
626
        from_label = '%s%s\t%s' % (self.old_label, old_path, old_date)
622
627
        to_label = '%s%s\t%s' % (self.new_label, new_path, new_date)
623
 
        return self.diff_text(from_file_id, to_file_id, from_label, to_label)
 
628
        return self.diff_text(from_file_id, to_file_id, from_label, to_label,
 
629
            old_path, new_path)
624
630
 
625
 
    def diff_text(self, from_file_id, to_file_id, from_label, to_label):
 
631
    def diff_text(self, from_file_id, to_file_id, from_label, to_label,
 
632
        from_path=None, to_path=None):
626
633
        """Diff the content of given files in two trees
627
634
 
628
635
        :param from_file_id: The id of the file in the from tree.  If None,
630
637
        :param to_file_id: The id of the file in the to tree.  This may refer
631
638
            to a different file from from_file_id.  If None,
632
639
            the file is not present in the to tree.
 
640
        :param from_path: The path in the from tree or None if unknown.
 
641
        :param to_path: The path in the to tree or None if unknown.
633
642
        """
634
 
        def _get_text(tree, file_id):
 
643
        def _get_text(tree, file_id, path):
635
644
            if file_id is not None:
636
 
                return tree.get_file(file_id).readlines()
 
645
                return tree.get_file(file_id, path).readlines()
637
646
            else:
638
647
                return []
639
648
        try:
640
 
            from_text = _get_text(self.old_tree, from_file_id)
641
 
            to_text = _get_text(self.new_tree, to_file_id)
 
649
            from_text = _get_text(self.old_tree, from_file_id, from_path)
 
650
            to_text = _get_text(self.new_tree, to_file_id, to_path)
642
651
            self.text_differ(from_label, from_text, to_label, to_text,
643
652
                             self.to_file)
644
653
        except errors.BinaryFile:
731
740
        return old_disk_path, new_disk_path
732
741
 
733
742
    def finish(self):
734
 
        osutils.rmtree(self._root)
 
743
        try:
 
744
            osutils.rmtree(self._root)
 
745
        except OSError, e:
 
746
            if e.errno != errno.ENOENT:
 
747
                mutter("The temporary directory \"%s\" was not "
 
748
                        "cleanly removed: %s." % (self._root, e))
735
749
 
736
750
    def diff(self, file_id, old_path, new_path, old_kind, new_kind):
737
751
        if (old_kind, new_kind) != ('file', 'file'):
882
896
                self.to_file.write("=== modified %s '%s'%s\n" % (kind[0],
883
897
                                   newpath_encoded, prop_str))
884
898
            if changed_content:
885
 
                self.diff(file_id, oldpath, newpath)
 
899
                self._diff(file_id, oldpath, newpath, kind[0], kind[1])
886
900
                has_changes = 1
887
901
            if renamed:
888
902
                has_changes = 1
903
917
            new_kind = self.new_tree.kind(file_id)
904
918
        except (errors.NoSuchId, errors.NoSuchFile):
905
919
            new_kind = None
906
 
 
 
920
        self._diff(file_id, old_path, new_path, old_kind, new_kind)
 
921
 
 
922
 
 
923
    def _diff(self, file_id, old_path, new_path, old_kind, new_kind):
907
924
        result = DiffPath._diff_many(self.differs, file_id, old_path,
908
925
                                       new_path, old_kind, new_kind)
909
926
        if result is DiffPath.CANNOT_DIFF: