~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Johan Walles
  • Date: 2009-05-06 05:36:28 UTC
  • mfrom: (4332 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4343.
  • Revision ID: johan.walles@gmail.com-20090506053628-tbf1wz4a0m9t684g
MergeĀ fromĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
620
620
            return self.CANNOT_DIFF
621
621
        from_label = '%s%s\t%s' % (self.old_label, old_path, old_date)
622
622
        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,
624
 
            old_path, new_path)
 
623
        return self.diff_text(from_file_id, to_file_id, from_label, to_label)
625
624
 
626
 
    def diff_text(self, from_file_id, to_file_id, from_label, to_label,
627
 
        from_path=None, to_path=None):
 
625
    def diff_text(self, from_file_id, to_file_id, from_label, to_label):
628
626
        """Diff the content of given files in two trees
629
627
 
630
628
        :param from_file_id: The id of the file in the from tree.  If None,
632
630
        :param to_file_id: The id of the file in the to tree.  This may refer
633
631
            to a different file from from_file_id.  If None,
634
632
            the file is not present in the to tree.
635
 
        :param from_path: The path in the from tree or None if unknown.
636
 
        :param to_path: The path in the to tree or None if unknown.
637
633
        """
638
 
        def _get_text(tree, file_id, path):
 
634
        def _get_text(tree, file_id):
639
635
            if file_id is not None:
640
 
                return tree.get_file(file_id, path).readlines()
 
636
                return tree.get_file(file_id).readlines()
641
637
            else:
642
638
                return []
643
639
        try:
644
 
            from_text = _get_text(self.old_tree, from_file_id, from_path)
645
 
            to_text = _get_text(self.new_tree, to_file_id, to_path)
 
640
            from_text = _get_text(self.old_tree, from_file_id)
 
641
            to_text = _get_text(self.new_tree, to_file_id)
646
642
            self.text_differ(from_label, from_text, to_label, to_text,
647
643
                             self.to_file)
648
644
        except errors.BinaryFile:
886
882
                self.to_file.write("=== modified %s '%s'%s\n" % (kind[0],
887
883
                                   newpath_encoded, prop_str))
888
884
            if changed_content:
889
 
                self._diff(file_id, oldpath, newpath, kind[0], kind[1])
 
885
                self.diff(file_id, oldpath, newpath)
890
886
                has_changes = 1
891
887
            if renamed:
892
888
                has_changes = 1
907
903
            new_kind = self.new_tree.kind(file_id)
908
904
        except (errors.NoSuchId, errors.NoSuchFile):
909
905
            new_kind = None
910
 
        self._diff(file_id, old_path, new_path, old_kind, new_kind)
911
 
 
912
 
 
913
 
    def _diff(self, file_id, old_path, new_path, old_kind, new_kind):
 
906
 
914
907
        result = DiffPath._diff_many(self.differs, file_id, old_path,
915
908
                                       new_path, old_kind, new_kind)
916
909
        if result is DiffPath.CANNOT_DIFF: