Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print Current Mercurial Revision Hash?

Try:

hg id -i

Example:

$ hg id -i
adc56745e928

hg --debug id -i

This will output the long hash, with a plus if there are uncommitted changes.


You can use --template with the parent command, I use this to get the long hash:

hg parent --template '{node}'

Summarising the answers and their responses, it seems that this is the best way to print the unique (not short form) identifier of the current version:

hg log -l 1 --template '{node}\n' -r .

hg log -l 1 --template '{node|short}\n'

See the docs, paragraphs "The basics of templating" and following.