Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the current mercurial revision without calling hg?

Tags:

mercurial

In Git the current revision hash is stored in

.git/refs/heads/master

Is there an equivalent in Mercurial that doesn't require me making a call to hg log -l1? I know I can get the current branch in .hg/branch.

This is to "display" the current hg hash on screen when browsing a web page.

like image 349
davidmytton Avatar asked Nov 17 '09 21:11

davidmytton


1 Answers

$ hg parents --template="{node}\n"
52b8cee1e59c91b9147635b7f44a3a8896ee0b00

$ hexdump -n 20 -e '1/1 "%02x"' .hg/dirstate
52b8cee1e59c91b9147635b7f44a3a8896ee0b00

But why can't you just call hg parents --template="{node}\n"?

like image 108
Steve Losh Avatar answered Oct 01 '22 17:10

Steve Losh