当前位置: 动力学知识库 > 问答 > 编程问答 >

batch file - How do I get the name of the branch that has had the most recent commit in Mercurial

问题描述:

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%\

网友答案:

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

hg log -r tip --template {branch}
分享给朋友:
您可能感兴趣的文章:
随机阅读: