common/templates/tag-hg-code.ant.xml.ftl
changeset 1046 871bdf0d7610
parent 55 4b303c38b677
child 1083 a91d8608229c
--- a/common/templates/tag-hg-code.ant.xml.ftl	Mon May 17 15:45:32 2010 +0100
+++ b/common/templates/tag-hg-code.ant.xml.ftl	Tue May 25 20:30:36 2010 +0100
@@ -1,37 +1,108 @@
 <?xml version="1.0"?>
 <project name="SF-TAG-HG-CODE" default="all" xmlns:hlm="http://www.nokia.com/helium">
 
-<#assign target_depends = "" />
-<#assign count = 0 />
+	<#assign dollar = "$"/>
+	
+	<#assign target_depends = "" />
+	<#assign count = 0 />
+	
+	<#list data as pkg_detail>
+		<target name="sf-tag-hg-code-${count}">
+			<echo message="Cloning TAGS branch from ${pkg_detail.dst}"/>
+			<mkdir dir="${ant['build.drive']}/tagging${pkg_detail.dst}"/>
+			<exec executable="hg" dir="${ant['build.drive']}/" failonerror="false" resultproperty="clone.from.dst.${count}.exitcode" errorproperty="clone.from.dst.${count}.stderr">
+				<arg value="--quiet"/>
+				<arg value="clone"/>
+				<arg value="--rev"/>
+				<arg value="TAGS"/>
+				<arg value="${pkg_detail.dst}"/>
+				<arg value="tagging${pkg_detail.dst}"/>
+			</exec>
+			<if>
+				<not>
+					<equals arg1="${dollar}{clone.from.dst.${count}.exitcode}" arg2="0"/>
+				</not>
+				<then>
+					<!-- TAGS branch not in local source - probably caused by package being new and not having a TAGS branch yet -->
+					<echo message="Clone failed because '${dollar}{clone.from.dst.${count}.stderr}'"/>
+					<!-- Clone the null revision instead -->
+					<exec executable="hg" dir="${ant['build.drive']}" failonerror="true">
+						<arg value="--quiet"/>
+						<arg value="clone"/>
+						<arg value="--rev"/>
+						<arg value="null"/>
+						<arg value="${pkg_detail.dst}"/>
+						<arg value="tagging${pkg_detail.dst}"/>
+					</exec>
+					<!-- Create the branch -->
+					<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}">
+						<arg value="branch"/>
+						<arg value="TAGS"/>
+					</exec>
+					<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
+						<arg value="--quiet"/>
+						<arg value="commit"/>
+						<arg value="--message"/>
+						<arg value="Created TAGS branch"/>
+					</exec>
+					<!-- Push it back to the source repo -->
+					<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
+						<arg value="--quiet"/>
+						<arg value="push"/>
+						<arg value="--force"/>
+						<arg value="--rev"/>
+						<arg value="."/>
+					</exec>
+				</then>
+			</if>
+			<!-- Find out what we're synced to in the main source repo -->
+			<exec executable="hg" dir="${ant['build.drive']}" outputproperty="hash12.${count}" logError="true">
+				<arg value="id"/>
+				<arg value="-i"/>
+				<arg value="${pkg_detail.dst}"/>
+			</exec>
+			<!-- Get the full hash id -->
+			<exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="hash40.${count}" logError="true">
+				<arg value="log"/>
+				<arg value="--rev"/>
+				<arg value="${dollar}{hash12.${count}}"/>
+				<arg value="--template"/>
+				<arg value="{node}"/>
+			</exec>
+			<!-- Manually add the tag to the tags file -->
+			<echo message="${dollar}{hash40.${count}} ${ant['sf.tagafterbuild.tag']}${dollar}{line.separator}" file="${ant['build.drive']}/tagging${pkg_detail.dst}/.hgtags" append="true"/>
+			<!-- Make sure the file is added (in case this is the first tagging for this package) -->
+			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" output="nul:">
+				<arg value="add"/>
+				<arg value=".hgtags"/>
+			</exec>
+			<!-- Manually commit it -->
+			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
+				<arg value="--quiet"/>
+				<arg value="commit"/>
+				<arg value="--message"/>
+				<arg value="Added tag ${ant['sf.tagafterbuild.tag']} for changeset ${dollar}{hash12.${count}}"/>
+			</exec>
+			<!-- 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}"/>
+			<echo message="Outgoing changes for ${dollar}{mcl.${count}}:"/>
+			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
+				<arg value="out"/>
+				<arg value="--force"/>
+				<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-tag-hg-code-${count}" />
+		
+		<#assign count = count + 1 />
+	</#list>
+	
+	<target name="all" depends="${target_depends}"/>
 
-<#list data as pkg_detail>
-    <target name="sf-tag-hg-code-${count}">
-        <sequential>
-        
-          <trycatch> <!-- build must not fail if this command gives an error -->
-            <try>
-              <hlm:scm verbose="true" scmUrl="scm:hg:${pkg_detail.source}">
-                <hlm:tag basedir="${ant['sf.spec.job.drive']}${pkg_detail.dst}" name="${ant['sf.tagafterbuild.tag']}" level="normal"/>
-              </hlm:scm>
-            </try>
-            <catch>
-              <echo message="WARNING: failed to tag code with label '${ant['sf.tagafterbuild.tag']}' (does the tag already exist?)"/>
-            </catch>
-          </trycatch>
-          
-        </sequential>
-    </target>
-    
-    <#if (count == 0) >
-    				<#assign target_depends = "${target_depends}" + "sf-tag-hg-code-${count}" />
-    </#if>
-    <#if (count > 0) >
-            <#assign target_depends ="${target_depends}" + ","+"sf-tag-hg-code-${count}"/>
-    </#if>
-    
-    <#assign count = count + 1 />
-</#list>
-
-<target name="all" depends="${target_depends}"/>
-
-</project>
\ No newline at end of file
+</project>