由于 SVN 存储库结构复杂,一些外部文件无法从存储库中正确检索。由于无法更改存储库结构,我开发了一个脚本,该脚本可遍历外部文件并在需要时“手动”检索它们(感谢“svn export”)。为了检测是否确实需要此操作,我执行了“svn info”,假设如果文件不存在或未进行版本控制,它将返回不同于 0 的值。这确实是在 host1(SVN Client 1.6.17)中获得的行为:
# Initially, the directory is empty
host1$ ls
host1$ svn update
Fetching external item into 'main.rbf'
svn: warning: '<REMOTE_SVN_LOCATION1>'
is not the same repository as
'<REMOTE_SVN_LOCATION2>'
At revision 18413.
# Although we do the update, the external item is not fetched,
# as it is a single file coming from a different repository
# (known problem)
host1$ ls
# The file is not present, and SVN info acts accordingly
host1$ svn info main.rbf
main.rbf: (Not a versioned resource)
svn: A problem occurred; see other errors for details
# If we force the SVN export
host1$ svn export <REMOTE_SVN_LOCATION1> main.rbf
A main.rbf
Export complete.
host1$ ls
main.rbf
# then SVN info detects it and acts accordingly
host1$ svn info main.rbf
main.rbf: (Not a versioned resource)
svn: A problem occurred; see other errors for details
host1$
在 host2 中(SVN Client 1.6.11),“SVN info”的行为完全不同:无论文件是否存在(来自以前的导出),答案是:
# Directory is empty
host2$ ls
host2$ svn info
Path: .
URL: <REMOTE_LOCATION>
Repository Root: ...
Repository UUID: ...
Revision: 18413
Node Kind: directory
Schedule: normal
Last Changed Author: ...
Last Changed Rev: 18326
Last Changed Date: ...
host2$
有什么理由可以解释这种不一致的行为?如何在 host2 中检测此未版本控制的文件?