我曾经使用过CVS并且不是最熟悉它的所有功能,但对我来说,一个巨大的烦恼是尝试添加包含更多目录的新目录。运行“cvs add
”只会添加当前目录的内容,并且使用“cvs import
”看起来不正确,因为它仍然是我正在生成的所有代码(这个如何声明导入是对于3rd party sources)
你们知道以任何方式递归地将给定目录中的所有内容添加到当前的CVS项目中(或者如果SVN或git使这一点变得更加容易)吗?
答案 0 :(得分:72)
我发现这非常有效:
首先,添加所有目录,但不添加任何命名的“CVS”:
find . -type d \! -name CVS -exec cvs add '{}' \;
然后添加所有文件,不包括CVS目录中的任何内容:
find . \( -type d -name CVS -prune \) -o \( -type f -exec cvs add '{}' \; \)
现在,如果有人能够治愈在这个时代使用CVS的尴尬......
答案 1 :(得分:10)
find . -type f -print0| xargs -0 cvs add
答案 2 :(得分:8)
我用这个:
首先递归地添加所有目录,而不是CVS:
$> find . -type d \! -name CVS -exec cvs add '{}' \;
第二个添加所有文件,少于CVS目录:
find . \( -type d -name CVS -prune \) -o \( -type f -exec cvs add '{}' \; \)
第三个以递归方式“提交”,例如"第一个版本"评价:
find . \( -type d -name CVS -prune \) -o \( -type f -exec cvs commit -m "first version" '{}' \; \)
最后一次递归标记:
find . \( -type d -name CVS -prune \) -o \( -type f -exec cvs tag -F MY_CVS_TAG '{}' \; \)
答案 3 :(得分:5)
首先将所有目录添加到CVS
find . -type d -print0| xargs -0 cvs add
然后将目录中的所有文件添加到CVS
find . -type f | grep -v CVS | xargs cvs add
为我工作
答案 4 :(得分:2)
cvs import
不仅适用于第三方来源。实际上,CVS没有对目录进行版本控制,因此它们不受分支策略的约束。只要你导入空目录,就可以了。
答案 5 :(得分:2)
请注意,您只能对已经签出的工作副本中的文件和文件夹使用cvs add
,否则您将收到"Cannot open CVS/Entries for reading"消息。此WinCVS常见问题项目解释了使用cvs add
创建新“根模块”的技术:http://cvsgui.sourceforge.net/newfaq.htm#add_rootmodule
如果您使用的是Windows,则TortoiseCVS和WinCVS都支持在单个操作中对多个文件进行递归添加(和可选提交)。在WinCvs中查找宏添加>递归添加(自动提交)...在Tortoise中,使用目录上的Add Contents命令。两者都允许您选择要添加的文件以及要用于它们的关键字扩展模式(主要用于定义哪些文件是二进制文件)。
有关WinCvs中递归添加的更多信息,请查看此处:http://cvsgui.sourceforge.net/newfaq.htm#cvs-add_recursive
除此之外cvs import
非常适合大规模增加。但是,cvs import
在vanilla CVS中实现的方式有两个缺点(因为 >最初是为第三方代码编写的):
如果您使用的是CVSNT,则可以通过在导入时指定-nC
选项来避免这两个缺点。 -n
用于避免“供应商”分支,-C
用于创建CVS目录。
答案 6 :(得分:2)
Mark的回答非常有用(找到。-type f -print0 | xargs -0 cvs add)但是我解决了当cvs添加尝试添加自己的文件时出现的一些问题,例如Tag,Entries等等。 / p>
cvs add NEW_FOLDER
找到NEW_FOLDER / -type d! -name" CVS" - 而且! -name" Tag" - 而且! -name" Entries.Log" - 而且! -name"条目" - 而且! -name" Repository" - 而且! -name" Root" -print0 | xargs -0 cvs add
找到NEW_FOLDER / -type f! -name" CVS" - 而且! -name" Tag" - 而且! -name" Entries.Log" - 而且! -name"条目" - 而且! -name" Repository" - 而且! -name" Root" -print0 | xargs -0 cvs add
答案 7 :(得分:1)
我认为这是我在CVS时代所做的事情:
find . -type f | xargs cvs add
答案 8 :(得分:1)
首先将所有目录添加到CVS
find . -type d -print0| xargs -0 cvs add
然后将目录中的所有文件添加到CVS
find . -type f -print0| xargs -0 cvs add
答案 9 :(得分:1)
我正在使用这个简单的shell脚本,它应该从已经签出的CVS目录开始。它将愚蠢地尝试添加/提交它在递归搜索时找到的任何文件和目录,因此最终你应该得到一个完全提交树。
只需将其保存为/usr/bin/cvsadd
,并且不要忘记chmod +x /usr/bin/cvsadd
。
#!/bin/sh # @(#) add files and directories recursively to the current CVS directory # (c) 2009 by Dirk Jagdmann if [ -z "$1" ] ; then echo "usage: cvsadd 'import message'" exit 1 fi if [ -d "$2" ] ; then cvs add "$2" cd "$2" || exit 1 fi if [ ! -d CVS ] ; then echo "current directory needs to contain a CVS/ directory" exit 1 fi XARGS="xargs -0 -r -t -L 1" # first add all files in current directory find . -maxdepth 1 -type f -print0 | $XARGS cvs add find . -maxdepth 1 -type f -print0 | $XARGS cvs ci -m "$1" # then add all directories find . -maxdepth 1 -type d -not -name CVS -a -not -name . -print0 | $XARGS "$0" "$1"
答案 10 :(得分:1)
已经讨论过的方法会进行递归查找,但如果再次执行相同的操作(如果要将子树添加到现有树),它将失败
因此,您需要检查您的目录是否尚未添加,然后仅添加尚未添加的文件。为此,我们使用cvs up
的输出来查看哪些元素尚未添加 - 它将在行首处出现问号。
我们使用选项-0
,-print0
和-zZ
来确保我们正确处理文件名中的空格。如果不需要添加任何内容,我们还会使用--no-run-if-empty
来避免运行。
CVS_PATTERN=/tmp/cvs_pattern
cvs -z3 -q up | egrep '^\?.*' | sed -e 's/^? //' > $CVS_PATTERN
find . -type d \! -name CVS -print0 | grep -zZf $CVS_PATTERN | xargs -0 --no-run-if-empty cvs add
find . \( -type d -name CVS -prune \) -o \( -type f -print0 \) | grep -zZf $CVS_PATTERN | xargs -0 --no-run-if-empty cvs add
cvs commit -m 'commiting tree recursively'
通过这种方法,我们将避免此类错误:
cvs add: cannot add special file `.'; skipping
cvs [add aborted]: there is a version in ./dirname1 already
和
cvs add: `./dirname2/filename' already exists, with version number 1.1.1.1
答案 11 :(得分:0)
Mark's solution解决了空间问题,但产生了这个问题:
cvs add:无法打开CVS /条目 阅读:没有这样的文件或目录
cvs [添加中止]:没有存储库
要修复它,实际使用的命令是:
find . -type f -exec cvs add {} \;
答案 12 :(得分:0)
我喜欢这样做(因为目录需要添加)
cvs status 2>/dev/null | awk '{if ($1=="?")system("cvs add "$2)}'
您可能需要多次运行(首先是目录,然后是子代),直到没有输出
答案 13 :(得分:-1)
SVN肯定会做出这个微不足道的任务,但使用像Tortoise这样的GUI会更容易。
这可能是一个很好的起点:http://www-mrsrl.stanford.edu/~brian/cvstutorial/