~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-03 13:56:48 UTC
  • mfrom: (1711.4.41 win32-accepted)
  • Revision ID: pqm@pqm.ubuntu.com-20060703135648-b927e5efb9f5b907
(jam) cleanup for win32, close open file handles, tests pass

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
        name = self._limbo_name(trans_id)
 
263
        f = open(name, 'wb')
 
264
        try:
 
265
            try:
 
266
                unique_add(self._new_contents, trans_id, 'file')
 
267
            except:
 
268
                # Clean up the file, it never got registered so
 
269
                # TreeTransform.finalize() won't clean it up.
 
270
                f.close()
 
271
                os.unlink(name)
 
272
                raise
 
273
 
 
274
            for segment in contents:
 
275
                f.write(segment)
 
276
        finally:
 
277
            f.close()
267
278
        self._set_mode(trans_id, mode_id, S_ISREG)
268
279
 
269
280
    def _set_mode(self, trans_id, mode_id, typefunc):