Merge internals

a rmand xerxes83 at gmail.com
Tue Jul 3 05:29:56 CDT 2007


I hope I can post my question about the internal workings (design) of
Mercurial here as the information I am looking for is similar to the
information provided in the "DeveloperInfo" section of the website.

My question is basically: how does merging several changesets work? Does
Mercurial merge the difference between applying all the changesets pulled in
and the common root to the working directory (like SVN)? Or does Mercurial
try to apply the patches one by one (like Darcs does)? And if the first is
the case, how are renames handled?

To make things a bit more clear, here is an example:

# Initial version

a.txt
-------------
line 1
line 2
line 3

$ hg commit

#  Clone of version 1 (Clone A) - Commit 1

$ hg clone /path/to/initial version/
$ hg rename a.txt b.txt
$ hg commit

#  Clone of version 1 (Clone A) - Commit 2

b.txt -> c.txt
-------------
line 1
line 1.5
line 2
line 3

$ hg rename b.txt c.txt
$ hg commit

#  Clone of version 1 (Clone B) - Commit 1

$ hg clone /path/to/initial version/

a.txt
-------------
line 1
line 2
line 3
line 4

$ hg commit

Now suppose all the changes are committed and the owner of repository "Clone
B" pulls in the changes from repository "Clone A" ($ hg pull /path/to/Clone
A/). How would Mercurial proceed in merging the patches?

1) Mercurial calculates that file a.txt and file c.txt are in fact the same
and runs an external merge (so Mercurial does not care about the contents of
the files)
2) Mercurial renames file a.txt to b.txt, then b.txt to c.txt and knows that
line 1.5 should be inserted at the second line of c.txt
3) Neither of the above options is correct

Thanks in advance for helping me. I hope that with this information and
section 4.4.3 of the Mercurial book I can finish my paper.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20070703/8f0d6c64/attachment.htm 


More information about the Mercurial-devel mailing list