I am trying to create an Ant script that will create a label in ClearCase and then apply the label to the latest version of any file where the latest version does not have a label.
I am using this to create the label:
<ccmklbtype typename="${label.name}" failonerr="false"
ordinary="true" comment="${label.comment}"/>
When I use this to add the labels:
<ccmklabel viewpath="${view.path}" comment="${label.comment}" recurse="true"
typename="${label.name}" replace="false" version="\main\${side.branch}\LATEST"/>
It is, of course, adding the label to everything in the view path. My desired behavior would be to only add the label if the item doesn’t already have a label on the latest version.
I can do what is desired via a command prompt, but I am trying to see if it can be done via Ant.
Does anyone have any ideas?
It looks like there is not a way to just label something that doesn’t already have a name. Instead, I set it up to use an exec block in ANT that will label anything if it isn’t labeled already with one of the labels used previously:
<target name="add_labels" description="Look for LATEST code that does not have a previous version label already on it. Skip the 0 generation as that is brought in from a previous release.">
<exec executable="cleartool" dir="${view.path}">
<arg value="find" />
<arg value="." />
<arg value="-ver" />
<arg value="version(\main\${side.branch}\LATEST)&&!version(\main\${side.branch}\0)${history.check}" />
<arg value="-exec" />
<arg value="cleartool mklabel -replace ${label.name} %CLEARCASE_XPN%" />
</exec>
</target>
It seems to work in testing.
Looking at the man page of
ccmklabel, you see:So with
replace=true, if a file hasn’t a label on the latest version, it will be put (or moved to) saidLATESTversion.In the OP ruminator‘s case, he only wants to add a label if the version does not have one already.
2 approaches are possible:
ccmklabelin a view which already select only the versions you want to label.Hard to do since the only version selector usable in a config spec is
\main\${side.branch}\'{!lbtype(MY_TEST)}, which select the last version which isn’t labelled ‘MY_TEST‘ (and that doesn’t fit exactly the initial selection criteria)don’t use ccmklabel in the ant script, and call insteald directly a cleartool find directive (which is more precise and can combine more version selectors than in a view config spec).
That is what the OP ruminator illustrates in his question update:
The find query focus on
LATESTversions which haven’t the right label: