Convert Subversion repository to Mercurial

泄露秘密 提交于 2020-01-02 13:11:36

问题


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.


回答1:


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!-)




回答2:


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).




回答3:


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

svn co http://myversioncontrorepositoryhere localrepo
hg convert localrepo



回答4:


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.



来源:https://stackoverflow.com/questions/1657652/convert-subversion-repository-to-mercurial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!