I have already found a solution for the problem I stated in my last post. I was able to make a shorty Python script that get the information out of the Mercurial repository using Mercurial classes.
It was more simple than I expected. If I manage to clean that up, it would probably be an useful Mercurial extension.
I only paste the Python code here. I would like to setup a git repository for my $HOME/bin scripts. This is definitely not the final product, but it's already something you can use.
#!/usr/bin/python
import mercurial
import sys
from mercurial import ui, hg;
myui = ui.ui()
try:
# Instanciate the repository.
hg_repo = hg.repository(myui, sys.argv[1])
# Get some informations.
hg_branch = hg_repo.dirstate.branch()
hg_rev = hg_repo.changelog.rev(hg_repo.changelog.tip())
if hg_repo.dirstate._dirty:
hg_dirty = "1"
else:
hg_dirty = ""
print "hg_rev=%s\nhg_branch=%s\nhg_dirty=%s" % (hg_rev, hg_branch, hg_dirty)
except Exception, ex:
sys.exit(1)