perforce - 在 Perforce 文件中查找字符串而不同步

标签 perforce

不确定这是否可能,但我想我应该问问是否有人知道。是否可以在 Perforce 存储库中找到包含字符串的文件?具体来说,是否可以在不首先将整个存储库同步到本地目录的情况下执行此操作? (它相当大 - 即使我删除了很多东西,我也不认为有空间 - 这就是存档服务器的用途。)

有很多工具可以搜索本地目录中的文件(我个人使用 Agent Ransack,但这只是众多工具之一),但这些工具不会搜索远程 Perforce 目录,除非有一些我不知道的(最好是免费的)工具具有此功能,或者可能是 Perforce 本身的一些隐藏功能?

最佳答案

p4 grep 是你的 friend 。来自 perforce blog

'p4 grep' allows users to use simple file searches as well as regular expressions to search through file contents of head as well as earlier revisions of files stored on the server. While not every single option of a standard grep is supported, the most important options are available. Here is the syntax of the command according to 'p4 help grep':

p4 grep [ -a -i -n -v -A after -B before -C context -l -L -t -s -F -G ] -e pattern file[revRange]...

另请参阅 the manual page .

更新:请注意,Perforce 在单个 p4 grep 命令中搜索的文件数量有限制。据推测,这是为了帮助降低服务器上的负载。这表现为一个错误:

Grep revision limit exceeded (over 10000).

如果您有足够的perforce权限,可以使用p4 configure将 dm.grep.maxrevs 设置从默认值 10K 增加到更大。例如设置为 100 万:

p4 configure set dm.grep.maxrevs=1M

如果您无权更改此设置,您可以通过将 p4 grep 拆分为子目录上的多个命令来解决此问题。您可能需要根据您的仓库结构进一步拆分为子子目录等。

例如,可以在 bash shell 中使用此命令一次搜索 //depot/trunk 的每个子目录。利用p4 dirs命令从服务器获取子目录列表。

for dir in $(p4 dirs //depot/trunk/*); do
  p4 grep -s -i -e the_search_string $dir/...
done

关于perforce - 在 Perforce 文件中查找字符串而不同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13693563/

相关文章:

java - 返回指定用户提交的所有更改列表 - Perforce Java API

GIT vs. Perforce- 两个 VCS 将进入...一个将离开

git p4 clone 没有文件

file - 强制 : passing file extensions in a "diff" command

c++ - 如何让 Eclipse CDT 忽略文件

python - 在 Mac OS 10.6.7 上安装 P4Python

Perforce:仅获取软件仓库文件的本地路径

version-control - Perforce - 仅适用于专家?

perforce - 将文件添加到现有变更列表

perforce - 如何强制克隆工作区