3

I am trying to convert an SVN repository to Mercurial, but I'm having some troubles. These are the steps I've taken: (I am on Windows)

Turned on "convert" in the extensions

Opened a command window, and typed:

hg convert http://myversioncontrorepositoryhere

It says it's initializing the destination folder and then asks:

Enter username for Administration at http://myversioncontrorepositoryhere:

type my username then

 in Administration at http://myversioncontrorepositoryhere:

I assume this is my password, but it just loops back to

Enter username for Administration at http://myversioncontrorepositoryhere:

What am I doing wrong? I'm very sure I'm typing in my username and password correctly.

Jonik
  • 80,077
  • 70
  • 264
  • 372
Paul
  • 9,409
  • 13
  • 64
  • 113

4 Answers4

7

I don't know what may be going wrong, but I'd like to suggest a workaround (which is the only way I've personally used for this task!): first svnsync the svn project to make a local mirror, then hg convert that local mirror -- that's what O'Sullivan suggests in his book (this URL has, as "sample from the book", exactly the relevant appendix for importing projects from other VCSs to hg -- with special emphasis on svn!), though his suggestion is mostly inspired by considerations of speed I suspect that following it has also saved me authentication and authorization hassles, and I hope it could do the same for you!-)

anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140
Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
  • I'm trying to do an svnsync, but i keep getting this error: svnsync: Repository has not been enabled to accept revision propchanges; ask the administrator to create a pre-revprop-change hook So I have enabled the pre-revprop-change hook, but it still happens. – Paul Nov 01 '09 at 17:48
  • Cancel that - the hook that's in there doesn't work under windows, it needs to contain "@exit 0" – Paul Nov 01 '09 at 17:56
3

Try hgsubversion instead; it's a lot more robust. I've had a lot of bizarre issues interacting with Subversion's CLI on Windows (mostly resolved by using CMD instead of another shell).

Nicholas Riley
  • 43,532
  • 6
  • 101
  • 124
  • hgsubversion apparently can't cope with non-ASCII filenames, deciding to not interpret them as UTF-8 but Latin 1. Would you know any way around that? – Joey Apr 15 '12 at 14:32
  • File a bug? :) Seriously, it's all Python, it should be able to cope. – Nicholas Riley Apr 15 '12 at 15:33
1

I have had luck fixing the authentication problem by simply converting from a local checkout:

svn co http://myversioncontrorepositoryhere localrepo
hg convert localrepo
jpsecher
  • 4,461
  • 2
  • 33
  • 42
1

In my experience conversion of a real-word Subversion repository with bunch of projects and years of history is a little more involved. Mostly because in Subversion it's fine to have one huge repo for all the stuff. On the contrary Mercurial repositories are advised to be much more fine-grained.

I assume the following Subversion repository layout:

├── project1
│   ├── branches
│   ├── tags
│   └── trunk
│       ├── package1
│       └── package2
└── project2

Conversion should turn package1 and package2 into separate Mercurial repositories with their own history. In this answer I'm interested in single path, but conversion of tags and branches is also possible.

Preparation

I usually do conversion on a remote server with fast connection. For Debian-family the following packages are required.

apt-get install mercurial subversion python-subversion

Then Convert extension should be enabled.

echo -e "[extensions]\nhgext.convert=" >> ~/.hgrc

On Windows make sure you've fulfilled the prerequisites.

Execution

Note, that if you try to do a conversion directly from a remote subversion repo it will likely take hours, so the following creates mirror of the project's path. Then each conversion is a matter of seconds to minutes.

cd /tmp
svnadmin create svn-mirror

# on Windows you may need to look at comments to accepted answer
echo '#!/bin/sh' > svn-mirror/hooks/pre-revprop-change
chmod +x svn-mirror/hooks/pre-revprop-change

svnsync init file:///tmp/svn-mirror svn://subversion.repo/project1
svnsync sync file:///tmp/svn-mirror

echo 'include project1/trunk/package1' > package1-map
echo 'rename project1/trunk/package1 .' >> package1-map    
hg convert --filemap=package1-map svn-mirror package1

echo 'include project1/trunk/package2' > package2-map
echo 'rename project1/trunk/package2 .' >> package2-map    
hg convert --filemap=package2-map svn-mirror package2

Then inside package directory you can run hg serve -p 8080 and clone from http://your.host:8080 with a mercurial client or repo manager like RhodeCode.

saaj
  • 23,253
  • 3
  • 104
  • 105