~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-30 17:25:27 UTC
  • mto: (1711.4.39 win32-accepted)
  • mto: This revision was merged to the branch mainline in revision 1836.
  • Revision ID: john@arbash-meinel.com-20060630172527-6d36c06a13dc7110
always close files, minor PEP8 cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
842
842
 
843
843
class Diff3Merger(Merge3Merger):
844
844
    """Three-way merger using external diff3 for text merging"""
 
845
 
845
846
    def dump_file(self, temp_dir, name, tree, file_id):
846
847
        out_path = pathjoin(temp_dir, name)
847
 
        out_file = file(out_path, "wb")
848
 
        in_file = tree.get_file(file_id)
849
 
        for line in in_file:
850
 
            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()
851
855
        return out_path
852
856
 
853
857
    def text_merge(self, file_id, trans_id):
865
869
            status = bzrlib.patch.diff3(new_file, this, base, other)
866
870
            if status not in (0, 1):
867
871
                raise BzrError("Unhandled diff3 exit code")
868
 
            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()
869
877
            if status == 1:
870
878
                name = self.tt.final_name(trans_id)
871
879
                parent_id = self.tt.final_parent(trans_id)