Reputation: 3739
To get a list of all branches containing a specific revision in Git according to this StackOverflow answer the following command can be used:
git branch --contains <commit>
How to get this done with Mercurial?
I also want the output to be maximally clean. For example hg branches
returns also the last revision in the branch:
new-branch 2:657883530997
default 1:6c8931261776 (inactive)
but it will be preferable to return only the names of the branches, each on a new line for easy machine processing.
Upvotes: 1
Views: 356
Reputation: 488203
In Mercurial, only one branch can contain any specific commit. Just inspect the commit itself and see which branch it is on; that is the branch it will be on forever. You can copy that commit to a new commit on a different branch if you like (using hg graft
for instance) but it will have a different hash ID.
The command hg log -r rev -T '{branch}'
suffices to extract just the branch name. The revision specifier can be a relative number or hash ID.
Upvotes: 2