在CVS中移动文件而无需重置版本号
时间:2020-03-06 14:43:28 来源:igfitidea点击:
最近,我一直在源代码树中移动源文件。例如,将一堆文件放入一个公共程序集中。我一直在这样做,我从CVS中删除了文件,然后再次将其添加到新位置。问题是文件的修订号重置为1.1. 是否有一些简单的方法可以移动东西而无需重新设置数字。
我可能应该提到,我无权访问存储库,因此任何需要的内容都无济于事,但可能对其他人有所帮助。
解决方案
在线CVS手册中有一些有关如何执行此操作的详细信息:
The normal way to move a file is to issue a cvs rename command. $ cvs rename old new $ cvs commit -m "Renamed old to new" This is the simplest way to move a file. It is not error prone, and it preserves the history of what was done. CVSNT clients can retrieve the original name by checking out an older version of the repository. This feature is only supported on CVSNT servers 2.0.55 and later.
这不是CVS没有内置文件移动机制的已知缺陷之一吗?自从我使用它已经很长时间了,所以也许现在有了解决方案。
Subversion允许我们移动文件,但是也会进行跟踪,因此新文件将获得最新的修订号。
最简单的方法就是访问仓库所在的cvs服务器,然后使用mv(假设使用* nix机器)移动文件夹/文件。这样,文件的历史记录将被保留。
无法使用仅客户端命令来移动文件。我们需要访问服务器文件系统,并且可以将存储库中的",v"文件移动到新位置。这将保留所有历史记录,因为CVS将每个修订及其注释记录在该文件中。
请记住,删除文件后,文件将移动到" Attic"子文件夹中(无法从客户端看到)。这是删除文件后可以还原文件的方式。
通常,这种方法没有立即出现的问题,但是,如果我们决定签出可能依赖于先前目录结构的早期版本产品,则必须考虑后果!
这是Subversion等其他版本控制系统具有明显优势的地方。
获得此效果的普遍接受的方法是执行以下步骤。为此的技术术语是复制。
- 在托管CVS存储库的服务器上登录,然后将存储库文件从所需位置复制(不要移动)到新位置。
- 在客户端,cvs从旧位置删除文件。
- 在客户端,cvs在新位置更新目录内容(以便文件将出现在该位置)。
- 在客户端,对复制的文件执行强制cvs commit(使用-f标志),以记录该文件已被重新复制的事实(为此添加日志注释)。
此过程将文件历史记录保留在新位置,也不会破坏存储库的向后连续性。如果我们时光倒流,该文件将正确显示在其旧位置。我们也可以使用相同的过程来重命名文件。
似乎保留了我们在移动时使用-v选项的版本历史记录,请参见下文
CVS renaming of files is cumbersome. To the repository point of view, you just can delete files or add new ones. So, the usual process is mv oldfile.c newfile.c cvs delete oldfile.c cvs add newfile.c This does work, but you lose all the change information you care to wrote in commit operations during years of hard development and that is probably not what you want. But there is a way; you must have direct access to the repository. First, go there, find the directory where your project is and do the following: cp oldfile.c,v newfile.c,v now go to your working directory and do a cvs update ; newfile.c will appear as a new file. Now you can cvs delete oldfile.c and commit.