Reputation: 19808
I'm using the Perforce tasks for Ant and would like to a file if it's not already known to Perforce or it if it is.
I can:
<p4add changelist='${p4.change}' failonerror='false'>
<fileset file='my-file'/>
</p4add>
<p4edit changelist='${p4.change}'>
<fileset file='my-file'/>
</p4edit>
Is there a better way?
Upvotes: 0
Views: 224
Reputation: 19808
<trycatch property='my-file-is-new'><try>
<p4edit view='my-file'/>
</try><catch>
<touch file='my-file'/>
<p4add>
<fileset file='my-file'/>
</p4add>
</catch></trycatch>
<if><isset property="my-file-is-new"/><then>
<echo message="p4 added my-file"/>
</then><else>
<echo message="p4 edited my-file"/>
</else></if>
Upvotes: 1
Reputation: 3659
The p4fstat task can filter based on a file's status in the repository. It seems like a cleaner approach but may take more lines of Ant script.
Upvotes: 0