如何在 Windows 上从 SVN 迁移/转换到 Mercurial (hg)
我正在寻找一个工具来将几个 SVN 存储库迁移到 Mercurial,其中包含历史记录、标签等。
我使用的是 TortoiseHg (Windows x32),因此 ConvertExtensions 被丢弃。 有一些关于如何在 Linux 机器上执行此过程的信息 (hgsvn),但我不知道没有可用的 Linux 机器。
我可以在 Windows 上使用这些 Python 脚本吗? 如果是这样,我需要做什么? 或者,我可以使用哪些其他工具来完成此过程?
基本上,如何将 SVN 项目转换为 Mercurial?
I'm looking for a tool to migrate a couple of SVN repositories to Mercurial, with history, labels and so on.
I'm using TortoiseHg (Windows x32), so ConvertExtensions are discarded. There's some info on how to do this process on a Linux box (hgsvn), but I don't have a Linux machine available.
Can I use those Python scripts on Windows? If so, what do I need to do it? Or, what other tools can I use to do this process?
Basically, how can I convert an SVN project to Mercurial?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我只需要自己解决这个问题。 我有一台 Windows XP 计算机,有一个单独的 Windows 服务器托管 VisualSVN Server。
我还安装了 TortoiseHG 以及 CollabNet Subversion 命令行客户端。
<启用带有 Tortoise Hg 2 的转换扩展>
非常感谢 bgever< /a> 在评论中指出,使用 TortoiseHg 2.0,启用转换扩展比以往任何时候都更容易。 正如他所说
<
Enable Convert Extension Manually>
要将存储库从 SVN 转换为 HG,我按照以下步骤操作:
1) 打开 C:\Program Files\TortoiseHg\Mercurial.ini
编辑
仅供参考 - Tortoise Hg 已将此文件迁移到
该文件大部分为空,您只需列出您想要覆盖的内容。 如果这就是您所拥有的,只需将这两行添加到文件的最后:
2) 搜索以
3) 在其下方,您将看到关键字列表,每行都用分号 (;) 注释掉
4) 找到显示以下内容的行
并删除分号,使其显示为
5) 打开命令提示符并导航到您要在其中创建新 hg 文件夹的目录(该过程将在命令提示符打开的目录中创建一个名为 yoursvnreponame-hg 的新文件夹)。
6)使用该命令
我发现转换工具在网络存储库方面可能存在问题,因此我必须将驱动器映射到它,但这对我来说效果很好。
I just had to tackle this problem myself. I have a windows XP machine with a separate windows server hosting VisualSVN Server.
I also have TortoiseHG installed as well as the CollabNet Subversion Command-Line Client.
<Enable Convert Extension w/ Tortoise Hg 2>
Many thanks to bgever for pointing out in the comments that with TortoiseHg 2.0, enabling the convert extension is easier than ever. As he says
</Enable Convert Extension w/ Tortoise Hg 2>
<Enable Convert Extension Manually>
To convert a repository from SVN to HG, I followed these steps:
1) Open C:\Program Files\TortoiseHg\Mercurial.ini
EDIT
FYI - Tortoise Hg has migrated this file to
That file will be mostly empty and you'll just list what you'd like to override there. If that's what you have, simple add these two lines to the very end of the file:
2) Search for the line that begins with
3) Below it you'll see a list of keywords, commented out with a semicolon (;) on each line
4) Find the line that says
and delete the semicolon so it reads
</Enable Convert Extension Manually>
5) Open the command prompt and navigate to the directory that you'd like the new hg folder created in (the process will create a new folder called yoursvnreponame-hg in the directory that the command prompt is open to).
6) Use this command
I found that the convert tool can have problems with networked repositories, so I had to map a drive to it, but this worked just fine for me.
Mercurial 有一个用于此目的的内置转换扩展。
Mercurial has a built-in conversion extension for this.
要将 SVN Repo 转换为 HG Repo 并将其复制到不同的服务器,您需要一些东西。
convert
扩展添加到 Tortoise。 从“开始”菜单启动 TortoiseHG 工作台。 选择文件 -> 设置
。 从列表中选择扩展
。 选中转换
复选框并单击“确定”。首先是转换……
\\server\folder
不要映射 SVN Repo 文件夹本身。映射其上方的文件夹)为映射的驱动器指定一个字母,例如Y:\
CD /DY:\
Y:\
提示符处键入:hg Convert y:/RepoName
(使用当前的存储库)请注意正斜杠和反斜杠。 命令中的那个是正斜杠。 另外,如果名称中有空格,请将名称放在引号中。 (即Y:/"My Repo 文件夹"
)其次是克隆...
文件 -> Clone Repository
To convert an SVN Repo to an HG Repo AND copy it to a different server, you will need a few things.
convert
extension to Tortoise. Start the TortoiseHG Workbench from the Start menu. SelectFile -> Settings
. SelectExtensions
from the list. Check theconvert
checkbox and click OK.First the conversion…
\\server\folder
Do not map the SVN Repo folder itself. Map the folder just above it) Give the mapped drive a letter, likeY:\
CD /D Y:\
Y:\
prompt type:hg convert y:/RepoName
(use the name of the current Repo) Be careful of the forward and back slashes. The one in the command is a forward slash. Also, if the name has spaces, put the name in quotations. (i.e.Y:/"My Repo folder"
)Second the cloning…
File -> Clone Repository
仍然没有人不提到 hgsubversion (扩展 Wiki),几乎可以轻松做到这一点(不包括罕见情况和特定树)。
只需添加扩展,启用它并
hg clone SVN_REPO
到本地 Mercurial 存储库Nobody still does not mention hgsubversion (Extension Wiki), which can do it without almost any headache (excluding rare cases and specific tree).
Just add extension, enable it and
hg clone SVN_REPO
to local mercurial repo这是在 TortoiseHg 常见问题解答:
所以这显然是可能的——我正在使用 Linux,所以我自己还没有尝试过。
This is in the TortoiseHg FAQ:
So it is apparently possible -- I'm using Linux so I haven't tried myself.
我刚刚将带有 HTTP 身份验证的远程 SVN 存储库转换为 Mercurial 存储库,让我告诉您,关于如何执行此操作的文档并不多。 我必须下载 Mercurial 源代码并使用源代码包独立安装它,这样 SVN 绑定才能正常工作。
我安装它的方式如下:
在我的 Server 2003 机器上运行得很好。 我现在可以通过执行以下操作以正确的方式转换 SVN 存储库:
Mercurial 站点上的 ConvertExtension 文档不是很清楚,但它确实这么说:
所以现在我只使用独立版本进行转换,并使用TortoiseHg 进行实际的VCS 工作。
I just converted a remote SVN repo with HTTP auth to a Mercurial repo, and let me tell you, there's not a lot of documentation on how to do this. I had to download the Mercurial source and install it stand-alone, using the source package, that way the SVN bindings will work the right way.
I installed it like:
Which worked just fine on my Server 2003 box. I can now convert an SVN repo the correct way, by doing something like this:
The documentation for ConvertExtension on the Mercurial site isn't terribly clear, but it does say this:
So now I just use the stand-alone version for converting, and TortoiseHg for actual VCS work.
迟到总比不到好……
一个的价格有两个答案……
如果它是一个公共的开源存储库,您可以使用 http://svn2github.com/add/ 花了大约半个小时将该存储库克隆到 GitHub,然后将其拉入 Hg。
使用
hg Convert
的优点是可以恢复。 将 SVN 转换为 Hg 可能需要几天。 如果您停止此操作,它将从停止的位置恢复。下面是我写的一个批处理文件,因为 Codeplex SVNbridge 很垃圾。 此示例中的存储库确实花了几天时间来获取整个历史记录(我在澳大利亚,因此延迟可能是一个因素)。 我想它给了某个地方的 TFS 服务器一个很好的打击。
如果它们恰好是地球上唯一仍在使用 SVN 的更新,则可以随时运行此批处理文件以从 SVN 源提取更新。 我还没有测试过它,所以看看如果你这样做会发生什么,所以如果我是你,如果你要编辑存储库,我会放弃原始分支。
如果您克隆 Hg 存储库,
robocopy shamap
的作用是维护 SVN 历史记录,shamap 是短暂的 - 检查批处理文件和文件。 shamap(我会在一个新分支上这样做)。该批次...
better late than never ...
Two answers for the price of one ...
If it is a public, open-source repo you could just use http://svn2github.com/add/ which took about half an hour to clone that repo to GitHib and then just pull that into Hg.
The advantage of using
hg convert
is that is can be resumed. Converting SVN to Hg can take days. If you stop this it will resume from where it left off.Below is a batch file I wrote because Codeplex SVNbridge rubbish. The repo in this example did take a couple of days to fetch the whole history (I'm in Australia so the latency may have been a factor). I'd like to think it gave a TFS server somewhere a good beating.
This batch file can be run at any time to pull updates from the SVN source if they happen to be the only ones left on earth actually still using SVN. I haven't tested it so see what happens if you do this so if I were you I'd abandon the original branch if you're going to edit the repo.
The
robocopy shamap
stuff is to maintain the SVN history if you clone the Hg repo, shamap is ephemeral - check the batch file & shamap in (I'd do that on a new branch).the batch...
使用 Mercurial 的
convert
扩展: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 存储库中所做的新更改。
注释 2:当 hg Convert 无法使用
http://
或svn://
工作时,您可以先查看 Subversion 存储库(或更新现有的)并使用本地结帐进行转换; 示例:hg Convert [DirectoryOfLocalCheckout] --source-type svn [DestinationDir]Using the
convert
extension of Mercurial:convert=
to the[extensions]
section of .hgrc like this:sudo apt-get install python-subversion
hg convert
commandhg convert -h
for helphg convert http://[svnserver]/[Project] --source-type svn [DestinationDir]
(see note 2)hg push https://[mercurialserver]/[Project]
note: you can even repeat the hg convert command to include new changes made in the svn repository after the previous convert.
note 2: When hg convert doesn't work using
http://
orsvn://
you could first checkout the Subversion repository (or update an existing one) and convert using the local checkout; example:hg convert [DirectoryOfLocalCheckout] --source-type svn [DestinationDir]