Subversion会记录目录树的结构,不仅仅是文件的内容。这是编写Subversion替代CVS最重要的一个原因。
以下是对你这意味着什么的说明,作为一个前CVS用户:
svn add和svn delete现在也工作在目录上了,就像在文件上一样,还有svn copy和svn move也一样。然而,这些命令不会导致版本库即时的变化,相反,工作的项目只是“预定要”添加和删除,在运行svn commit之前没有版本库的修改。
Directories aren't dumb containers anymore; they have
revision numbers like files. (Or more properly, it's
correct to talk about “directory
foo/
in revision 5.”)
让我们再讨论一下最后一点,目录版本化是一个困难的问题;因为我们希望允许混合修订版本的工作拷贝,有一些防止我们滥用这个模型的限制。
From a theoretical point of view, we define “revision
5 of directory foo
” to mean a
specific collection of directory entries and properties. Now
suppose we start adding and removing files from
foo
, and then commit. It would be a lie
to say that we still have revision 5 of
foo
. However, if we bumped
foo
's revision number after the commit,
that would be a lie too; there may be other changes to
foo
we haven't yet received, because we
haven't updated yet.
Subversion通过在.svn
区域偷偷的纪录添加和删除来处理这些问题,当你最后运行svn update,所有的账目会到版本库结算,并且目录的新修订版本号会正确设置。因此,只有在更新之后才可以真正安全地说我们有了一个“完美的”修订版本目录。在大多数时候,你的工作拷贝会保存“不完美的”目录修订版本。
Similarly, a problem arises if you attempt to commit property changes on a directory. Normally, the commit would bump the working directory's local revision number. But again, that would be a lie, as there may be adds or deletes that the directory doesn't yet have, because no update has happened. Therefore, you are not allowed to commit property changes on a directory unless the directory is up to date.
关于目录版本的更多讨论见“混合修订版本的工作拷贝”一节。