views:

208

answers:

3

I have to run a dozen of different build tests on a code base maintained in a mercurial repository. I don't want to run serially these tests on same repository because they modify a set of common files and I want to run them in parallel on different machines. Also, after all tests are run I want to have access to latest test results from those test work areas. Currently I'm cloning the master repository a dozen of times and run in each clone one different test. Before each test execution I do a pull/update/purge preparation sequence in order to start the test on latest clean state. That's good for me.

I'm also preparing new changes using mq extension that I would test on all clones as above before committing them. For testing some ready candidate mq patches I want somehow to deploy/synchronize them to be available in test clones and apply those ready for testing using some guard before running the test.

Did anybody do this synchronization before? What's the most simple way to do it? Do I need to have versioned mq patches for that?

+3  A: 

patches can be maintained in their own repository provided you passed the "-c" switch to qinit like so

hg qinit -c

You may still be able to create a patch repo after the fact via

cd .hg/patches
hg init
hg addremove
hg commit -m "my patches"

But I haven't ever tried that personally.

then .hg/patches can be treated like any other mercurial repository. so I think you could probably roll some shell scripting. to get into the .hg dir of your cloned repos and do a

hg clone http://centralrepo.com/patch_repo ./patches
Tom Willis
Thanks Tom. Unfortunately, I was already considering an approach based on this idea (that's why I'm wondering in question "Do I need to have versioned mq patches for that?") but looks little bit too complex. I'll post tested details as a self answer. Really --mq option should be also available for clone. Anybody see something easier? or other way to achieve my above usecase? +1 for now.
dim
even if partial and qinit become obsolete, this is the idea. thanks for answer...
dim
no problem hope it works it all works out. I will most likely have to do something similar very soon.
Tom Willis
I suggest you default `qinit` with `-c` as soon as you start to use MQ, because it's too easy to lose change history with `qrefresh`. As all tutorials would tell you that you should commit often to mark the progress, with MQ you need to `qcommit` often. It's the best of both worlds: keep your regular changeset history clean while having work-in-progress history to reference and fall back.
Geoffrey Zheng
+1  A: 

Here is the solution that I've implemented. Few notes:

  • all patches guarded with ready_for_testing AND those unguarded are applied for testing.
  • using versioned repos is better because we can make abstraction of queue repository implementation
  • I use mercurial 1.5.1
  • master repo is in master dir
  • clone repos are in clone-x dirs

Here are the steps (some could be optional):

  1. once: put patches in master repository under versioning using mercurial:
    a. hg -R master init --mq #no commit happen here, can be done later
    b. hg -R master commit --mq --addremove --message 'initial patch queue' #make them visible to clone repos

  2. for each clone, once after clone creation finishes: assuming no patches created yet on clones, initialize mq sub-repository:
    a. hg clone master\.hg\patches clone-x\.hg\patches
    b. hg -R clone-x qselect ready_for_testing

  3. for each change ready in master (patch created/imported in mq repo): do this before launching tests for it:
    a. review/update guards of mq patches: those included for testing should be unguarded or with +ready_for_testing
    b. hg -R master commit --mq -A #make them visible to clone repos

  4. for each clone, for each [test] iteration for each clone: do this preparation sequence before running the actual test:
    a. hg -R clone-x qpop --all --force
    b. hg -R clone-x pull
    c. hg -R clone-x update --clean
    d. hg -R clone-x purge --all
    e. hg -R clone-x pull --mq
    f. hg -R clone-x update --mq
    g. hg -R clone-x qpush --all

dim
just found some qclone mercurial command. maybe step 2a can be avoided...
dim