~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-09 07:14:22 UTC
  • Revision ID: mbp@sourcefrog.net-20050309071421-eb5d3514d415bc4c
write inventory to temporary file and atomically replace

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
        That is to say, the inventory describing changes underway, that
160
160
        will be committed to the next revision.
161
161
        """
162
 
        inv.write_xml(self.controlfile('inventory', 'w'))
163
 
        mutter('wrote inventory to %s' % quotefn(self.controlfilename('inventory')))
 
162
        ## TODO: factor out to atomicfile?  is rename safe on windows?
 
163
        tmpfname = self.controlfilename('inventory.tmp')
 
164
        tmpf = file(tmpfname, 'w')
 
165
        inv.write_xml(tmpf)
 
166
        tmpf.close()
 
167
        os.rename(tmpfname, self.controlfilename('inventory'))
 
168
        mutter('wrote working inventory')
164
169
 
165
170
 
166
171
    inventory = property(read_working_inventory, _write_inventory, None,