def _resolve_existing_entry(self, changelog_path): # When this is called, the top entry in the ChangeLog was just created # by prepare-ChangeLog, as an clean updated version of the one below it. with self._tool.filesystem.open_text_file_for_reading(changelog_path) as changelog_file: entries_gen = ChangeLog.parse_entries_from_file(changelog_file) entries = zip(entries_gen, range(2)) if not len(entries): raise Exception("Expected to find at least two ChangeLog entries in %s but found none." % changelog_path) if len(entries) == 1: # If we get here, it probably means we've just rolled over to a # new CL file, so we don't have anything to resolve. return (new_entry, _), (old_entry, _) = entries final_entry = self._merge_entries(old_entry, new_entry) changelog = ChangeLog(changelog_path, self._tool.filesystem) changelog.delete_entries(2) changelog.prepend_text(final_entry)