如何在任何修订版本中搜索svn存储库以查看是否存在文件

问题描述:

如何搜索名为foo.txt的文件是否曾提交给我的svn存储库(在任何修订版本中)?如何在任何修订版本中搜索svn存储库以查看是否存在文件

+0

我想简单的答案是“搜索日志”。你如何实现这一点取决于你如何与SVN交互,因此Martijn和我的不同答案。 – 2008-12-24 16:23:08

+0

那么把亚当:)我首先回答了一个编码的答案,但后来注意到相当明确的tortoiseSVN标签。 – 2008-12-24 16:44:10

+1

对,我错过了。不过,我会留下我的答案,有人可能会感兴趣。 – 2008-12-24 16:46:42

上签出的文件夹的根目录右键> TortoiseSVN的>显示日志

您可以输入文件名一样好那里。

这应该为你工作:

svn log -r 0:HEAD -v $REPOSITORY_PATH | grep "/foo.txt" 

这会给你从日志路径的文件和状态。如果你有任何点击,你知道它在某个时刻存在。如果没有获得结果,那么在任何修订版本中,存储库中的任何地方都不会匹配。您还可以看到美国从每个日志行,例如:

 
    A /some/path/foo.txt 
    D /some/path/foo.txt 

但我猜额外的信息是不是对你的问题。 :)

使用Subversion 1.8+客户端和new --search and --search-and options become available for svn log command。这些选项不允许进行仓库内全文搜索和查找只有以下数据:

  • 修订的作者(svn:author版本化的属性),
  • 日期(svn:date版本化的属性),
  • 日志消息文本(svn:log未版本控制的属性),
  • 已更改路径(即受特定修订影响的路径)的列表。

据我猜测,你可以搜索 “foo.txt的” 使用以下命令行:

svn log -v --search "foo.txt"

下面是对这些新svn log搜索选项完整的帮助页面:

If the --search option is used, log messages are displayed only if the 
provided search pattern matches any of the author, date, log message 
text (unless --quiet is used), or, if the --verbose option is also 
provided, a changed path. 
The search pattern may include "glob syntax" wildcards: 
    ?  matches any single character 
    *  matches a sequence of arbitrary characters 
    [abc] matches any of the characters listed inside the brackets 
If multiple --search options are provided, a log message is shown if 
it matches any of the provided search patterns. If the --search-and 
option is used, that option's argument is combined with the pattern 
from the previous --search or --search-and option, and a log message 
is shown only if it matches the combined search pattern. 
If --limit is used in combination with --search, --limit restricts the 
number of log messages searched, rather than restricting the output 
to a particular number of matching log messages.