Correct handling of tag name and changeset author in sf-tag-hg-code
authorSimon Howkins <simonh@symbian.org>
Thu, 10 Jun 2010 14:37:23 +0100
changeset 1084 abefe2962232
parent 1083 a91d8608229c
child 1086 7e72cd1ef70a
Correct handling of tag name and changeset author in sf-tag-hg-code Addition of sf-push-hg-tags and associated template file, for pushing the tags created in sf-tag-hg-code back out to the MCL. Minor whitespace rationalisation.
common/build.postbuild.xml
common/templates/push-hg-tags.ant.xml.ftl
--- a/common/build.postbuild.xml	Thu Jun 10 14:34:20 2010 +0100
+++ b/common/build.postbuild.xml	Thu Jun 10 14:37:23 2010 +0100
@@ -100,7 +100,41 @@
     </target>
 
     <target name="sf-tag-hg-code">
-        <property name="sf.tagafterbuild.tag" value="${sf.spec.job.name}_${sf.spec.job.codeline}.${sf.spec.job.number}"/>
+        <!-- To do the tagging, we need to know what tag to use, and who the author is (from hg's perspective) -->
+        <fail message="This target needs to have all the details specified, or to be run interactively so it can query the user">
+            <condition>
+                <and>
+                    <isset property="sf.hudson.executor.number"/>
+                    <not>
+                        <or>
+                            <isset property="sf.tagafterbuild.tag"/>
+                            <isset property="sf.hg.ui.username"/>
+                        </or>
+                    </not>
+                </and>
+            </condition>
+        </fail>
+
+        <!-- Ask the user, interactively, what tag to use -->
+        <input addproperty="sf.tagafterbuild.tag" message="Enter the tag to apply to the code (eg &quot;PDK_1.0.1&quot;):"/>
+        <fail message="No tag supplied">
+            <condition>
+                <length string="${sf.tagafterbuild.tag}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
+        <!-- Now get the username sorted out -->
+        <exec executable="hg" outputproperty="sf.hg.showconfig.ui.username">
+            <arg value="showconfig"/>
+            <arg value="ui.username"/>
+        </exec>
+        <input addproperty="sf.hg.ui.username" message="Enter hg author credentials (eg &quot;Fred Bloggs &lt;fredb@example.org&gt;&quot;) default is" defaultvalue="${sf.hg.showconfig.ui.username}"/>
+        <fail message="No author supplied">
+            <condition>
+                <length string="${sf.hg.ui.username}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
         <fmpp sourceFile="${sf.common.config.dir}/templates/tag-hg-code.ant.xml.ftl"
               outputFile="${temp.build.dir}/tag-hg-code.ant.xml">
             <data expandProperties="yes">
@@ -111,6 +145,59 @@
         <ant antfile="${temp.build.dir}/tag-hg-code.ant.xml"/>
     </target>
 
+    <target name="sf-push-hg-tags">
+        <!-- To do the pushing, we need to have a set of credentials for the developer.symbian.org site -->
+        <fail message="This target needs to have loging credentials specified specified, or to be run interactively so it can query the user">
+            <condition>
+                <and>
+                    <isset property="sf.hudson.executor.number"/>
+                    <not>
+                        <or>
+                            <isset property="sf.symbian.account.username"/>
+                            <isset property="sf.symbian.account.password"/>
+                        </or>
+                    </not>
+                </and>
+            </condition>
+        </fail>
+
+        <input addproperty="sf.symbian.account.username" message="Enter symbian.org username (eg &quot;fredb&quot;)"/>
+        <fail message="No author supplied">
+            <condition>
+                <length string="${sf.hg.ui.username}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
+        <input addproperty="sf.symbian.account.password" message="Enter symbian.org password (eg &quot;unguessable&quot;)">
+            <!-- Ant 1.8 supports secure here, which would be an improvement... -->
+            <handler type="default"/>
+        </input>
+        <fail message="No password supplied">
+            <condition>
+                <length string="${sf.hg.ui.password}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
+        <if>
+            <not>
+                <available file="${build.drive}/tagging" type="dir"/>
+            </not>
+            <then>
+                <!-- No dir with tagged repos in - create them! -->
+                <runtarget target="sf-tag-hg-code"/>
+            </then>
+        </if>
+
+        <fmpp sourceFile="${sf.common.config.dir}/templates/push-hg-tags.ant.xml.ftl"
+              outputFile="${temp.build.dir}/push-hg-tags.ant.xml">
+            <data expandProperties="yes">
+                ant: antProperties()
+                data: csv(${sf.spec.sourcesync.sourcespecdir}/${sf.spec.sourcesync.sourcespecfile}, {separator:','})
+            </data>
+        </fmpp>
+        <ant antfile="${temp.build.dir}/push-hg-tags.ant.xml"/>
+    </target>
+
     <target name="sf-run-evalid" >
         <delete dir="${build.drive}/output/md5"/>
         <mkdir  dir="${build.drive}/output/md5"/>
@@ -630,12 +717,12 @@
           </exec>
           <echo message="Send ${build.log.dir}/diamonds_uh.xml to Diamonds"/>
           <exec executable="python">
-		    <arg value="${sf.common.config.dir}/tools/brag/send_xml_to_diamonds.py"/>
-		    <arg value="-u"/>
-		    <arg value="http://${diamonds.host}${diamonds.build.id}"/>
-		    <arg value="-f"/>
-		    <arg value="${build.log.dir}/diamonds_uh.xml"/>
-		  </exec>
+            <arg value="${sf.common.config.dir}/tools/brag/send_xml_to_diamonds.py"/>
+            <arg value="-u"/>
+            <arg value="http://${diamonds.host}${diamonds.build.id}"/>
+            <arg value="-f"/>
+            <arg value="${build.log.dir}/diamonds_uh.xml"/>
+          </exec>
         </then>
       </if>
     </target>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/templates/push-hg-tags.ant.xml.ftl	Thu Jun 10 14:37:23 2010 +0100
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<project name="SF-TAG-HG-CODE" default="all" xmlns:hlm="http://www.nokia.com/helium">
+
+	<#assign dollar = "$"/>
+	
+	<#assign target_depends = "" />
+	<#assign count = 0 />
+	
+	<#list data as pkg_detail>
+		<target name="sf-push-hg-tag-${count}">
+			<!-- Work out the URL of the web *MCL* -->
+			<propertyregex property="mcl.${count}" input="${pkg_detail.source}" regexp="(developer.symbian.org)/(oss|sfl)/FCL/(sf|sftools)" casesensitive="false" replace="\1/\2/MCL/\3" defaultValue="${pkg_detail.source}"/>
+			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
+				<arg value="push"/>
+				<arg value="--force"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf1.prefix=https://developer.symbian.org/"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf1.username=${dollar}{sf.symbian.account.username}"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf1.password=${dollar}{sf.symbian.account.password}"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf2.prefix=http://developer.symbian.org/"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf2.username=${dollar}{sf.symbian.account.username}"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf2.password=${dollar}{sf.symbian.account.password}"/>
+				<arg value="--rev"/>
+				<arg value="TAGS"/>
+				<arg value="${dollar}{mcl.${count}}"/>
+			</exec>
+		</target>
+		
+		<#if (count > 0) >
+			<#assign target_depends ="${target_depends}" + ", "/>
+		</#if>
+		<#assign target_depends = "${target_depends}" + "sf-push-hg-tag-${count}" />
+		
+		<#assign count = count + 1 />
+	</#list>
+	
+	<target name="all" depends="${target_depends}"/>
+
+</project>