def check_merge(master, new, expected): master_doc = minidom.parseString(header + master + footer) new_doc = minidom.parseString(header + new + footer) merge.merge(master_doc, new_doc) expected_doc = minidom.parseString(header + expected + footer) def remove_boring(doc): for node in list(doc.documentElement.childNodes): if node.localName in ('name', 'summary', 'description'): doc.documentElement.removeChild(node) remove_boring(master_doc) remove_boring(expected_doc) formatting.format_node(master_doc.documentElement, "\n") formatting.format_node(expected_doc.documentElement, "\n") master_doc.normalize() expected_doc.normalize() if xmltools.nodes_equal(master_doc.documentElement, expected_doc.documentElement): return actual = master_doc.documentElement.toxml() expected = expected_doc.documentElement.toxml() assert actual != expected raise Exception("Failed.\n\nExpected:\n{}\nActual:\n{}".format(expected, actual))
def check_merge(master, new, expected): master_doc = minidom.parseString(header + master + footer) new_doc = minidom.parseString(header + new + footer) merge.merge(master_doc, new_doc) expected_doc = minidom.parseString(header + expected + footer) def remove_boring(doc): for node in list(doc.documentElement.childNodes): if node.localName in ('name', 'summary', 'description'): doc.documentElement.removeChild(node) remove_boring(master_doc) remove_boring(expected_doc) formatting.format_node(master_doc.documentElement, "\n") formatting.format_node(expected_doc.documentElement, "\n") master_doc.normalize() expected_doc.normalize() if xmltools.nodes_equal(master_doc.documentElement, expected_doc.documentElement): return actual = master_doc.documentElement.toxml() expected = expected_doc.documentElement.toxml() assert actual != expected raise Exception("Failed.\n\nExpected:\n{}\nActual:\n{}".format( expected, actual))
def do_merge(master_xml, new_impl_path): # The tests were originally written for 0publish. This just adapts them to the new API. master_doc = minidom.parse(ByteIO(master_xml)) with open(new_impl_path, 'rb') as stream: new_impl_doc = minidom.parse(stream) merge.merge(master_doc, new_impl_doc) return master_doc.toxml(encoding = 'utf-8')
def do_merge(master_xml, new_impl_path): # The tests were originally written for 0publish. This just adapts them to the new API. master_doc = minidom.parse(ByteIO(master_xml)) with open(new_impl_path, 'rb') as stream: new_impl_doc = minidom.parse(stream) merge.merge(master_doc, new_impl_doc) return master_doc.toxml(encoding='utf-8')
def accept_and_publish(archive_file, src_feed_name): if status.tagged: print "Already tagged in SCM. Not re-tagging." else: scm.ensure_committed() head = scm.get_head_revision() if head != status.head_before_release: raise SafeException("Changes committed since we started!\n" + "HEAD was " + status.head_before_release + "\n" "HEAD now " + head) scm.tag(status.release_version, status.head_at_release) scm.reset_hard(TMP_BRANCH_NAME) scm.delete_branch(TMP_BRANCH_NAME) status.tagged = 'true' status.save() assert len(local_feed.feed_for) == 1 # Merge the source and binary feeds together first, so # that we update the master feed atomically and only # have to sign it once. with open(src_feed_name, 'rb') as stream: doc = minidom.parse(stream) for b in compiler.get_binary_feeds(): with open(b, 'rb') as stream: bin_doc = minidom.parse(b) merge.merge(doc, bin_doc) new_impls_feed = 'merged.xml' with open(new_impls_feed, 'wb') as stream: doc.writexml(stream) # TODO: support uploading to a sub-feed (requires support in 0repo too) master_feed, = local_feed.feed_for repository = registry.lookup(master_feed, missing_ok = True) if repository: release_via_0repo(new_impls_feed) else: release_without_0repo(archive_file, new_impls_feed) os.unlink(new_impls_feed) print "Push changes to public SCM repository..." public_repos = options.public_scm_repository if public_repos: scm.push_head_and_release(status.release_version) else: print "NOTE: No public repository set => you'll have to push the tag and trunk yourself." os.unlink(support.release_status_file)