Fwd: Merging a Mercurial repository back into Subversion
karltk wrote:
In a recent project, I forked an upstream SVN repository into a new Mercurial repo, to do some exploratory programming. The exploration proved very fruitful, so I decided to merge the code back into the upstream SVN repo.
Should be simple, right? Wrong. For posterity, here’s a high-level…
This is definitely the best guide I found on this topic. If you want to convert an existing mercurial repository into an subversion repository the best way is to collapse all branched commits as described by karltk, because SVN needs a linear history when converting from hg to SVN. When collapsing, the -f switch may useful if commits come from different authors.
I modified the toolchain a little bit:
As soon as all entries are collapsed in hg-repos and the history is linear (check with hg view or hg glog), convert hg-repos to a subversion-repository with hg convert:
hg convert --dest-type svn repos_hg/ repos_svn
If you get abort: svn exited with status 256, add —debug and try to fix the problem. In my case I got this error: svn: Entry ‘/path/to/file’ has unexpectedly changed special status
svn st display one or more files with a tilde in front of the name, so just delete the special-properties:
svn propdel svn:special file
When the file is repaired you can start hg convert again with the same arguments, and everything should be fine.
Because I want to integrate the converted SVN-Repos to the central SVN-Repos, dump this SVN-Repos afterwards and import it under a new project-folder in the central SVN-Repos:
svn mkdir svn://svn_host/path/to/project
svnadmin dump repos_svn > repos_svn.dump
svnadmin load /path/to/svn --parent-dir path/to/project < repos_svn.dump
The last step takes some time, and requires that you work on the same machine where the central svn-repos is. When everything goes fine, you have fully converted your mercurial-repository into an existing subversion-repository.
Because we want to continue to work with mercurial, just clone the repository from svn by hg:
hg clone file://path/to/svn/path/to/project project