~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-06-24 09:03:20 UTC
  • Revision ID: mbp@sourcefrog.net-20050624090320-c34ea3e5aa81d01d
- write new working inventory using AtomicFile

Show diffs side-by-side

added added

removed removed

Lines of Context:
338
338
        That is to say, the inventory describing changes underway, that
339
339
        will be committed to the next revision.
340
340
        """
341
 
        ## TODO: factor out to atomicfile?  is rename safe on windows?
342
 
        ## TODO: Maybe some kind of clean/dirty marker on inventory?
343
 
        tmpfname = self.controlfilename('inventory.tmp')
344
 
        tmpf = file(tmpfname, 'wb')
345
 
        inv.write_xml(tmpf)
346
 
        tmpf.close()
347
 
        inv_fname = self.controlfilename('inventory')
348
 
        if sys.platform == 'win32':
349
 
            os.remove(inv_fname)
350
 
        os.rename(tmpfname, inv_fname)
 
341
        self.lock_write()
 
342
        try:
 
343
            from bzrlib.atomicfile import AtomicFile
 
344
 
 
345
            f = AtomicFile(self.controlfilename('inventory'), 'wb')
 
346
            try:
 
347
                inv.write_xml(f)
 
348
                f.commit()
 
349
            finally:
 
350
                f.close()
 
351
        finally:
 
352
            self.unlock()
 
353
        
351
354
        mutter('wrote working inventory')
352
355
            
353
356