common/templates/tag-hg-code.ant.xml.ftl
changeset 1046 871bdf0d7610
parent 55 4b303c38b677
child 1083 a91d8608229c
equal deleted inserted replaced
1045:d822afc3c044 1046:871bdf0d7610
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <project name="SF-TAG-HG-CODE" default="all" xmlns:hlm="http://www.nokia.com/helium">
     2 <project name="SF-TAG-HG-CODE" default="all" xmlns:hlm="http://www.nokia.com/helium">
     3 
     3 
     4 <#assign target_depends = "" />
     4 	<#assign dollar = "$"/>
     5 <#assign count = 0 />
     5 	
     6 
     6 	<#assign target_depends = "" />
     7 <#list data as pkg_detail>
     7 	<#assign count = 0 />
     8     <target name="sf-tag-hg-code-${count}">
     8 	
     9         <sequential>
     9 	<#list data as pkg_detail>
    10         
    10 		<target name="sf-tag-hg-code-${count}">
    11           <trycatch> <!-- build must not fail if this command gives an error -->
    11 			<echo message="Cloning TAGS branch from ${pkg_detail.dst}"/>
    12             <try>
    12 			<mkdir dir="${ant['build.drive']}/tagging${pkg_detail.dst}"/>
    13               <hlm:scm verbose="true" scmUrl="scm:hg:${pkg_detail.source}">
    13 			<exec executable="hg" dir="${ant['build.drive']}/" failonerror="false" resultproperty="clone.from.dst.${count}.exitcode" errorproperty="clone.from.dst.${count}.stderr">
    14                 <hlm:tag basedir="${ant['sf.spec.job.drive']}${pkg_detail.dst}" name="${ant['sf.tagafterbuild.tag']}" level="normal"/>
    14 				<arg value="--quiet"/>
    15               </hlm:scm>
    15 				<arg value="clone"/>
    16             </try>
    16 				<arg value="--rev"/>
    17             <catch>
    17 				<arg value="TAGS"/>
    18               <echo message="WARNING: failed to tag code with label '${ant['sf.tagafterbuild.tag']}' (does the tag already exist?)"/>
    18 				<arg value="${pkg_detail.dst}"/>
    19             </catch>
    19 				<arg value="tagging${pkg_detail.dst}"/>
    20           </trycatch>
    20 			</exec>
    21           
    21 			<if>
    22         </sequential>
    22 				<not>
    23     </target>
    23 					<equals arg1="${dollar}{clone.from.dst.${count}.exitcode}" arg2="0"/>
    24     
    24 				</not>
    25     <#if (count == 0) >
    25 				<then>
    26     				<#assign target_depends = "${target_depends}" + "sf-tag-hg-code-${count}" />
    26 					<!-- TAGS branch not in local source - probably caused by package being new and not having a TAGS branch yet -->
    27     </#if>
    27 					<echo message="Clone failed because '${dollar}{clone.from.dst.${count}.stderr}'"/>
    28     <#if (count > 0) >
    28 					<!-- Clone the null revision instead -->
    29             <#assign target_depends ="${target_depends}" + ","+"sf-tag-hg-code-${count}"/>
    29 					<exec executable="hg" dir="${ant['build.drive']}" failonerror="true">
    30     </#if>
    30 						<arg value="--quiet"/>
    31     
    31 						<arg value="clone"/>
    32     <#assign count = count + 1 />
    32 						<arg value="--rev"/>
    33 </#list>
    33 						<arg value="null"/>
    34 
    34 						<arg value="${pkg_detail.dst}"/>
    35 <target name="all" depends="${target_depends}"/>
    35 						<arg value="tagging${pkg_detail.dst}"/>
       
    36 					</exec>
       
    37 					<!-- Create the branch -->
       
    38 					<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}">
       
    39 						<arg value="branch"/>
       
    40 						<arg value="TAGS"/>
       
    41 					</exec>
       
    42 					<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
       
    43 						<arg value="--quiet"/>
       
    44 						<arg value="commit"/>
       
    45 						<arg value="--message"/>
       
    46 						<arg value="Created TAGS branch"/>
       
    47 					</exec>
       
    48 					<!-- Push it back to the source repo -->
       
    49 					<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
       
    50 						<arg value="--quiet"/>
       
    51 						<arg value="push"/>
       
    52 						<arg value="--force"/>
       
    53 						<arg value="--rev"/>
       
    54 						<arg value="."/>
       
    55 					</exec>
       
    56 				</then>
       
    57 			</if>
       
    58 			<!-- Find out what we're synced to in the main source repo -->
       
    59 			<exec executable="hg" dir="${ant['build.drive']}" outputproperty="hash12.${count}" logError="true">
       
    60 				<arg value="id"/>
       
    61 				<arg value="-i"/>
       
    62 				<arg value="${pkg_detail.dst}"/>
       
    63 			</exec>
       
    64 			<!-- Get the full hash id -->
       
    65 			<exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="hash40.${count}" logError="true">
       
    66 				<arg value="log"/>
       
    67 				<arg value="--rev"/>
       
    68 				<arg value="${dollar}{hash12.${count}}"/>
       
    69 				<arg value="--template"/>
       
    70 				<arg value="{node}"/>
       
    71 			</exec>
       
    72 			<!-- Manually add the tag to the tags file -->
       
    73 			<echo message="${dollar}{hash40.${count}} ${ant['sf.tagafterbuild.tag']}${dollar}{line.separator}" file="${ant['build.drive']}/tagging${pkg_detail.dst}/.hgtags" append="true"/>
       
    74 			<!-- Make sure the file is added (in case this is the first tagging for this package) -->
       
    75 			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" output="nul:">
       
    76 				<arg value="add"/>
       
    77 				<arg value=".hgtags"/>
       
    78 			</exec>
       
    79 			<!-- Manually commit it -->
       
    80 			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
       
    81 				<arg value="--quiet"/>
       
    82 				<arg value="commit"/>
       
    83 				<arg value="--message"/>
       
    84 				<arg value="Added tag ${ant['sf.tagafterbuild.tag']} for changeset ${dollar}{hash12.${count}}"/>
       
    85 			</exec>
       
    86 			<!-- Work out the URL of the web *MCL* -->
       
    87 			<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}"/>
       
    88 			<echo message="Outgoing changes for ${dollar}{mcl.${count}}:"/>
       
    89 			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
       
    90 				<arg value="out"/>
       
    91 				<arg value="--force"/>
       
    92 				<arg value="--rev"/>
       
    93 				<arg value="TAGS"/>
       
    94 				<arg value="${dollar}{mcl.${count}}"/>
       
    95 			</exec>
       
    96 		</target>
       
    97 		
       
    98 		<#if (count > 0) >
       
    99 			<#assign target_depends ="${target_depends}" + ", "/>
       
   100 		</#if>
       
   101 		<#assign target_depends = "${target_depends}" + "sf-tag-hg-code-${count}" />
       
   102 		
       
   103 		<#assign count = count + 1 />
       
   104 	</#list>
       
   105 	
       
   106 	<target name="all" depends="${target_depends}"/>
    36 
   107 
    37 </project>
   108 </project>