Bruno
Bruno

Reputation: 189

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?

Upvotes: 3

Views: 142

Answers (2)

daniel kullmann
daniel kullmann

Reputation: 14023

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"

Upvotes: 5

Sedat Kapanoglu
Sedat Kapanoglu

Reputation: 47690

Add to your repository's .hg/hgrc:

[hooks]
commit=echo "Changeset committed on branch `hg branch`"

Upvotes: 8

Related Questions