0

I'm trying to merge 3 repos into one using mercurial. Repo A is the one I'd like to merge Repo B and C into. These are AS3 projects and A relies on files from B and C.

I tried following the steps from this post: Merging two different repositories

However, I think this depends on the fact that the repos don't share anything. In my case since the project have the same file structure, it seems like it just overwrites the previous one (example: both have /images folder).

Any suggetions?

Community
  • 1
  • 1
cjr
  • 520
  • 2
  • 7
  • 22
  • 1
    I think we need a bit more information on what outcome you're aiming for with the merge. So the projects have the same structure and a merge will mean they all use the same images folder. Is that not what you want if they're supposed to be sharing this data? What would you like to see the final structure of the working directory that contains a merged A, B and C look like? – Nanhydrin Aug 12 '15 at 14:08
  • Is it customer-specific changes of single project or... ? Write more *technical* details, guessing is bad – Lazy Badger Aug 12 '15 at 15:31
  • @Nanhydrin I do want to this to happen, however, it seems by following the process in the post above, it ends up the repo I force merge in (B forced merged into A) results in B override A rather than sharing. Basically, I am aiming for these 3 projects that contain similar structure to be merge into 1 project maintaining this same structure(thus maintaining the commit history). – cjr Aug 12 '15 at 21:03
  • Are you doing the revert step that they specify in that process because that will wipe out all your changes from one or the other? – Nanhydrin Aug 13 '15 at 07:13
  • Why yes I am. (I'm pretty noob at this repo stuff so I just followed the step by step). – cjr Aug 13 '15 at 16:29

1 Answers1

1

Let's make sure we fully understand our goal here:

We want to keep all the files from all three projects. If the same file name appears in multiple repositories, we want to do what?

  • Keep the version from A (or B, or C): We can perform the merge using --tool internal:local or internal:other as appropriate. Local keeps the version we currently have, other keeps the version we're merging in.
  • Merge them together using Mercurial's standard three-way merging logic (which won't work very well since we don't have common ancestry): --tool internal:merge or just don't specify the option at all. This will likely produce ugly merge conflicts which we will have to resolve.
  • This can't (shouldn't) happen in the first place: --tool internal:fail will throw an error in this case and won't try to merge the files.

So, here's the modified procedure:

$ hg init combined
$ cd combined
$ hg pull ../A
$ hg update
$ hg pull ../B --force
$ hg merge --tool something # see above
$ # Manually fix up any files that throw merge conflicts
$ hg resolve --all -m  # Mark all files as resolved, only if there were conflicts
$ hg commit -m "Merge A and B"
$ hg pull ../C --force
$ hg merge --tool something # see above
$ # Fix conflicts
$ hg resolve --all -m  # Only if there were conflicts
$ hg commit -m "Merge A+B and C"
Kevin
  • 28,963
  • 9
  • 62
  • 81