~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-03 16:19:30 UTC
  • mfrom: (1836 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1851.
  • Revision ID: john@arbash-meinel.com-20060703161930-c373bd7eddd73011
[merge] bzr.dev 1836

Show diffs side-by-side

added added

removed removed

Lines of Context:
390
390
            results = self.tt.apply()
391
391
            self.write_modified(results)
392
392
            try:
393
 
                working_tree.set_conflicts(ConflictList(self.cooked_conflicts))
 
393
                working_tree.add_conflicts(self.cooked_conflicts)
394
394
            except UnsupportedOperation:
395
395
                pass
396
396
        finally:
397
 
            try:
398
 
                self.tt.finalize()
399
 
            except:
400
 
                pass
 
397
            self.tt.finalize()
401
398
            working_tree.unlock()
402
399
            self.pb.clear()
403
400
 
845
842
 
846
843
class Diff3Merger(Merge3Merger):
847
844
    """Three-way merger using external diff3 for text merging"""
 
845
 
848
846
    def dump_file(self, temp_dir, name, tree, file_id):
849
847
        out_path = pathjoin(temp_dir, name)
850
 
        out_file = file(out_path, "wb")
851
 
        in_file = tree.get_file(file_id)
852
 
        for line in in_file:
853
 
            out_file.write(line)
 
848
        out_file = open(out_path, "wb")
 
849
        try:
 
850
            in_file = tree.get_file(file_id)
 
851
            for line in in_file:
 
852
                out_file.write(line)
 
853
        finally:
 
854
            out_file.close()
854
855
        return out_path
855
856
 
856
857
    def text_merge(self, file_id, trans_id):
868
869
            status = bzrlib.patch.diff3(new_file, this, base, other)
869
870
            if status not in (0, 1):
870
871
                raise BzrError("Unhandled diff3 exit code")
871
 
            self.tt.create_file(file(new_file, "rb"), trans_id)
 
872
            f = open(new_file, 'rb')
 
873
            try:
 
874
                self.tt.create_file(f, trans_id)
 
875
            finally:
 
876
                f.close()
872
877
            if status == 1:
873
878
                name = self.tt.final_name(trans_id)
874
879
                parent_id = self.tt.final_parent(trans_id)