简体   繁体   English

cvs2git:可以保持从 CVS 修订号到 Git 修订哈希的映射

[英]cvs2git: Possibility to keep mapping from CVS revision numbers to Git revision Hash

We migrate large CVS repositories to GIT with cvs2git .我们使用cvs2git将大型 CVS 存储库迁移到 GIT。 For an in-house tool we need a mapping from CVS revision numbers to GIT revision hash for some files.对于内部工具,我们需要从 CVS 修订号到某些文件的 GIT 修订哈希的映射。

cvs2svn has an parameter --cvs-revnums , but this revisions are only stored in svn file properties and are not available for git. cvs2svn有一个参数--cvs-revnums ,但此修订仅存储在 svn 文件属性中,不适用于 git。

I saw that git cvsimport -R creates this mapping, but has many other disadvantages to cvs2git.我看到git cvsimport -R创建了这个映射,但是 cvs2git 有许多其他缺点。

Are there any other possibilities to get the informations from --cvs-revnums ?还有其他可能从--cvs-revnums获取信息吗?

If I understand correctly, you want a way to answer the question "what is the first Git commit that includes CVS revision XY of file FOO?".如果我理解正确,您需要一种方法来回答这个问题“第一个包含文件 FOO 的 CVS 修订版 XY 的 Git 提交是什么?”。

If you turn on cvs2git verbose output ("-v"), then cvs2git displays, during CreateRevsPass, the CVS file revisions that are being added to each Git commit:如果您打开 cvs2git 详细输出(“-v”),则 cvs2git 在 CreateRevsPass 期间显示添加到每个 Git 提交的 CVS 文件修订:

CVS Revision grouping:
  Time: Fri May 23 02:31:36 2003
Creating Subversion r23 (commit)
 proj/default 1.2.2.1
 proj/sub1/default 1.2.2.1
 proj/sub2/subsubA/default 1.1.2.1

This is close to what you want.这接近你想要的。 But it is not quite enough information to generate your table, because there is no easy way to map the pseudo-Subversion revision numbers (like "r23") to Git commit hashes.但是,生成表格的信息还不够充分,因为没有简单的方法可以将伪 Subversion 修订号(如“r23”)映射到 Git 提交哈希。 In fact, this is not trivial because cvs2git doesn't create the Git hashes itself, but rather just writes them in an abstract form to "git fast-import", which creates the commits and computes their hashes.事实上,这并非微不足道,因为 cvs2git 本身不会创建 Git 哈希值,而只是将它们以抽象形式写入“git fast-import”,从而创建提交并计算它们的哈希值。

Tellya what I'm gonna do... Tellya 我要做什么...

I just made a change to the trunk version of cvs2svn which causes OutputPass to emit a little bit more information, namely, which "mark" corresponds to which pseudo-Subversion revision number.我刚刚对 cvs2svn 的主干版本进行了更改,这会导致 OutputPass 发出更多信息,即哪个“标记”对应于哪个伪 Subversion 修订号。 The output for the above commit looks like this:上述提交的输出如下所示:

Writing commit r23 on Branch('B_MIXED') (mark :1000000021)

The mark ":1000000021", in turn, can be converted into a Git SHA-1 by asking "git fast-import" to write its marks to a file:反过来,标记“:1000000021”可以通过要求“git fast-import”将其标记写入文件来转换为Git SHA-1:

cat ../git-blob.dat ../git-dump.dat | git fast-import --export-marks=FILENAME

Look in the resulting file for a line that looks like this:在生成的文件中查找如下所示的行:

:1000000021 0aa255270fbb94ad691d5391a6d37c2ee6d78b03

from which you can read off the Git hash.您可以从中读取 Git 哈希。

You still have a bit of work to do to pull all of this information together, but now at least it should in principle be possible.您仍然需要做一些工作来将所有这些信息整合在一起,但现在至少原则上应该是可能的。

Please note that this method will only tell you the first Git commit containing the CVS file revision.请注意,此方法只会告诉您包含 CVS 文件修订的第一个 Git 提交。 It will not tell you when that file revision was merged to other branches.不会告诉您该文件修订何时合并到其他分支。 And in fact, because of the impedance-mismatch between CVS and Git, you cannot rely on the Git commit ancestry graph to tell you that information.事实上,由于 CVS 和 Git 之间的阻抗不匹配,你不能依赖 Git 提交祖先图来告诉你这些信息。 So there would be a lot more work to do to make this into a complete, convenient feature.因此,要使其成为一个完整、方便的功能,还需要做更多的工作。

Hope that helps.希望有帮助。

Thank you for your answer!谢谢您的回答!

Now I finished the Migration from CVS to GIT successfully.现在我成功地完成了从 CVS 到 GIT 的迁移。

Because we needed the mapping between Git Hash and CVS revision for a couple of files in every repository only, I solved the described problem in a way that was a little bit more easy for me:因为我们只需要每个存储库中几个文件的 Git Hash 和 CVS 修订版之间的映射,所以我以一种对我来说更容易一点的方式解决了所描述的问题:

  1. Migration of the CVS Repository with cvs2svn from CVS to GIT.使用 cvs2svn 将 CVS 存储库从 CVS 迁移到 GIT。
  2. For file A: Receive all CVS commits from all branches from CVS server, ordered chronological in a single list.对于文件 A:从 CVS 服务器的所有分支接收所有 CVS 提交,在单个列表中按时间顺序排列。
  3. Receive all commits from all branches for file A from GIT, ordered chronological (ignore commits with comment "This commit was manufactured by cvs2svn") in a single list.从 GIT 的文件 A 的所有分支接收所有提交,在单个列表中按时间顺序排序(忽略带有注释“此提交由 cvs2svn 制造”的提交)。
  4. Ensure that the amount of CVS an GIT commits in both lists is exactly the same (to ensure that nobody made newer commits to CVS ).确保 GIT 在两个列表中提交的 CVS 数量完全相同(以确保没有人对 CVS 进行新的提交)。
  5. Map every CVS revision to a single GIT Hash.将每个 CVS 修订版映射到单个 GIT 哈希。

Now we had for every CVS revision the first Git Commit containing the CVS File revision.现在,对于每个 CVS 修订版,我们都有包含 CVS 文件修订版的第一个 Git 提交。 This worked for us, because we had for one file no CVS commit with the same timestamp in different branches.这对我们有用,因为对于一个文件,我们没有在不同分支中使用相同时间戳的 CVS 提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM