You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2014/01/24 16:08:23 UTC
svn commit: r1561031 - /manifoldcf/release-scripts/create-site-branch.py
Author: kwright
Date: Fri Jan 24 15:08:23 2014
New Revision: 1561031
URL: http://svn.apache.org/r1561031
Log:
Add incomplete release branch creation script
Added:
manifoldcf/release-scripts/create-site-branch.py (with props)
Added: manifoldcf/release-scripts/create-site-branch.py
URL: http://svn.apache.org/viewvc/manifoldcf/release-scripts/create-site-branch.py?rev=1561031&view=auto
==============================================================================
--- manifoldcf/release-scripts/create-site-branch.py (added)
+++ manifoldcf/release-scripts/create-site-branch.py Fri Jan 24 15:08:23 2014
@@ -0,0 +1,120 @@
+import sys
+import os
+import shutil
+import subprocess
+
+def svn_command(command_array):
+ """ Invoke svn command """
+ popen = subprocess.Popen(["svn"] + command_array,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out,err = popen.communicate()
+ rcode = popen.returncode
+ if rcode != 0:
+ raise Exception("svn invocation errored with code %d: %s" % (rcode,err))
+ return out
+
+def remove_dir(directory_path):
+ """ Remove a directory and all of its contents """
+ shutil.rmtree(directory_path)
+
+def add_change_file_release_row(change_file_path, release_version):
+ """ Convert the -dev row in a change file to a release row """
+ # MHL
+ pass
+
+def add_change_file_new_dev_row(change_file_path, dev_version):
+ """ Add a new -dev row to the start of a change file """
+ # MHL
+ pass
+
+def fix_pom_xml(pom_file_path, pom_version):
+ """
+ Fix primary versions in a pom file to become the specified pom_version.
+ Returns an array of child project names (NOT paths).
+ """
+ # MHL
+ return [ ]
+
+def update_poms(root_directory, pom_version):
+ """ Update all poms in a project """
+ dirs = fix_pom_xml( "%s/pom.xml" % root_directory, pom_version )
+ for dir in dirs:
+ update_poms( "%s/%s" % (root_directory, dir), pom_version )
+
+def fix_build_xml(build_file_path, build_version):
+ """ Update version number in build.xml to be the specified one. """
+ # MHL
+ pass
+
+def checkout_tree(tree_directory_path, svn_url):
+ """ Check out the specified svn tree to the specified place """
+ svn_command(["co", svn_url, tree_directory_path])
+
+def commit_tree(tree_directory_path, commit_message):
+ """ Commit the svn tree using the specified commit message """
+ svn_command([ "-m", commit_message, "commit", tree_directory_path])
+
+def create_branch(trunk_url, branch_url, branch_message):
+ """ Create a branch with the given branch message """
+ svn_command([ "-m", branch_message, "copy", trunk_url, branch_url])
+
+def create_release_branch(release_version, new_trunk_version, working_directory):
+ """ Create a release branch, and modify trunk also to reset versions """
+ # Basic checks
+ if not os.exists(working_directory):
+ raise Exception("Working directory '%s' does not appear to exist" % working_directory)
+ if release_version.index("-SNAPSHOT") >= 0 or release_version.index("-dev") >= 0:
+ raise Exception("Release version '%s' cannot contain SNAPSHOT or dev" % release_version)
+ if new_trunk_version.index("-SNAPSNOT") >= 0 or new_trunk_version.index("-dev") >= 0:
+ raise Exception("New trunk version '%s' cannot contain SNAPSHOT or dev" % new_trunk_version)
+
+ # Point to all the right places
+ trunk_url = "https://svn.apache.org/repos/asf/manifoldcf/trunk"
+ branch_url = "https://svn.apache.org/repos/asf/manifoldcf/branches/release-%s-branch" % release_version
+ trunk_dir = "%s/trunk" % working_directory
+
+ trunk_changes_file = "%s/CHANGES.txt" % trunk_dir
+ trunk_build_xml_file = "%s/build.xml" % trunk_dir
+
+ # Check out trunk.
+ checkout_tree(trunk_dir, trunk_url)
+
+ # First, tie off trunk. Then we can branch.
+ # Add change file release row.
+ add_change_file_release_row(trunk_changes_file, release_version)
+ # Update build.xml
+ fix_build_xml(trunk_build_xml_file, release_version)
+ # Update poms
+ update_poms(trunk_dir, release_version)
+
+ # Commit trunk
+ commit_tree(trunk_dir, "Tie off release %s" % release_version)
+
+ # Now, create branch!!
+ create_branch(trunk_url, branch_url, "Create a release branch for MCF %s" % release_version)
+
+ # Second round of changes: Modify trunk for next -dev cycle
+ add_change_file_new_dev_row(trunk_changes_file, new_trunk_version)
+ fix_build_xml(trunk_build_xml_file, "%s-dev" % new_trunk_version)
+ update_poms(trunk_dir, "%s-SNAPSHOT" % new_trunk_version)
+ commit_tree(trunk_dir, "Prepare trunk for %s development" % new_trunk_version)
+
+ # Finally, delete trunk checkout (we're done with it)
+ remove_dir(trunk_dir)
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3 and len(sys.argv) != 4:
+ print >> sys.stderr, "Usage: %s <release_branch_version> <new_trunk_version> [<working_directory>]" % sys.argv[0]
+ sys.exit(1)
+
+ release_version = sys.argv[1]
+ trunk_version = sys.argv[2]
+ if len(sys.argv) > 3:
+ working_dir = sys.argv[3]
+ else:
+ working_dir = "."
+
+ create_release_branch(release_version, trunk_version, working_dir)
+
+ print >> sys.stderr, "Release branch created!"
+
\ No newline at end of file
Propchange: manifoldcf/release-scripts/create-site-branch.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/release-scripts/create-site-branch.py
------------------------------------------------------------------------------
svn:keywords = Id