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

  • Home
  • SEARCH
  • 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 907171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:30:35+00:00 2026-05-15T16:30:35+00:00

Is Mercurial always using the external merge tools when two branches that are merging

  • 0

Is Mercurial always using the external merge tools when two branches that are merging have changes to the same file?

Or does it first see if it can merge the file itself, and only punting to the external tool if it can’t?

The reason I’m asking is that I am (once again) re-reading the tutorial written by Joel Spolsky on Mercurial and one thing he says, when comparing how Subversion and Mercurial is merging is that:

By contrast, while we were working separately in Mercurial, Mercurial was busy keeping a series of changesets. And so, when we want to merge our code together, Mercurial actually has a whole lot more information: it knows what each of us changed and can reapply those changes, rather than just looking at the final product and trying to guess how to put it together.

Only, my experience tells me that it seems to involve the external merge tool when two branches have changes to the same files. And thus, doesn’t that render the above argument incorrect?

Or should I interpret this as follows:

  • Subversion only merges the final state of the two branches, and has more work to do in a single unit
  • Mercurial merges each changeset individually, which allows it to work with smaller units of changes, with higher chance of merge success

Can someone shed some light on this?


Edit: Let me give an example:

@echo off

setlocal

if exist repo rd /s /q repo

md repo
cd repo
hg init .

rem --- version 0 ---
echo 1 >test.txt
echo 2 >>test.txt
echo 3 >>test.txt
echo 4 >>test.txt
echo 5 >>test.txt
hg add test.txt
hg commit -m "v0"

rem --- version 1 ---
echo 1 >test.txt
echo 2 v1 >>test.txt
echo 3 >>test.txt
echo 4 >>test.txt
echo 5 >>test.txt
hg commit -m "v1"

rem --- version 2 ---
hg update 0
echo 1 >test.txt
echo 2 >>test.txt
echo 3 >>test.txt
echo 4 v2 >>test.txt
echo 5 >>test.txt
hg commit -m "v2"

rem --- merge ---
hg update 1
hg merge 2

This first creates a file with the following content:

1
2
3
4
5

Then it changes it to:

1
2 v1
3
4
5

Then it goes back to the initial version (changeset), and changes it to:

1
2
3
4 v2
5

Then it attempts to merge the two.

Now, according to the (currently) single answer, this should not pose a problem, since the changes are not in conflict.

However, at this point, Beyond Compare (my external merge tool) is invoked.

  • 1 1 Answer
  • 1 View
  • 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-15T16:30:36+00:00Added an answer on May 15, 2026 at 4:30 pm

    The mergetool is invoked only in case there’s a conflict that needs to be resolved. Changes to the same file in different branches constitutes such a conflict.

    Other than that, the actual merge algorithm isn’t changeset based, it’s file based to allow for best merge results. See the Mercurial Wiki for more details.

    Mercurial leaves your merge uncomitted, so you have a chance to check your code before comitting the merge changeset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For two changesets X and Y of the same Mercurial repository, does following condition
does Mercurial have an HTTP protocol we could browse files/folders/branches instead of clone/pull changesets?
Does Mercurial offer any type of extensions that offer functionality similar to TFS's work
I have a mercurial repository that is not accessible by Http. I can't figure
I have a site/backoffice solution that works with this structure: /bo // mercurial repo
've written two functions in a file commit_hooks.py that I want to run before
Recently, I've started experimenting with Mercurial, due to the fact that it always attracted
What are some useful Mercurial hooks that you have come across? A few example
When we merge changes from our Mercurial feature release repositories into our trunk repository,
I am trying to get Mercurial hgweb working using ISAPI following those two links

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.