Blog   About   Contact

Ant + Subversion - How to list revision numbers

Today I needed a way to list all revision numbers of a repository.

I came up with the following solution:

Notes:
- svnant required;
- subversion called from command line.


<project name="buildexample" basedir="." default="svn.revisions">
        
    <!-- Setup svnant -->
    <import file="svnant.xml"/>
    
    <!-- Temp -->
    <property name="tempDir" value="C:\\DATA\\TEMP\\${ant.project.name}" />
    
    <!-- svn repo url -->
    <property name="svn.url" value="YOUR REPO URL HERE" />

    <target name="prepare">
        <!-- Create temp directory -->
<mkdir dir="${tempDir}" />
    </target>

    <!-- Set svn.revisions property -->
    <target name="svn.revisions" description="Sets property: svn.revisions" depends="prepare">

        <!-- creates log.xml for reading revisions -->
        <exec executable="svn" outputproperty="svnlog.out" output="${tempDir}\\log.xml" >
            <arg line="log --xml -v ${svn.url}" />
        </exec>
        <xmlproperty file="${tempDir}\\log.xml" collapseattributes="true" />     
        
        <property name="svn.revisions" value="${log.logentry.revision}" />
    
        <echo>${svn.revisions}</echo>
    
        <input message="Select Start Revision" validargs="${svn.revisions}" addproperty="svn.startRevision" />
        <input message="Select End Revision" validargs="${svn.revisions}" addproperty="svn.endRevision" />
    
    </target>

</project>

Please let me know if you think there's better way to list revision numbers.

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.9.004.