Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6356111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:54:03+00:00 2026-05-24T22:54:03+00:00

I have a few branches and a commit with ID X, I want Mercurial

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:54:05+00:00Added an answer on May 24, 2026 at 10:54 pm

    I think you could get what you want with this formula

    hg log -r 'descendants(X) and head()'
    

    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 the hg log command. If you have more than one head per named branch, you may end up using uniq or similar.

    EDIT: To describe what this will do

    A----B----C----D----E  Branch: default (E is a merge of F into D)
          \    \    \ /
           \    \    F     Branch B1 (closed)
            \    G-----H   Branch B2
             \    \
              \    I       Branch B2
               J           Branch B3
    

    If you execute hg log -r 'descendants(C) and head()', you should get E, F, H and I.

    • E: You get E, because ‘default’ is a branch head, even though it has a special name.
    • F comes up because even though you merged into E, it’s still a head(), so it shows up on this list
    • G is not a head, although it does contain C
    • H is a head and clearly a descendant of C
    • I branched from G, is also a head, and clearly contains C
    • J is a head, but does not have C as an ancestor
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mercurial repository setup with a few named branches. I want to
I have a local ref that contains a few branches that I recently performed
I have a git repo which has a few branches - there's the master
I have few nested DIVs at page. I want to add event only for
I have few questions about using lock to protect my shared data structure. I
I have few questions, I want to show the alert window on my Update
Here's the scenario: At work we have quite a few branches and we haven't
I have a Git repository with few branches and dangling commits. I would like
I have two branches that are different enough that rebasing seems to not work
Say I have few folders in trunk trunk/documentation trunk/ApplicationServices trunk/Release trunk/ApplicationUI I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.