0
votes

I am trying to convert a subversion (svn) repository to mercurial (hg). In the past the svn repository project folder was renamed several times. The following command is partially successful in converting the svn project to hg:

hg convert svn://localhost/project project-hg

This converts from the latest revision back to a revision at which the svn project folder was last renamed. At this point the converted hg repository (changeset 0) just contains addition operations for all of the files within the repository (the file contents are the same as when the svn rename took place).

I would like to preserve the history of the original svn project within the hg project all the way back to revision 0 but am not sure how to overcome the rename problem(s).

2

2 Answers

0
votes

Try the conversion with hgsubversion.

0
votes

Here is a script I just used to convert my project with 1 rename to mercurial. You must run this in an empty directory as it does rm -rfv * each iteration:

#!/bin/bash
set -e
svnpath=svn://host/repo/project
hg init
for r in $(svn log $svnpath | egrep -o '^r[0-9]+' | tac); do
  rm -rfv *
  svn export --force -r $r $svnpath .
  hg addremove -s 50
  message="$(svn log -c $r $svnpath | tail -n +4 | head -n -1)"
  echo "$message" >&2
  changes="$(hg st)"
  [[ "$changes" ]] && hg commit -m "$message"
done