/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-29 20:46:29 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-20060629204629-28d58b0591966eea
Use try/finally inside create_file for TreeTransform to ensure the file handle gets closed

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
        New file takes the permissions of any existing file with that id,
260
260
        unless mode_id is specified.
261
261
        """
262
 
        f = file(self._limbo_name(trans_id), 'wb')
263
 
        unique_add(self._new_contents, trans_id, 'file')
264
 
        for segment in contents:
265
 
            f.write(segment)
266
 
        f.close()
 
262
        f = open(self._limbo_name(trans_id), 'wb')
 
263
        try:
 
264
            unique_add(self._new_contents, trans_id, 'file')
 
265
            for segment in contents:
 
266
                f.write(segment)
 
267
        finally:
 
268
            f.close()
267
269
        self._set_mode(trans_id, mode_id, S_ISREG)
268
270
 
269
271
    def _set_mode(self, trans_id, mode_id, typefunc):