~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:00:35 UTC
  • Revision ID: mbp@sourcefrog.net-20050624090035-cd6b439eb1b6068c
- append to branch revision history using AtomicFile

Show diffs side-by-side

added added

removed removed

Lines of Context:
521
521
 
522
522
 
523
523
    def append_revision(self, revision_id):
 
524
        from bzrlib.atomicfile import AtomicFile
 
525
 
524
526
        mutter("add {%s} to revision-history" % revision_id)
525
 
        rev_history = self.revision_history()
526
 
 
527
 
        tmprhname = self.controlfilename('revision-history.tmp')
528
 
        rhname = self.controlfilename('revision-history')
529
 
        
530
 
        f = file(tmprhname, 'wt')
531
 
        rev_history.append(revision_id)
532
 
        f.write('\n'.join(rev_history))
533
 
        f.write('\n')
534
 
        f.close()
535
 
 
536
 
        if sys.platform == 'win32':
537
 
            os.remove(rhname)
538
 
        os.rename(tmprhname, rhname)
539
 
        
 
527
        rev_history = self.revision_history() + [revision_id]
 
528
 
 
529
        f = AtomicFile(self.controlfilename('revision-history'))
 
530
        try:
 
531
            for rev_id in rev_history:
 
532
                print >>f, rev_id
 
533
            f.commit()
 
534
        finally:
 
535
            f.close()
540
536
 
541
537
 
542
538
    def get_revision(self, revision_id):