我正在寻找一种工具来将一些SVN存储库迁移到Mercurial,包括历史记录,标签等。
我正在使用TortoiseHg(Windows x32),因此ConvertExtensions将被丢弃。有关如何在Linux机器上执行此过程的一些信息(hgsvn),但我没有可用的Linux机器。
我可以在Windows上使用这些Python脚本吗?如果是这样,我需要做什么?或者,我可以使用哪些其他工具来完成此过程?
基本上,我如何将SVN项目转换为Mercurial?
答案 0 :(得分:92)
我必须自己解决这个问题。我有一台带有VisualSVN Server的独立Windows服务器的Windows XP机器。
我还安装了TortoiseHG以及CollabNet Subversion Command-Line Client。
<强> <Enable Convert Extension w/ Tortoise Hg 2>
强>
非常感谢bgever在使用TortoiseHg 2.0的评论中指出,启用转换扩展比以往更容易。正如他所说的
使用TortoiseHG 2.0已经完成了 更简单:启动TortoiseHG “开始”菜单中的“工作台”。选择 档案 - &gt;设置。选择扩展程序 从列表中。检查'转换' 复选框并单击确定。而已!没有 需要尝试生成配置 文件再次在文件中搜索 系统。 - bgever 3月11日7:56
<强> </Enable Convert Extension w/ Tortoise Hg 2>
强>
<强> <Enable Convert Extension Manually>
强>
要将存储库从SVN转换为HG,我按照以下步骤操作:
1)打开C:\ Program Files \ TortoiseHg \ Mercurial.ini
修改强>
仅供参考 - Tortoise Hg已将此文件迁移至
该文件大部分都是空的,您只需列出您要覆盖的内容。如果这就是你所拥有的,那么简单地将这两行添加到文件的最后:
[extensions]
convert =
2)搜索以
开头的行[扩展]
3)在它下面你会看到一个关键字列表,每行都用分号(;)注释
4)找到说
的行; convert =
并删除分号,使其读取
convert =
<强> </Enable Convert Extension Manually>
强>
5)打开命令提示符并导航到您希望创建新hg文件夹的目录(该进程将在命令提示符打开的目录中创建名为yoursvnreponame-hg的新文件夹)。 / p>
6)使用此命令
hg convert file:/// y:/ yoursvnreponame
我发现转换工具可能存在网络存储库的问题,所以我不得不将驱动器映射到它,但这对我来说效果很好。
答案 1 :(得分:8)
答案 2 :(得分:7)
Mercurial有built-in conversion extension for this。
答案 3 :(得分:5)
要将SVN Repo转换为HG Repo并将其复制到其他服务器,您需要做一些事情。
convert
扩展名添加到Tortoise。从“开始”菜单启动TortoiseHG Workbench。选择File -> Settings
。从列表中选择Extensions
。选中convert
复选框,然后点击确定。首先转换......
\\server\folder
不要映射SVN Repo文件夹本身。映射它上面的文件夹)给映射的驱动器一个字母,如Y:\
CD /D Y:\
Y:\
提示符下键入:hg convert y:/RepoName
(使用当前回购的名称)注意前后斜杠。命令中的一个是正斜杠。此外,如果名称包含空格,请将名称放在引号中。 (即Y:/"My Repo folder"
)第二次克隆......
File -> Clone Repository
答案 4 :(得分:3)
没有人仍然没有提及hgsubversion(Extension Wiki),这可以做到这一点而几乎没有任何头痛(不包括罕见案例和特定树)。
只需添加扩展程序,启用它,然后hg clone SVN_REPO
添加到本地mercurial repo
答案 5 :(得分:1)
如何将subversion存储库转换为Mercurial?
您必须安装svn-win32-1.4.6命令行工具,然后将它们添加到您的路径中。然后,您必须启用转换扩展。此时,您应该能够使用“
hg convert
”命令进行转换。请将有关转换扩展程序的问题/问题直接发送到Mercurial邮件列表或#mercurial
上的irc.freenode.net
。
所以显然这是可能的 - 我正在使用Linux,所以我没有尝试过自己。
答案 6 :(得分:0)
我刚刚将带有HTTP身份验证的远程SVN仓库转换为Mercurial仓库,让我告诉您,目前还没有很多关于如何执行此操作的文档。我必须使用源包下载Mercurial源并单独安装它,这样SVN绑定将以正确的方式工作。
我安装它像:
python setup.py install
在我的Server 2003框中运行正常。我现在可以通过这样的方式转换SVN repo:
python c:\python26\scripts\hg convert <remote repo>
Mercurial网站上的ConvertExtension文档并不十分清楚,但确实如此:
没有办法安装 Subversion绑定到[Mercurial的]内置 Python库。所以你需要使用 一个Mercurial安装在一个 独立的Python
所以现在我只使用独立版本进行转换,使用TortoiseHg进行实际的VCS工作。
答案 7 :(得分:0)
一个价格的两个答案......
如果它是一个公开的,开源的仓库,你可以使用http://svn2github.com/add/大约半小时将该仓库克隆到GitHib,然后将其拉入Hg。
< / LI>使用 hg convert
的优点是可以恢复。将SVN转换为Hg可能需要天。如果你停止它,它将从它停止的地方恢复。
下面是我写的批处理文件,因为Codeplex SVNbridge垃圾。在这个例子中的回购确实花了几天时间来获取整个历史记录(我在澳大利亚所以延迟可能是一个因素)。我想它认为TFS服务器在某个地方很好。
这个批处理文件可以随时运行,以便从SVN源中获取更新,如果它们恰好是地球上实际仍然使用SVN的唯一数据。我没有测试过,所以看看如果你这样做会发生什么,如果我是你,如果你要编辑回购,我会放弃原来的分支。
如果您克隆Hg仓库,则robocopy shamap
内容是维护SVN历史记录,shamap是短暂的 - 检查批处理文件&amp; shamap(我会在新的分支上执行此操作)。
批次......
@echo off
mode con:cols=100 lines=800
:: Change the SVN remote name here
::
set remote=https://cinch.svn.codeplex.com/svn
::
title Fetching SVN from %remote%. This could take...DAYS
echo .
echo Fetching SVN checkins from %remote%
echo .
echo Dependencies: Tortoise Hg and hg.exe in the Path would be ideal.
echo using hg convert
echo .
echo First, I will make a backup of shamap in the hg repo folder.
echo If shamap in .hg\ is newer then it will be copied to the repo.
echo You should commit it so hg clones of this repo work with this.
echo Commit this .BeeyATch file as well.
echo shamap keeps track of what has been fetched from SVN.
echo ok, that ends the educational part of this script...
echo Now I will fetch SVN changes from
echo %remote%
echo ...
echo ...(this could take quite some time)...
echo ...DAYS...yes...DAYS
echo ...especially if it's fecking Codeplex SVN...
echo .
echo If this craps out just run it again - it will resume from where it left off.
echo and fetch the rest...eventually
echo .
echo Control C to abort or any other key to start:
echo .
pause
echo .
:: http://mercurial.selenic.com/wiki/ConvertExtension <== see for details of shamap
:: copy the shamap from the original convert into the .hg folder unless it is already there & newer
:: don't panic if shamap is much bigger than the original - diff it to see why
robocopy .\ .\.hg\ shamap /XO
robocopy .\.hg\ .\ shamap /XO
echo .
hg convert --verbose --debug %remote% "%CD%"
echo .
echo .
echo Finished fetching from %remote%
title Finished fetching from %remote%
echo Any key to Exit
echo .
pause
exit
答案 8 :(得分:0)
使用Mercurial的convert
extension:
convert=
添加到.hgrc的[extensions]
部分,如下所示:
[扩展]
转换=
sudo apt-get install python-subversion
hg convert
命令
hg convert -h
寻求帮助hg convert http://[svnserver]/[Project] --source-type svn [DestinationDir]
(参见注释2) hg push https://[mercurialserver]/[Project]
注意:您甚至可以重复执行hg convert命令,以包含上次转换后在svn存储库中所做的新更改。
note 2 :当hg转换无法使用http://
或svn://
时,您可以首先签出Subversion存储库(或更新现有存储库)并进行转换使用当地结账;例如:hg convert [DirectoryOfLocalCheckout] --source-type svn [DestinationDir]