Reparenting in Mercurial: how does one bring two independent svn clones back together?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 05:56:47

SOLVED!

One thing I didn't notice initially was that my presumed common ancestor wasn't exactly the same after all. During the svn->hg conversion of Foo's repo, the $ID$ strings were expanded, but were not in the creation of Bar's repo. Step 1 below was a simple fix to create a REAL common ancestor.

The following steps allowed me to accomplish my goal:

1- Ensure that the presumed common ancestor (D and D') are actually identical. If not, create a new splice point for them (S) in Bar's repo. S should exactly match the content of D' in my example.

    ...A-B-C-D--J-K---L
              \  \   /
               S  M-N

2- Trim the history of Foo's repo to remove the duplicate history, including D', with

    hg convert --splicemap TrimSplicemap Foo FooTrimmed

TrimSplicemap contents: (where E is the full hash of E)

    E 0000000000000000000000000000000000000000

3- Use hg strip to remove the disconnected, redundant history

    cd FooTrimmed
    hg strip C'

4- Use hg convert again to splice Foo's stripped repo onto Bar's repo at commit 'S'

    cd ../Bar
    hg convert --splicemap FooBarSplicemap ../FooTrimmed .

FooBarSplicemap contents: (where E' is the NEW hash for E in the FooTrimmed, and S is the hash of S)

    E' S

That should do it! :D

You might be able accomplish this using Mercurial Queues.

  1. Import every changeset from repo Foo into a patch queue.
  2. Go to the Bar repo.
  3. Update Bar to the changeset that is the common ancestor.
  4. Import the patch queue into Bar.
  5. Apply the patch queue.

This would change the commit IDs of all the Foo patches, but still allow you to keep the entire history and merge their dev repos together.

We talked about this today in IRC and my advice was to just pull both into the same repo and let it have two roots. The heads will be exactly as you want and the rest really doesn't matter.

If you just can't stomach that (you're imagining people use history/blame more than they really do) then I think your splicemap should have:

E D

in in since you're trying to get E's parent to be D (not D')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!