How can I commit a file before the tag is committed?

I want to automatically replace my project version when I use hg tag XXX.

I set the pretag hook in my hgrc (note: I removed material that ensures that it outputs VERSION to hg root, for clarity):

[hooks]
pretag.bump_version = (echo "$HG_TAG" > VERSION; hg commit -m "Updated VERSION to $HG_TAG" VERSION)

When I create a new tag:

$ hg tag 1.1

I get an error message:

warning: ignoring unknown working parent <revision_id>!

Instead, I can use a hook tag that succeeds, but then the VERSION number is exactly one version later than the tag: this means updating to the tagged revision and then creating will result in the product version number (which depends on the VERSION file) wrong.

? SO # 2558531, : , .

+3
1

pre-tag pretag. pretag - , , . , pre-tag pre-*, , , , - , . ( , , pre-log).

:

[hooks]
pre-tag.bump_version = echo $HG_ARGS > VERSION; hg commit -m "updated version to $HG_ARGS" VERSION

, :

ry4an@ry4an:~$ hg init tagtest
ry4an@ry4an:~$ cd tagtest
ry4an@ry4an:~/tagtest$ echo text > VERSION
ry4an@ry4an:~/tagtest$ hg commit -A -m initial
adding file
ry4an@ry4an:~/tagtest$ hg tag --config hooks.pre-tag='echo $HG_ARGS > VERSION; hg commit -m "updated version to $HG_ARGS" VERSION' 1.1

: $HG_ARGS, pre-*, , . hgrc manpage.

, VERSION, hook, . , , , .

+3

All Articles