~james-page/merge-o-matic/ubuntu-opnestack

« back to all changes in this revision

Viewing changes to produce-merges.py

  • Committer: Colin Watson
  • Date: 2016-11-18 21:42:52 UTC
  • Revision ID: cjwatson@canonical.com-20161118214252-tdd66o1pxu10wuji
Encapsulate atomic file writing in an AtomicFile context manager.

Show diffs side-by-side

added added

removed removed

Lines of Context:
716
716
    changelog_file = "%s/debian/changelog" % merged_dir
717
717
 
718
718
    with open(changelog_file) as changelog:
719
 
        with open(changelog_file + ".new", "w") as new_changelog:
 
719
        with tree.AtomicFile(changelog_file) as new_changelog:
720
720
            print("%s (%s) UNRELEASED; urgency=low"
721
721
                  % (package, merged_version), file=new_changelog)
722
722
            print(file=new_changelog)
731
731
            for line in changelog:
732
732
                print(line.rstrip("\r\n"), file=new_changelog)
733
733
 
734
 
    os.rename(changelog_file + ".new", changelog_file)
735
 
 
736
734
def copy_in(output_dir, source, distro=None):
737
735
    """Make a copy of the source files."""
738
736
    for _, name in files(source):