Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial - How to specify branch on commit?

I would like, when a user commit a changeset, to show a message mentioning the branch where the changeset was committed.

Example:

$hg commit -m 'Fix bug'
Changeset committed on branch bugfix

Do I actually need to modify the hg commit code or is it a quicker/simpler way of doing it?

like image 606
Bruno Avatar asked Nov 21 '25 10:11

Bruno


2 Answers

Add to your repository's .hg/hgrc:

[hooks]
commit=echo "Changeset committed on branch `hg branch`"
like image 62
Sedat Kapanoglu Avatar answered Nov 24 '25 17:11

Sedat Kapanoglu


ssg's answer is unfortunately not portable to e.g. Windows (because of the backticks), but this should work:

# UNIX-like
[hooks]
commit=hg log -r $HG_NODE --template "Committing on branch {branch}\n"

or

# Windows
[hooks]
commit=hg log -r %HG_NODE% --template "Committing on branch {branch}\n"
like image 45
daniel kullmann Avatar answered Nov 24 '25 18:11

daniel kullmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!