在不同步的情况下在 Perforce 文件中查找字符串 [英] Find a string in Perforce file without syncing

查看:51
本文介绍了在不同步的情况下在 Perforce 文件中查找字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Not sure if this is possible or not, but I figured I'd ask to see if anyone knows. Is it possible to find a file containing a string in a Perforce repository? Specifically, is it possible to do so without syncing the entire repository to a local directory first? (It's quite large - I don't think I'd have room even if I deleted lots of stuff - that's what the archive servers are for anyhow.)

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

There's any number of tools that can search through files in a local directory (I personally use Agent Ransack, but it's just one of many), but these will not search a remote Perforce directory, unless there's some (preferably free) tool I'm not aware of that has this capability, or maybe some hidden feature within Perforce itself?

推荐答案

p4 grep 是你的朋友.来自 perforce 博客

'p4 grep' 允许用户使用简单的文件搜索以及常规的用于搜索 head 和更早文件内容的表达式存储在服务器上的文件的修订.虽然不是每一个选项支持标准 grep,最重要的选项是可用的.这是根据p4帮助"的命令语法grep':

'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]...

另请参阅手册页.

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

Update: Note that there is a limitation on the number of files that Perforce will search in a single p4 grep command. Presumably this is to help keep the load on the server down. This manifests as an error:

Grep revision limit exceeded (over 10000).

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

If you have sufficient perforce permissions, you can use p4 configure to increase the dm.grep.maxrevs setting from this default of 10K to something larger. e.g. to set to 1 million:

p4 configure set dm.grep.maxrevs=1M

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

If you do not have permission to change this, you can work around it by splitting the p4 grep up into multiple commands over the subdirectories. You may have need to split further into sub-subdirectories etc depending on your depot structure.

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

For example, this command can be used at a bash shell to search each subdirectory of //depot/trunk one at a time. Makes use of the p4 dirs command to obtain the list of subdirectories from the server.

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

这篇关于在不同步的情况下在 Perforce 文件中查找字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆