简体   繁体   English

如何在cvs2git / cvs2svn中生成提交时间戳?

[英]How are the commit timestamps generated in cvs2git/cvs2svn?

I am converting a very old and huge CVS repository to Git using cvs2git via Cygwin. 我正在通过Cygwin使用cvs2git将一个非常古老且庞大的CVS存储库转换为Git。 It works fine and I started testing the new repository. 它工作正常,我开始测试新的存储库。 I found no bigger peculiarities. 我没有发现更大的特点。 But I wonder how the timestamps of a commit/change set are determined. 但是我不知道如何确定提交/更改集的时间戳。

So far I determined, that the timestamps between certain CVS revisions differ by 1 or 2 hours plus x, where x is a time from some seconds or minutes (most cases) up two 15 minutes. 到目前为止,我确定,某些CVS版本之间的时间戳相差1或2个小时加上x,其中x是从几秒钟或几分钟(大多数情况下)到两个15分钟的时间。 Many timestamps only differ by whole hours (x=0). 许多时间戳仅相差整小时(x = 0)。

I guess this has to do something with the "timestamp error correction" I found to be a cvs2svn feature ( http://www.mcs.anl.gov/~jacob/cvs2svn/features.html ). 我想这与我发现是cvs2svn功能( http://www.mcs.anl.gov/~jacob/cvs2svn/features.html )的“时间戳错误校正”有一定关系。 Maybe it has something to do with time zones, also. 也许也与时区有关。

The results of my tests show, that all commits with only one file in the change set differ by whole hours. 我的测试结果表明,更改集中只有一个文件的所有提交在整个小时内都不同。 That supports my "time zone hypothesis". 那支持我的“时区假说”。 But it also leads me to the question how the timestamp of change sets with multiple files is determined. 但这也使我想到一个问题,即如何确定包含多个文件的变更集的时间戳。

I tried to go through the code and found out (with help from Google) that there is a "COMMIT_THRESHOLD" in the config.py of the cvs2svn_lib. 我尝试遍历代码,并在Google的帮助下发现cvs2svn_lib的config.py中有一个“ COMMIT_THRESHOLD”。 It is used for fuzzing the file based commits in the CVS together, I guess. 我猜,它用于在CVS中对基于文件的提交进行模糊测试。 Although the code looks written well, my lack of technical understanding of CVS, SVN and Git revision storage makes it hard for me to understand. 尽管代码看起来写得不错,但是由于我对CVS,SVN和Git修订版存储缺乏技术了解,这使我很难理解。

Therefore, I would be grateful if someone could answer the following questions: 因此,如果有人可以回答以下问题,我将不胜感激:

  • How does cvs2svn/cvs2git determine a commit timestamp of change sets with multiple files? cvs2svn / cvs2git如何确定具有多个文件的变更集的提交时间戳?
  • How does the "timestamp error correction" cvs2svn/cvs2git work? “时间戳错误纠正” cvs2svn / cvs2git如何工作? (For me the functional background is more important than the technical.) (对我来说,功能背景比技术背景更重要。)

Kind regards 亲切的问候

Edit: 编辑:

As someone considered this question as "too broad", I am afraid I did not make my point clear enough. 有人认为这个问题“太广泛了”,恐怕我的观点还不够清楚。 So I would like to give a concrete (while fictional) example: 因此,我想举一个具体的(虚构的)示例:

cvs2git found 3 file changes for one change set. cvs2git发现1个变更集有3个文件变更。 They where committed on the same day (let's say on 30th February 2016). 他们是在同一天提交的(例如,2016年2月30日)。 But their times differ: 但是他们的时代不同:

  • File 1: 12:34:56 档案1:12:34:56
  • File 2: 12:35:38 文件2:12:35:38
  • File 3: 12:36:09 文件3:12:36:09

If it was only file 1, I would think, that cvs2git uses 2016-02-30T12:34:56 as timestamp for the Git commit. 如果只是文件1,我会认为cvs2git使用2016-02-30T12:34:56作为Git提交的时间戳。 But which timestamp is chosen, when the commits for all 3 files belong to one change set? 但是,当所有3个文件的提交都属于一个变更集时,选择哪个时间戳记?

Related to this, when my repository is converted the times seem to be adjusted by exactly 1 or 2 hours, too. 与此相关的是,在转换我的存储库时,时间似乎也恰好调整了1或2个小时。 This also happens when there is only one file in the change set. 当变更集中只有一个文件时,也会发生这种情况。 I guess it is some kind of time zone adjustment. 我想这是某种时区调整。 So I would like to know, why the "timestamp error correction" changed my timestamps, to check whether I accept these changes or not. 因此,我想知道为什么“时间戳错误更正”更改了我的时间戳,以检查我是否接受这些更改。 I did some statistics on the converted Git repository and the commit times seem ok to me in principle; 我对转换后的Git存储库进行了一些统计,从原则上来说,提交时间对我来说似乎还不错; but that is not enough for me. 但这对我来说还不够。

You ask two questions: 您问两个问题:

  1. How are timestamps generated for commits touching multiple files? 如何为涉及多个文件的提交生成时间戳?

    For commits that modify files, cvs2svn/cvs2git takes the newest timestamp from among the file-level commits that comprise the commit. 对于修改文件的提交,cvs2svn / cvs2git从构成提交的文件级提交中获取最新的时间戳。 However, if that timestamp is earlier than the timestamp of the previous commit or more than one day after the time of conversion, it instead chooses a timestamp one second after that of the previous commit. 但是,如果该时间戳记早于上一次提交的时间戳记,或者比转换时间晚了一天以上,那么它将选择一个比上一次提交的时间戳记晚一秒的时间戳记。

    For commits that involve branching or tagging (for which CVS doesn't record timestamps at all), the timestamp is set to be one second after the timestamp of the previous commit. 对于涉及分支或标记的提交(CVS根本不记录时间戳),将时间戳设置为上一次提交的时间戳之后的一秒钟。

  2. Why are timestamps sometimes off by an integral number of hours? 为什么有时时间戳会偏离整数小时?

    CVS records timestamps in UTC without recording a timezone, and cvs2svn/cvs2git uses those timestamps as-is without trying to guess a timezone. CVS在UTC中记录时间戳而不记录时区,而cvs2svn / cvs2git照原样使用这些时间戳,而无需尝试猜测时区。 So the timestamps should be correct, but are expressed in UTC. 因此,时间戳记应该正确,但以UTC表示。

    git log has a --date option that can be used to ask that dates be displayed in the local timezone. git log具有--date选项,可用于要求在本地时区中显示日期。

The cvs2svn project file doc/design-notes.txt documents the algorithms used by cvs2svn/cvs2git in quite some detail. cvs2svn项目文件doc/design-notes.txt详细介绍了cvs2svn / cvs2git使用的算法。

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

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