views:

374

answers:

2

I have a little private Google code project. For a SCM I use Mercurial. And for the local build i would like to use nant.

So basically:

  1. I would like to download my source files from a known mercurial repository using a nant task
  2. I would like to somehow get the revision number of the repository so that I can assemble a nice little assembly version number

The build script will not be used for continuous integration but only for nightly builds and production builds.

Thanks for the help

+3  A: 

I don't know nant, but in (real) ant, we just use the <exec> task to invoke the hg binary. Depending clean you'd like to start you can clone or just pull and executing hg id -i gets you the revision number cleanly. Another thing to consider is using the archive links on the remote web interface (essentially the hg archive command via HTTP) and just use wget (not the equivalent nant task) to pull down the tip archive, which has an easy consistent link, and then you can get the revision id from inside the archive's hg_archival.txt file.

Ry4an
That would work but at the same time imply that the end-user of the script would have to have mercurial installed locally.I was honestly hoping that some taks extensions were available
Dejan
I don't think you'll find any non-mercurial code that speaks the mercurial wire protocol currently, and it's in python. So you could try running it in IronPython, but at that point you're talking as much work as a mercurial install. I'll re-write my get based soln in a separate answer.
Ry4an
+1  A: 

Since you're looking for NANT code rather than calling off to the mercurial binary, I'd suggest just using Nant's <get> task to pull down the tip of your repo like this:

<get src="http://bitbucket.org/tortoisehg/stable/get/tip.zip" dest="latest.zip" />
<unzip zipfile="latest.zip" todir="latest"/>

and inside there should be a .hg_archival.txt file that contains something like this:

repo: bac32db38e52fd49acb62b94730a55f4f4b0cdee
node: 61482ea34fd0b9650e738eaebb2fe352c2f6315a

from which you can get a hashId suitable for use in branding a build.

Unfortunately, I'm not finding the archive download links on google code, but they're pretty standard in the mercurial (and bitbucket) web interfaces, so I'd imagine they're somewhere.

Ry4an