~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-19 08:42:39 UTC
  • mfrom: (1558.15.11 bzr.binaries)
  • Revision ID: pqm@pqm.ubuntu.com-20060419084239-730ca2dccc3bea14
diff and merge handle binaries safely

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
            if reverse:
 
589
                label_pair = (to_label, from_label)
 
590
            else:
 
591
                label_pair = (from_label, to_label)
 
592
            print >> output_to, "Binary files %s and %s differ" % label_pair
586
593
 
587
594
    def has_text(self):
588
595
        """See InventoryEntry.has_text."""