为什么 svn 对待文件和目录如此不同?

发布于 2024-10-31 04:23:15 字数 457 浏览 1 评论 0原文

您可以对工作副本进行两种更改:文件更改和树更改。 您不需要告诉 Subversion 您打算更改文件;Subversion 会自动检测哪些文件已被更改,此外。对于树更改,您可以要求 Subversion “标记”文件和目录以按计划删除、添加、复制或移动。

为什么 svn 对待目录的方式与对待文件的方式不同?

经过测试,我发现以与文件更改相同的方式处理目录更改非常实用,因为它的上次修改时间戳也是可跟踪的:

[ ~]# mkdir svntest
[ ~]# ll |grep svn
drwxr-xr-x  2 root root      4096 2011-04-10 07:41 svntest
[ ~]# touch svntest/demo.txt
[ ~]# ll |grep svn
drwxr-xr-x  2 root root      4096 2011-04-10 07:42 svntest

You can make two kinds of changes to your working copy: file changes and tree changes.
You don't need to tell Subversion that you intend to change a file;Subversion automatically detects which files have been changed, and in addition.For tree changes, you can ask Subversion to “mark” files and directories for scheduled removal, addition, copying, or moving.

Why doesn't svn treat directory the same way as it treats the file?

And after testing I find it quite practical to treat directory change the same way as file change since its last modify timestamp is also track-able:

[ ~]# mkdir svntest
[ ~]# ll |grep svn
drwxr-xr-x  2 root root      4096 2011-04-10 07:41 svntest
[ ~]# touch svntest/demo.txt
[ ~]# ll |grep svn
drwxr-xr-x  2 root root      4096 2011-04-10 07:42 svntest

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千里故人稀 2024-11-07 04:23:15

文件的版本控制是全有或全无,而目录的版本控制则按项目进行。如果对它们进行相同的处理,则会有两个不同的选项:

  • 将文件与目录相同:这意味着文件中的每一行都可以单独存在,并且您可以选择要对哪些行进行版本控制。这没有多大意义。

  • 将目录视为文件:这意味着您添加到目录的每个文件都会自动添加到您的树中(甚至是目标文件、二进制文件和其他临时文件),从而不可能拥有与主干不同的目录树。这似乎也不太有用。此外,处理重命名而不立即提交的唯一方法是“安排”它。

Files are versioned all-or-nothing, while directories are versioned by item. If they were treated the same, there would be two different options:

  • Treat files the same as directories: this means that each line in a file could be individually and you could choose which lines you want versioned. This doesn't make much sense.

  • Treat directories as files: this means that each file you add to a directory is automatically added to your tree (even object files, binaries, and other temporaries), making it impossible to have a directory tree that differs from the trunk. This also doesn't seem too useful. Furthermore, the only way to handle renames without doing an immediate commit is to "schedule" it.

梦在深巷 2024-11-07 04:23:15

我能找到的不自动标记所有新文件和目录以进行添加的最佳理由是,通常在包含工作副本的目录中编译代码。如果 svn 那样工作,存储库最终会填满一堆垃圾(编译器的输出)。

The best justification that I can find for not automatically marking all new files and directories for addition is that it's common to compile your code in the directory containing your working copy. If svn worked that way, the repository would end up filling up with a bunch of junk (the output from the compiler).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文