我多年来一直使用 ComponentSoftware 的 CS-RCS Basic 来管理我的各种单一开发人员项目。它对我来说效果很好,但现在我想迁移到现代版本控制系统,在研究了我的选择后,我决定使用 Mercurial。
问题是我一直使用 CS-RCS 的中央存储库,现在我想对各个项目使用单独的 Mercurial 存储库,保留我的 RCS 存储库中的历史记录。
经过一番深入的谷歌搜索后,我得出结论,做到这一点的唯一方法是将我的 RCS 存储库转换为单独的 CVS 存储库,然后将它们转换为 Mercurial。这两个站点可能是最有帮助的:
与 Jeff Atwood 询问和的想法保持一致回答我自己的问题,我将为陷入这种情况的其他人回答这个问题,以防我以后必须再次找到它。正如您将看到的,虽然我确实找到了一种解决方案,但它很笨拙并且至少存在一个重大问题。如果其他人有更好的方法,我当然想听听。
I've been using ComponentSoftware's CS-RCS Basic for many years now to manage my various single-developer projects. It's worked very well for me, but now I want to migrate to a modern revision-control system, and after studying my options I decided on Mercurial.
The problem is that I've always used a central repository for CS-RCS, and I'd now like to use individual Mercurial repositories for individual projects, keeping the history from my RCS repository.
After some in-depth Googling I concluded that the only way to do this is to convert my RCS repository to individual CVS repositories, then convert those to Mercurial. These two sites were probably the most helpful:
In keeping with Jeff Atwood's idea of asking and answering my own question, I'm going to answer this for anyone else stuck in this situation, and in case I have to find it again later. As you'll see, though I did find a solution, it's clunky and has at least one significant problem. If anyone else has any better method I'd certainly like to hear about it.
发布评论
评论(2)
这是我想出的方法,尽管有缺陷。这有点“货物崇拜”,因为我基本上对 CVS 一无所知,对 Mercurial 也了解不多:
我有一个可以拍摄快照的 Windows XP 虚拟机,所以我这样做了,然后安装了 CVSNT 和 Windows 命令Mercurial 的 -line 版本(我在我的主机上使用 TortoiseHg)。我在虚拟机中执行了此操作,这样我就可以轻松摆脱 CVSNT、Mercurial 以及在进行一次性迁移时必须创建的任何其他内容。是的,我可能不必这样做,但虚拟机已经可用,并且多年来我已经从安装/卸载周期中留下了足够的奇怪应用程序。 :-)
据我所知,CVSNT 是唯一可以在 Windows 计算机上轻松设置 CVS 服务器的可用程序。看起来这曾经是免费的,但所有者的当前网站现在要钱。这并不是一件坏事,但我真的无法证明花钱只是为了进行一次性转换是合理的。我最终通过 Google 搜索找到了旧版本的 CVSNT,并毫无问题地安装了它。
以下是我在学习如何进行此转换时所做的笔记:
长版本
将所需的源代码文件夹从主计算机的驱动器复制到虚拟机的驱动器。将各种“,v”文件从 C:\RCS 文件夹结构复制到 VM 上的同一源代码文件夹中。只需从 C:\RCS 中的相应文件夹复制 ,v 文件即可。
在 VM 上打开命令提示符框并键入以下内容:
在
\cvs-repo
中创建源代码文件夹的副本。\cvs-repo
现在应该只有两个文件夹:CVSROOT 和您的新文件夹。也复制相应的“,v”文件。“\cvs-checkout\name_of_your_source_code_folder”的目录应该显示所有源代码文件,这些文件现在已从 CVS 中签出。
如果您尚未下载 Mercurial,请从 https://www.mercurial-scm.org/< /a> 并安装它。打开记事本副本并将文件“C:\Program Files\Mercurial\hgrc.d\Mercurial.rc”拖入其中。在“[extensions]”下,删除行开头的分号“
;convert =
”。将文件保存到“C:\Documents and Settings\user_name\Mercurial.ini”返回 VM 命令行:
将 \my-repo 中的“.hg”文件夹复制到主计算机硬盘上的源代码文件夹。目标文件夹现在将显示在 TortoiseHg 中,其中包含所有相应的更改历史记录,但所有文件都标记为“已更改”(红色圆圈中感叹号的图标覆盖)。这是因为新的 Mercurial 存储库认为文件是以 Unix 行结尾 (0x0A) 而不是 Windows (0x0D,0x0A) 签入的。这似乎发生在“hg Convert”过程中,我还没有找到任何解决方法。
简短版本
在虚拟机中完成所有设置后,需要执行以下操作:
cvs -d \cvs-repo init
。cd \cvs-checkout
cvs -d \cvs-repo co name_of_your_source_code_folder
hg conversion --datesort \cvs-checkout\name_of_your_source_code_folder \my-repo.hg
cd \my-repo.hg
hg update
方便的批处理文件
一旦我开始工作,我在虚拟机上设置了这个批处理文件,以尽可能自动化该过程:
结论
因此,这一切都有效,但给我留下了行结尾错误的文件。看看这个问题,我发现我不是只有一个有这个问题。我可以忍受这个,但如果有人知道解决方案,我仍然想解决它。
Here's the method I came up with, warts and all. It's a bit 'cargo culty', since I basically know nothing about CVS and not much (yet) about Mercurial:
I have a Windows XP virtual machine that I can take snapshots of, so I did that and then installed CVSNT and the Windows command-line version of Mercurial (I use TortoiseHg on my main machine). I did this in a VM so I could easily get rid of CVSNT, Mercurial, and anything else I had to create while doing this one-time migration. Yeah, I probably didn't have to do this, but the VM was already available and I've already got enough odd bits of apps left over from install/uninstall cycles over the years. :-)
As far as I could tell, CVSNT was the only program available that could easily set up a CVS server on a Windows machine. It seems that this was free at one time but the owner's current site now asks for money. That's not a bad thing, but I really couldn't justify spending money just to do a one-time conversion. I did eventually track down an older version of CVSNT with a Google search and installed that without problems.
Here are the notes I took while learning how to make this conversion work:
The Long Version
Copy the source-code folder you need from the main computer's drive to the VM's drive. Copy the various ",v" files from the C:\RCS folder structure to this same source-code folder on the VM. Just copy the ,v files from the corresponding folder in C:\RCS.
Open a Command Prompt box on the VM and type the following:
Make a copy of your source code folder in
\cvs-repo
.\cvs-repo
should now just have two folders: CVSROOT and your new folder. Copy in the appropriate ",v" files as well.A DIR of "\cvs-checkout\name_of_your_source_code_folder" should show all of your source code files, which are now checked out of CVS.
If you haven't already done so, download Mercurial from https://www.mercurial-scm.org/ and install it. Open a copy of Notepad and drag the file "C:\Program Files\Mercurial\hgrc.d\Mercurial.rc" into it. Under "[extensions]", remove the semicolon at the start of the line "
;convert =
". Save the file to "C:\Documents and Settings\user_name\Mercurial.ini"Back at the VM command line:
Copy the ".hg" folder from \my-repo to the source code folder on your main computer's hard drive. The destination folder will now show up in TortoiseHg with all of the appropriate change history, but all files marked as Changed (icon overlay of an exclamation mark in a red circle). This is because the new Mercurial repository thinks the files were checked in with Unix line endings (0x0A) instead of Windows (0x0D,0x0A). This seems to happen in the "hg convert" process, and I haven't found any way around it.
The Short Version
Once everything's set up in the VM, here's what to do:
cvs -d \cvs-repo init
.cd \cvs-checkout
cvs -d \cvs-repo co name_of_your_source_code_folder
hg convert --datesort \cvs-checkout\name_of_your_source_code_folder \my-repo.hg
cd \my-repo.hg
hg update
Handy Batch File
Once I got this working, I set up this batch file on the VM to automate the process as much as possible:
Conclusion
So, this all worked but left me with files that had the wrong line endings. Looking at this question, I see I'm not the only one with this problem. I can live with this, but I'd still like to fix it if anyone knows of a solution.
如果 Mercurial 具有快速导入/快速导出支持,并且您的多文件存储库不使用分支,您可以尝试使用我的 rcs-fast-export 工具(可在 @http://git.oblomov.eu/rcs-fast-export )。虽然到目前为止我只使用它从 RCS 导出到 git,但我不知道使用了任何特定于 git 的快速导出命令,因此它可能有效。
If Mercurial has fast-import/fast-export support, and if your multi-file repositories do not use branches, you can probably try using my rcs-fast-export tool (available @ http://git.oblomov.eu/rcs-fast-export ). Although I've only used it to export from RCS to git so far, I am not aware of any git-specific fast-export commands being used so it might work.