如何在 Windows 上从 SVN 迁移/转换到 Mercurial (hg)

发布于 2024-07-19 19:44:26 字数 365 浏览 6 评论 0原文

我正在寻找一个工具来将几个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

梦里°也失望 2024-07-26 19:44:27

我只需要自己解决这个问题。 我有一台 Windows XP 计算机,有一个单独的 Windows 服务器托管 VisualSVN Server

我还安装了 TortoiseHG 以及 CollabNet Subversion 命令行客户端

<启用带有 Tortoise Hg 2 的转换扩展>

非常感谢 bgever< /a> 在评论中指出,使用 TortoiseHg 2.0,启用转换扩展比以往任何时候都更容易。 正如他所说

这是用 TortoiseHG 2.0 实现的
更简单:启动 TortoiseHG
“开始”菜单中的工作台。 选择
文件--> 设置。 选择扩展
从列表中。 检查“转换”
复选框并单击“确定”。 就是这样! 不
需要尝试生成配置
不再归档并在文件中搜索它
系统。 – bgever 3 月 11 日 7:56

<

Enable Convert Extension Manually>

要将存储库从 SVN 转换为 HG,我按照以下步骤操作:

1) 打开 C:\Program Files\TortoiseHg\Mercurial.ini

编辑

仅供参考 - Tortoise Hg 已将此文件迁移到

  • XP 或更低版本 - C:\Documents and Settings\USERNAME\Mercurial.ini
  • Vista 或更高版本 - C:\Users\USERNAME\Mercurial.ini

该文件大部分为空,您只需列出您想要覆盖的内容。 如果这就是您所拥有的,只需将这两行添加到文件的最后:

[extensions]
convert =

2) 搜索以

[扩展]

3) 在其下方,您将看到关键字列表,每行都用分号 (;) 注释掉

4) 找到显示以下内容的行

;转换=

并删除分号,使其显示为

转换=

5) 打开命令提示符并导航到您要在其中创建新 hg 文件夹的目录(该过程将在命令提示符打开的目录中创建一个名为 yoursvnreponame-hg 的新文件夹)。

6)使用该命令

hg 转换文件:///y:/yoursvnreponame

我发现转换工具在网络存储库方面可能存在问题,因此我必须将驱动器映射到它,但这对我来说效果很好。

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

With TortoiseHG 2.0 this has been made
much simpler: Start the TortoiseHG
Workbench from the Start menu. Select
File --> Settings. Select Extensions
from the list. Check the 'convert'
checkbox and click OK. That's it! No
need to try to generate the config
file anymore and search it in the file
system. – bgever Mar 11 at 7:56

</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

  • XP or older - C:\Documents and Settings\USERNAME\Mercurial.ini
  • Vista or later - C:\Users\USERNAME\Mercurial.ini

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:

[extensions]
convert =

2) Search for the line that begins with

[extensions]

3) Below it you'll see a list of keywords, commented out with a semicolon (;) on each line

4) Find the line that says

;convert =

and delete the semicolon so it reads

convert =

</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

hg convert file:///y:/yoursvnreponame

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.

樱花落人离去 2024-07-26 19:44:27
  1. 在本地主机上启动 svn 服务器
  2. hg 转换 svn://localhost/your_repo
  3. 完成,因为仅 file:// 协议需要 svn 绑定
  1. startup svn server on localhost
  2. hg convert svn://localhost/your_repo
  3. done, because svn bindings needed only for file:// protocol
罗罗贝儿 2024-07-26 19:44:27

要将 SVN Repo 转换为 HG Repo 并将其复制到不同的服务器,您需要一些东西。

  1. 已安装 TortoiseHG。 (检查当前使用的版本)
  2. Python 已安装。 (检查当前使用的版本)
  3. Python 模块(您可以在 http://pysvn. tigris.org/project_downloads.html
  4. 您需要将 convert 扩展添加到 Tortoise。 从“开始”菜单启动 TortoiseHG 工作台。 选择文件 -> 设置。 从列表中选择扩展。 选中转换复选框并单击“确定”。

首先是转换……

  1. 最好将当前 SVN Repo 所在的文件夹映射到您正在使用的计算机。 (即 \\server\folder 不要映射 SVN Repo 文件夹本身。映射其上方的文件夹)为映射的驱动器指定一个字母,例如 Y:\
  2. 打开一个命令提示符并键入:CD /DY:\
  3. Y:\ 提示符处键入:hg Convert y:/RepoName(使用当前的存储库)请注意正斜杠和反斜杠。 命令中的那个是正斜杠。 另外,如果名称中有空格,请将名称放在引号中。 (即 Y:/"My Repo 文件夹"
  4. 现在它应该正在运行,并将在旧文件夹旁边创建另一个文件夹。 里面应该有一个 hg 文件夹。 它不会被启动,也不要启动!
  5. 转换完成。

其次是克隆...

  1. 打开 TortoiseHG Workbench。 转到文件 -> Clone Repository
  2. Source:输入转换后的存储库的完整路径。
  3. 目标:输入您想要克隆存储库的完整路径。 无需在新目标位置创建文件夹,因为克隆过程将创建该文件夹并对其进行初始化。
  4. 将权限添加到新克隆的文件夹。
  5. 你完成了!!!

To convert an SVN Repo to an HG Repo AND copy it to a different server, you will need a few things.

  1. TortoiseHG installed. (Check to see what version is currently being used)
  2. Python Installed. (Check to see what version is currently being used)
  3. The Python Modules (you can find them http://pysvn.tigris.org/project_downloads.html)
  4. You will need to add the convert extension to Tortoise. Start the TortoiseHG Workbench from the Start menu. Select File -> Settings. Select Extensions from the list. Check the convert checkbox and click OK.

First the conversion…

  1. It is best to map the Folder that the current SVN Repo is in to the computer you are working on. (i.e. \\server\folder Do not map the SVN Repo folder itself. Map the folder just above it) Give the mapped drive a letter, like Y:\
  2. Open a command Prompt and type: CD /D Y:\
  3. At the 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")
  4. Now it should be running and will create another folder alongside the old one. And an hg folder should be inside. IT WILL NOT BE INITIATED, AND DO NOT INITIATE!
  5. The conversion is complete.

Second the cloning…

  1. Open TortoiseHG Workbench. Go to File -> Clone Repository
  2. Source: Enter the full path of the converted repo.
  3. Destination: Enter the full path of where you want the repo cloned. It is not necessary to create a folder at the new destination as the cloning process will create it and initialize it.
  4. Add the permissions to the new cloned folder.
  5. You’re done!!!
橘虞初梦 2024-07-26 19:44:27

仍然没有人不提到 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

悸初 2024-07-26 19:44:27

这是在 TortoiseHg 常见问题解答

如何将 Subversion 存储库转换为 Mercurial?

您必须安装 svn-win32-1.4.6 命令行工具,然后将它们添加到您的路径中。 然后您必须启用转换扩展。 此时,您应该能够使用“hg Convert”命令进行转换。 请将有关转换扩展的问题直接发送至 Mercurial 邮件列表或 irc.freenode.net 上的 #mercurial

所以这显然是可能的——我正在使用 Linux,所以我自己还没有尝试过。

This is in the TortoiseHg FAQ:

How can I convert a subversion repository to Mercurial?

You must install svn-win32-1.4.6 command line tools, then add them to your path. Then you must enable the convert extension. At this point, you should be able to use the 'hg convert' command to do the conversion. Please direct problems/questions about the convert extension to the Mercurial mailing list or #mercurial on irc.freenode.net.

So it is apparently possible -- I'm using Linux so I haven't tried myself.

眼眸印温柔 2024-07-26 19:44:27

我刚刚将带有 HTTP 身份验证的远程 SVN 存储库转换为 Mercurial 存储库,让我告诉您,关于如何执行此操作的文档并不多。 我必须下载 Mercurial 源代码并使用源代码包独立安装它,这样 SVN 绑定才能正常工作。

我安装它的方式如下:

python setup.py install

在我的 Server 2003 机器上运行得很好。 我现在可以通过执行以下操作以正确的方式转换 SVN 存储库:

python c:\python26\scripts\hg convert <remote repo>

Mercurial 站点上的 ConvertExtension 文档不是很清楚,但它确实这么说:

无法安装
Subversion 绑定到 [Mercurial's] 内置
Python 库。 所以你需要使用
安装在 a 之上的 Mercurial
独立Python

所以现在我只使用独立版本进行转换,并使用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:

python setup.py install

Which worked just fine on my Server 2003 box. I can now convert an SVN repo the correct way, by doing something like this:

python c:\python26\scripts\hg convert <remote repo>

The documentation for ConvertExtension on the Mercurial site isn't terribly clear, but it does say this:

There's no way to install the
Subversion bindings into [Mercurial's] built-in
Python library. So you'll need to use
a Mercurial installed on top of a
stand-alone Python

So now I just use the stand-alone version for converting, and TortoiseHg for actual VCS work.

你爱我像她 2024-07-26 19:44:27

迟到总比不到好……

一个的价格有两个答案……

  1. 如果它是一个公共的开源存储库,您可以使用 http://svn2github.com/add/ 花了大约半个小时将该存储库克隆到 GitHub,然后将其拉入 Hg。

  2. 使用hg Convert的优点是可以恢复。 将 SVN 转换为 Hg 可能需要几天。 如果您停止此操作,它将从停止的位置恢复。

下面是我写的一个批处理文件,因为 Codeplex SVNbridge 很垃圾。 此示例中的存储库确实花了几天时间来获取整个历史记录(我在澳大利亚,因此延迟可能是一个因素)。 我想它给了某个地方的 TFS 服务器一个很好的打击。

如果它们恰好是地球上唯一仍在使用 SVN 的更新,则可以随时运行此批处理文件以从 SVN 源提取更新。 我还没有测试过它,所以看看如果你这样做会发生什么,所以如果我是你,如果你要编辑存储库,我会放弃原始分支。

如果您克隆 Hg 存储库,robocopy shamap 的作用是维护 SVN 历史记录,shamap 是短暂的 - 检查批处理文件和文件。 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

better late than never ...

Two answers for the price of one ...

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

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

@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
老旧海报 2024-07-26 19:44:27

使用 Mercurial 的 convert 扩展

  1. 启用转换扩展; 将 convert= 添加到 .hgrc 的 [extensions] 部分,如下所示:

    <块引用>

    [扩展]
    转换=

  2. Linux 需要额外的 python 绑定: sudo apt-get install python-subversion
  3. 执行 hg Convert 命令
    • 请参阅 hg Convert -h 获取帮助
    • 示例:hg Convert http://[svnserver]/[Project] --source-type svn [DestinationDir] (参见注释 2)
  4. 推送到新创建的 Mercurial 存储库: 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:

  1. Enable convert extention; add convert= to the [extensions] section of .hgrc like this:

    [extensions]
    convert=

  2. Linux needs additional python bindings: sudo apt-get install python-subversion
  3. Execute hg convert command
    • See hg convert -h for help
    • Example: hg convert http://[svnserver]/[Project] --source-type svn [DestinationDir] (see note 2)
  4. Push to newly created Mercurial repository: 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:// or svn:// 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]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文