Mercurial How To Merge 2 Repositories that share a common ancestor but are not clones of the same repo

StackOverflow https://stackoverflow.com/questions/2442874

  •  19-09-2019
  •  | 
  •  

Question

I am using hg-subversion, and I have 2 different hg repositories one from our svn trunk, and one from a branch of the trunk. I would like to link them somehow. At some point in the history both Hg repositories will be identical is there some way to join them?

In other words is there a way to relate the repositories from within Hg?

The technique I am currently using is to just export the second repository over top of the working copy of the revision they share, and then commit that working copy as a branch in Hg, but I lose the history this way.

Any advice would be great

Was it helpful?

Solution

You could try importing the two repos into one as if unrelated, then merging them. (When you say they share a common ancestor, do you mean that those ancestors have the same revision ID? If so there is a good chance that this will work well.)

hg clone repoA
hg pull -f repoB # may not need -f
hg merge

OTHER TIPS

Can you re-clone the Subversion repository, giving the root of the Subversion repository as argument instead of trunk or one of the branches? I used hg clone svn+ssh://foo/bar/baz once, where svn+ssh://foo/bar/baz/trunk was the trunk and svn+ssh://foo/bar/baz/branches/quux was a branch, and in the end I had two named branches in Mercurial, the "default" branch representing Subversion trunk and the "quux" branch representing the like-named Subversion branch.

If you have outgoing changesets in your existing hg repos, you might be in a bit of a bind there. If there are just a few outgoing changesets, it might work to enable the mq extension and to convert the changesets into patches. These patches can then be re-applied on the new clone (in the appropriate named branch) and eventually pushed to Subversion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top