~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Aaron Bentley
  • Date: 2006-04-16 15:52:29 UTC
  • mto: This revision was merged to the branch mainline in revision 1673.
  • Revision ID: aaron.bentley@utoronto.ca-20060416155229-dd8b35cdc5d134ce
Implemented binary file handling for diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
import bzrlib
38
38
from bzrlib.osutils import (pumpfile, quotefn, splitpath, joinpath,
39
39
                            pathjoin, sha_strings)
 
40
from bzrlib.errors import (NotVersionedError, InvalidEntryName,
 
41
                           BzrError, BzrCheckError, BinaryFile)
40
42
from bzrlib.trace import mutter
41
 
from bzrlib.errors import (NotVersionedError, InvalidEntryName,
42
 
                           BzrError, BzrCheckError)
43
43
 
44
44
 
45
45
class InventoryEntry(object):
572
572
    def _diff(self, text_diff, from_label, tree, to_label, to_entry, to_tree,
573
573
             output_to, reverse=False):
574
574
        """See InventoryEntry._diff."""
575
 
        from_text = tree.get_file(self.file_id).readlines()
576
 
        if to_entry:
577
 
            to_text = to_tree.get_file(to_entry.file_id).readlines()
578
 
        else:
579
 
            to_text = []
580
 
        if not reverse:
581
 
            text_diff(from_label, from_text,
582
 
                      to_label, to_text, output_to)
583
 
        else:
584
 
            text_diff(to_label, to_text,
585
 
                      from_label, from_text, output_to)
 
575
        try:
 
576
            from_text = tree.get_file(self.file_id).readlines()
 
577
            if to_entry:
 
578
                to_text = to_tree.get_file(to_entry.file_id).readlines()
 
579
            else:
 
580
                to_text = []
 
581
            if not reverse:
 
582
                text_diff(from_label, from_text,
 
583
                          to_label, to_text, output_to)
 
584
            else:
 
585
                text_diff(to_label, to_text,
 
586
                          from_label, from_text, output_to)
 
587
        except BinaryFile:
 
588
            print >> output_to, "Binary files differ"
586
589
 
587
590
    def has_text(self):
588
591
        """See InventoryEntry.has_text."""