Merge problems after moving directories in a branch

Gustavo Narea gustavonarea at 2degreesnetwork.com
Wed Apr 7 06:45:52 CDT 2010


Hi, Matt.

On 06/04/10 22:26, Matt Mackall wrote:
> If we do the merge in two steps:
>
> Alice:                   Bob:
> rename foo -> old-foo    edit foo/bar
>                          merge with Alice
> rename new-foo -> foo
>                          merge with Alice
>
> ..you'll get the result you're expecting.
>
> The problem is that you're doing a "shell game" with old and new and
> current with the assumption that Mercurial cares more about rename
> history than about the filenames themselves. But Mercurial assumes that
> if there are files on both sides called "template/mail.html", then it
> should be merging "the mail template". It only goes looking for "the
> thing that used to be the mail template" if it can't find "the mail
> template" on one side.
>   

Thanks for the explanation, but still, I think Mercurial should handle
this situation somehow.

A two-step merge may probably be OK in most situations, but in this case
we needed to have a separate branch to clean up trunk. That cleanup
branch would be too unstable initially, so we really don't want to merge
it into any other branch until we're sure it's stable -- plus, the new
directory names might not be the final ones.

Even if I had only renamed "foo" to "old-foo" first, I wouldn't like to
merge "cleanup" into "trunk" and other branches because I would've had
to change many other files to replace "foo" with "old-foo". And if I
don't edit the other files to update the paths, "trunk" would be broken.
We try to keep "trunk" as stable as possible, free of any experimental
change (specially when it's something that affects thousands of files).

Hence we need a branch which will get merged when it's stable, not sooner.

Also keep in mind that there's another related problem: Mercurial
recreates non-existing directories. In your example, it'll create
"new-foo" if you changed/added something to that directory, even though
"new-foo" is now called "foo" and there's no directory with that name
anymore.

Cheers,

-- 
Gustavo Narea.
Software Developer.
2degrees, Ltd. <http://www.2degreesnetwork.com/>.



More information about the Mercurial mailing list