Search code examples
mercurialhg-log

Mercurial get branch name by changeset


I have tried the

hg log --rev "branch([changeset])"

but what I got is a collection of all the changesets in this branch.

What I do want to get is the name of the target branch (e.g. default) instead of the whole collection.

Is there a way to achieve this goal?


Solution

  • That's... not what revsets are for. You want to do something rather different:

    hg log --rev [changeset] --template "{branch}\n"
    

    See hg help templates.