简体   繁体   中英

How to get a list of all branches containing specific revisoin in Mercurial?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM