如何还原CVS的重大变化

如何还原CVS的重大变化

本文介绍了如何还原CVS的重大变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一位同事完全弄乱了我们主要的CVS存储库中目录的内容。我只需要将整个模块恢复到去年年底的状态即可。

One of my colleagues has totally messed up the contents of a directory in our main CVS repository. I need to just revert the whole module to the state it was in at the end of last year. What's the CVS command to do this please?

他已添加和删除了数百个文件,因此,简单的从旧的检出并提交复制文件是不够的。

He has added and removed hundreds of files, so a simple "copy over files from old checkout and commit" isn't enough.

我有RTFM和STFW,我尝试过这样做:

I have RTFM and STFW, and I tried this:

cvs co modulename  # Note no -P option
cvs up -jHEAD -jMAIN:2008-12-30 modulename

但这不起作用-他创建的新文件被删除,但是旧文件和目录没有被复活。 (我没有提交它。)

But that doesn't work - the new files he created get removed, but the old files and directories don't get resurrected. (I didn't commit it).

我也许可以为此编写一个shell脚本,但是肯定要在CVS中使用此功能吗?

I can probably write a shell script for this, but surely this functionality must be in CVS already?

更新:一些澄清:


  • 我可以得到本地结帐。问题是如何将其恢复到CVS中。

  • I can get a local checkout of the module at a specific date. The question is how to get that back into CVS.

我确实有备份,但是使用像CVS这样的版本控制系统的要点是,它应该容易获得任何历史状态。下次发生这种情况时,我可能不太幸运可以进行备份(例如,每天备份一次,因此我可能会失去一天的工作)。

I do have backups, but the point using of a revision control system like CVS is that it's supposed to be easy to get any historical state. Next time something like this happens I may not be lucky enough to have backups (e.g. backups are daily, so I may lose up to a day's work).

我知道CVS很老,我们应该改用新的东西。但是,在拥有大量基于CVS的工具(结帐和构建脚本,每夜构建服务器等)的大型团队中,此举的时间成本相当可观。 (评估,更新脚本,测试,迁移,培训,开发人员时间浪费,并行维护两个系统,因为旧分支仍然需要CVS)。因此,必须对此进行计划和评估。

I know that CVS is old, and we should move to something newer. But in a large team with a large number of CVS-based tools (checkout & build scripts, nightly build server, etc) the time cost of such a move is considerable. (Evaluation, updating scripts, testing, migration, training, lost developer time, maintaining both systems in parallel as CVS would still be needed for old branches). Hence this has to be planned & scheduled by management.

更新#2:我将为此悬赏。 要获得赏金资格,您必须解释如何使用普通的CVS命令而不是带有hacky的shell脚本来还原。

Update #2: I'm going to start a bounty on this. To qualify for the bounty you have to explain how to revert using normal CVS commands, not with a hacky shell script.

更新#3:服务器是。通过pserver访问。我可以在Linux PC上使用相同版本的CVS,也可以在客户端上使用Windows。

Update #3: The server is CVS 1.12.13. Access is via pserver. I can use the same version of CVS on a Linux PC, or the CVSNT 2.0.51d client on Windows.

推荐答案

实际上,您的初始方法非常接近解决方案。问题是,基于日期的加入不能正确处理已删除的文件和目录。您需要在要首先加入的代码库中设置标记:

Actually your initial approach was very close to the solution. The problem is, that joining date-based does not handle removed files and directories correctly. You need to set a tag to the code base you want to join first:

mkdir code_base1 && cd code_base1
cvs co -D "2008-12-30" modulename
cvs tag code_base_2008_12_30

现在基于加入标记进行操作,减去从现在到2008-12-30的所有更改:

Now do the join tag-based, subtracting all changes between now and 2008-12-30:

cd .. && mkdir code_base2 && cd code_base2
cvs co modulename
cvs update -d -j HEAD -j code_base_2008_12_30  # use -d to resurrect deleted directories

比较code_base1和code_base2的内容。除了CVS元信息外,它们应该相同。最后,将代码像2008年12月30日一样作为新的HEAD提交:

Compare the contents of code_base1 and code_base2. They should be identical except for the CVS meta information. Finally commit the code as it was on 2008-12-30 as new HEAD:

cvs commit -m "Revert all changes this year"






请注意,标记您想要的代码这样的联接将不起作用,因为使用-D时,rtag也不能正确处理已删除的文件和目录:


Note that tagging the code you wish to join like this will not work, because rtag also does not handle removed files and directories correctly, when using -D:

cvs rtag -D "2008-12-30" code_base_2008_12_30 modulename

这篇关于如何还原CVS的重大变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 15:58