fooyeahcode

Text

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
via karltk
Posted on Saturday, March 5 2011. Tagged with: svnsubversionmergemercurialimporthgexportconvertcollapse
27
Notes
  1. slowercarton liked this
  2. celebsbrutalsmalltits liked this
  3. interracialdrunksmalltits liked this
  4. pleasebeauti liked this
  5. t4kr reblogged this from fooyeahcode
  6. fooyeahcode reblogged this from karltk and added:
    This is definitely the best guide...found on this topic. If you want to convert
  7. karltk posted this
fooyeahcode

When I am programming, I am at a nexus. My thoughts become concrete. My ideas transform illusion into reality. The structure of existence is remade before my very eyes. I become a vessel for the creative force of the universe. I am carried aloft as if on the wings of dragons. Why should I care if nobody knows my name?

The Hacker Ethic
Ask me anything Submit
Previous Next