Two other options: use svnversion.exe:

<?xml version="1.0"?>

<project name="svnver"  default="">
  <exec program="svnversion.exe" output="svnver.tmp">
     <arg value="-n"/>
  </exec>

  <loadfile file="svnver.tmp" property="svnver"/>

  <!-- NOTE: We should really delete the svnver.tmp file -->

  <echo message="Revision = ${svnver}"/>
</project>


Also, you could use the --xml option to svn info and then read in the xml
file.  Then you could get all the fields without needed the regex's.
However, if you're not in a current working directory, the XML generated by
'svn info --xml' is invalid: perhaps you could key on the program return
code (don't know enough about nant to say).  If you're not in a working
directory, 'svnversion -n' (-n == no newline) returns 'exported'.  Also,
svnversion shows mixed revisions ('110:111') and local mods ('110M',
'110:111M') as well.

For example, "svn info --xml" in one of my working copies returns:
<?xml version="1.0"?>
<info>
<entry
  kind="dir"
  path="."
  revision="149">
<url>file:///s:/repos/svn/books/trunk</url>
<repository>
<root>file:///s:/repos/svn/books</root>
<uuid>45b52e18-af15-e54c-84e6-b335ebcf52fe</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
</wc-info>
<commit
  revision="149">
<author>kogrover</author>
<date>2007-01-22T21:56:09.424750Z</date>
</commit>
</entry>
</info>



- kevin

On 1/22/07, Arnette, Bill <[EMAIL PROTECTED]> wrote:

 I would suggest you use 'svn info' command to get the revision.  In fact,
you may not want the current revision of the repository but actually the
last revision that the directory was changed.  Svn Info will give you that
information.

How about this:

<?xml version="1.0"?>

<project name="Fred"  default="" xmlns="
http://nant.sf.net/release/0.85-rc3/nant.xsd";>


   <exec program="svn.exe" output="svninfo.out">
      <arg value="info"/>
   </exec>

   <loadfile file="svninfo.out" property="svn-info"/>

   <regex pattern="Revision:\s+(?'revision'\d+)" input="${svn-info}"
/>
   <regex pattern="Last Changed Rev:\s+(?'lastchangedrevision'\d+)"
input="${svn-info}"  />

   <echo message="Revision = ${revision}"/>
   <echo message="Last Changed Rev = ${lastchangedrevision}"/>

</project>
BTW, I couldn't get options="Multiline" to work either.



 ------------------------------
*From:* [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED] *On Behalf Of *Mark Modrall
*Sent:* Sunday, January 21, 2007 2:54 PM
*To:* nant-users@lists.sourceforge.net
*Subject:* [NAnt-users] <exec> and <regex>

    Hi…

I'm new to nant, and I'm trying to port some java/ant tasks we'd done to
it.  Since we use svn as our source control, I'm having to do the update
with exec.  To get the revision updated to, I'm sifting through the svn
output.  Under ant, I redirected the svn output to a property using a
filterchain and then looked for certain patterns (turns out to be in the
last line).

Just stumbling along here, it seems that I have to direct the svn output
to a file in nant, then use loadfile to get it into a property then use a
<regex> on the whole thing.  Is that the best way to do it?

I was having the damnedest time getting it to deal with the fact that the
property now had multiple lines in it when the regex was applied.  I put
options="Multiline" but it still couldn't find anything if I had $ in the
pattern.  That seems more of a C# pattern issue, but I thought I'd ask about
the general approach.

Thanks

-Mark


This e-mail message, and any attachments, is intended only for the use of
the individual or entity identified in the alias address of this message and
may contain information that is confidential, privileged and subject to
legal restrictions and penalties regarding its unauthorized disclosure and
use. Any unauthorized review, copying, disclosure, use or distribution is
strictly prohibited. If you have received this e-mail message in error,
please notify the sender immediately by reply e-mail and delete this
message, and any attachments, from your system. Thank you.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to