Question about pretxnchangegroup
Maxim Vuets
maxim.vuets at gmail.com
Fri Nov 7 13:47:44 CST 2008
On 11/6/08, Doug Simon <Doug.Simon at sun.com> wrote:
> I want to use the pretxnchangegroup hook to verify that pushes to a
> shared repo do not break the build.
As for me, it looks like you have chosen a wrong way to verify a commit,
because every push will take some time.
I think it is better to have two repos: first one for development purposes,
second one for stable and tested versions of a product.
> The problem is that the test requires accessing the state
> that would be pushed.
> As far as I understand it, the working directory in the destination
> repo is not updated
> before my pretxnchangegroup hook executes which means I have
> incorporate an explicit
> 'hg update' in my hook. Assuming that this is correct, should I run
> another 'hg update'
> at the end of my hook in the case that the test fails? Otherwise, the
> working directory
> would now reflects changeset(s) that no longer exist, right?
Just try it (:
tmp$ hg init hgtest
tmp$ cd hgtest
hgtest$ touch file
hgtest$ hg ci -qAm init
hgtest$ echo -e "[hooks]\\npretxnchangegroup=sh -c 'hg -R $(pwd) log
--style=compact; exit 1'\\n" >>.hg/hgrc
hgtest$ cd ..
tmp$ hg clone hgtest hgtest-slave
tmp$ cd hgtest-slave
hgtest-slave$ echo something >>file
hgtest-slave$ hg ci -m 'my change'
hgtest-slave$ hg push -q
1[tip] 7d3d801f7ace 2008-11-07 21:32 +0200 maxim
my change
0 47cf95ae6ec5 2008-11-07 21:26 +0200 maxim
init
transaction abort!
rollback completed
abort: pretxnchangegroup hook exited with status 1
---you see that the state of a repo during pretxnchangegroup hook
reflectes commits that are commiting now.
So just call some script which will do "hg up -C", make test build,
perform tests and as a result return 0 or non-0 for success and
failure respectively. I think there are no reasons to worry about
state of working dir after not successful commit (assuming that
this repo is just used like a common storage).
--
. Hoc est simplicissimum!
..: maxim.vuets.name
More information about the Mercurial
mailing list