Reparenting in Mercurial: how can two independent svn clones be combined?

Here's the situation: the developer Foo created an hg repo from our svn repo. Foo hg repo was just a small clone of the chest in svn (no svn branches, tags, etc., but the story was incomplete [about 100 changes]). The developer panel did the same, but cloned all svn repositories, including all history, branches, tags, etc. Both Foo and Bar did extensive development in their repositories.

There is a common SVN ancestor for both repositories, but each hg repo has a different version number for it. I would like to review Foo changes from a common ancestor on Bar repo. Here is a diagram of what I'm looking for:

Foo repo:

C'-D'-EF---G \ / HI 

Repo Bar:

 ...ABCDJK---L \ / MN 

C, C 'and D, D' have the same content, but different version numbers and comments.

Goal:

 ...ABCD--EF---G \ \ / \ HI \ JK---L \ / MN 

I have run out of ideas on how to do this. I tried converting --splicemap splice.map [the splice.map file contained ED] (did nothing). Clone -f managed to get everything in one repo, but they seem to be independent trees. After clone -f, I tried rebase -source E -dest D -detach, but it just crashed :(

Ideas?

I know that changing the history will invalidate any cloning of the repositories, this is not a problem in this case. All users will be re-cloned from the results of these efforts.

+6
source share
3 answers

SOLVE!

At first, I did not notice that my alleged common ancestor was not exactly the same. During the conversion svn-> hg Foo repo, the $ ID $ lines were expanded, but Bar repo was not created. Step 1 below was a simple fix to create a REAL common ancestor.

The following steps allowed me to fulfill my goal:

1 - Make sure the alleged common ancestor (D and D) is actually identical. If not, create a new splicing point (S) for them in the repo bar. S should exactly match the contents of D 'in my example.

  ... ABCD - JK --- L
               \ \ /
                S MN

2 - Trim the history of the Foo repository to remove duplicate history, including D ', using

  hg convert --splicemap TrimSplicemap Foo FooTrimmed

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

  E 00000000000000000000000000000000000000000000

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

  cd FooTrimmed
     hg strip C '

4 - Use hg convert again to merge Foo, deprived of repo on Bar repo when fixing 'S'

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

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

  E 's

It must be !: D

+2
source

You may be able to accomplish this using Mercurial Queues .

  • Import each set of changes from repo Foo into the patch queue.
  • Go to the Bar repository.
  • Update Bar to a set of changes that is a common ancestor.
  • Import the patch queue to Bar .
  • Apply the patch queue.

This will change the commit identifiers of all Foo patches, but allow you to save the entire history and merge your shared projects.

+1
source

We talked about this today at the IRC, and my advice was to simply pull both into the same repo and give it two roots. The heads will be exactly what you want, and the rest does not really matter.

If you just can't feel it (you think people use the story / blame more than they really do), then I think your splicemap should have:

 ED 

in in since you are trying to get E parent to be D (not D)

+1
source

Source: https://habr.com/ru/post/887380/


All Articles