Question

What I would like to do is query the HG repo to find the branch name of the last commit.

When a user pushes their commit to the repo, I am triggering a batch file via a hook in the .hg/hgrc file in the central repo.

Using hg branch in my local repo works fine, however the batch file I'm running resides on the central repo, meaning that it always returns 'default'

What i would like to do is go, 'Get the last committed revision and extract the branch name from that' regardless of what branch the central repo is on.

I hope this is possible, but may be it's not - any suggestions greatly appreciated

Here is a snippet from my batch file:

setlocal enableextensions
for /f "tokens=*" %%a in (
'hg branch'
) do (
set hg_branch=%%a
)
set dest=\\myrepo-%hg_branch%\
Was it helpful?

Solution

tip is always the most recent changeset, so this will print the branch name:

hg log -r tip --template {branch}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top