views:

96

answers:

2

I have a legacy product, spread across dozens of repositories. I'm currently trying to refactor (and understand...) the given build process. First step was moving from the old version control system to mercurial, which was encouraging and easy.

The build process mainly uses ant build scripts (good news) but has to run 'on' the repository file structure (bad news...) because the ant scripts take files from all repositories and leave artifacts on .. lets say, several places... But that's not a blocker.

Before I trigger the build (now with hudson CI), I have to make sure, that all repositories are updated to the tip or a selected tag. I could write a script/batch or write a custom ant task (again) but, I don't want to ignore existing features (again):

is it possible to update a set of mercurial repositories by using existing ant tasks or mercurial features? All repositories are located in one folder (like /repo) and have a common prefix (like SYSTEMNAME_module) so it's easy to locate them/create a fileset.

+1  A: 

The most simple solution today is to start the hg executable from ant (using the exec task. Note: MacroDef is your friend). Just create a "main" build file in one of the projects, change to the parent directory (where you can access all the local copies) and then update each one.

Aaron Digulla
Thanks Aaron - didn't know MacroDef but it looks like a part of the solution - but i still need an idea on how to feed a 'hg-update-macro' with the repository names
Andreas_D
You need to feed it a single repository name as a parameter. See the examples. Check ANT Contrib tasks if you need a loop.
Aaron Digulla
+1  A: 

I found a different ant based solution, based on the 'apply' task:

<apply executable="hg">
  <arg value="update" />
  <arg value="--verbose" />
  <arg value="--revision" />
  <dirset dir="/repos" include="REPO_SUFFIX*" />
</apply>

Thanks to Aaron, his very helpful answer showed me the right direction.

Andreas_D