You can use the branch command
hg branches - active
Branches are considered active if their last commit has not been merged into another branch. Closed branches will not be displayed at all.
If you need to process the list programmatically and use .NET, there is also a library
Kindread
source share