~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2006-04-16 16:20:46 UTC
  • mto: This revision was merged to the branch mainline in revision 1673.
  • Revision ID: aaron.bentley@utoronto.ca-20060416162046-a50698189b032755
Handle binary files for diff3 merges

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                           UnrelatedBranches,
36
36
                           UnsupportedOperation,
37
37
                           WorkingTreeNotRevision,
 
38
                           BinaryFile,
38
39
                           )
39
40
from bzrlib.merge3 import Merge3
40
41
import bzrlib.osutils
517
518
            else:
518
519
                contents = None
519
520
            return kind, contents
 
521
 
 
522
        def contents_conflict():
 
523
            trans_id = self.tt.trans_id_file_id(file_id)
 
524
            name = self.tt.final_name(trans_id)
 
525
            parent_id = self.tt.final_parent(trans_id)
 
526
            if file_id in self.this_tree.inventory:
 
527
                self.tt.unversion_file(trans_id)
 
528
                self.tt.delete_contents(trans_id)
 
529
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
530
                                              set_version=True)
 
531
            self._raw_conflicts.append(('contents conflict', file_group))
 
532
 
520
533
        # See SPOT run.  run, SPOT, run.
521
534
        # So we're not QUITE repeating ourselves; we do tricky things with
522
535
        # file kind...
553
566
                # THIS and OTHER are both files, so text merge.  Either
554
567
                # BASE is a file, or both converted to files, so at least we
555
568
                # have agreement that output should be a file.
 
569
                try:
 
570
                    self.text_merge(file_id, trans_id)
 
571
                except BinaryFile:
 
572
                    return contents_conflict()
556
573
                if file_id not in self.this_tree.inventory:
557
574
                    self.tt.version_file(file_id, trans_id)
558
 
                self.text_merge(file_id, trans_id)
559
575
                try:
560
576
                    self.tt.tree_kind(trans_id)
561
577
                    self.tt.delete_contents(trans_id)
564
580
                return "modified"
565
581
            else:
566
582
                # Scalar conflict, can't text merge.  Dump conflicts
567
 
                trans_id = self.tt.trans_id_file_id(file_id)
568
 
                name = self.tt.final_name(trans_id)
569
 
                parent_id = self.tt.final_parent(trans_id)
570
 
                if file_id in self.this_tree.inventory:
571
 
                    self.tt.unversion_file(trans_id)
572
 
                    self.tt.delete_contents(trans_id)
573
 
                file_group = self._dump_conflicts(name, parent_id, file_id, 
574
 
                                                  set_version=True)
575
 
                self._raw_conflicts.append(('contents conflict', file_group))
 
583
                return contents_conflict()
576
584
 
577
585
    def get_lines(self, tree, file_id):
578
586
        """Return the lines in a file, or an empty list."""