How does mercurial handle splitted files? What will happen if I create a branch and split a file. Can I easily pull changes from another branch which modifies the original, unsplitted file?
Asked
Active
Viewed 457 times
6
-
1What do you mean by "splitted files"? Do you mean that you create a branch and then split the contents of the file into two new files? Or do you just mean changing the file in both branches? – Steve Losh Oct 22 '09 at 14:01
-
1I am into programming and plan to split a God class into several smaller classes. This means I want to split the content of the god-class-file within my branch into several other files. I'd like to know if mercurial can then apply chunks/changes which were made in the original file (in the default branch), to e.g. a function which now resides in another file in my refactoring branch. – Miguel Malac Oct 22 '09 at 19:27
2 Answers
7
I just did a little experiment. I created one repository (foo
) with one big file. Then I cloned that into bar
, used hg cp
to copy the file into two files, and removed one half in both files. Then I made a change affecting the whole file in foo
, and merged that into bar
.
As a result, the parts contained by the respective split file were merged correctly, while I got a conflict for the removed parts: my local version was empty, while the other version was the change from foo
.
So if you're happy with removing these kinds of conflicts every time you merge, this might be good enough for you.

legoscia
- 39,593
- 22
- 116
- 167
2
After reading the clarification comment, the answer is no. Mercurial tracks files, not hunks of code, so it can't do that as far as I know.

Steve Losh
- 19,642
- 2
- 51
- 44