I have a few branches and a commit with ID X, I want Mercurial to return me a list of branches where that commit exists.
Mercurial already stores information about branch in every commit, but only about a branch in which that commit was introduced. If you merge that commit into some other branch, commit will still store only original branch name.
I think you could get what you want with this formula
head()includes all named branch heads, so even if the tip of a branch has been merged into another named branch, it will still be listed with this formula.If you only want to show branch names, you will probably want to use the
--template '{branches}\n'directive for thehg logcommand. If you have more than one head per named branch, you may end up usinguniqor similar.EDIT: To describe what this will do
If you execute
hg log -r 'descendants(C) and head()', you should get E, F, H and I.head(), so it shows up on this list