How do you search the text of changelist descriptions in Perforce?

On occasion, I find myself wanting to search the text of changelist descriptions in Perforce. There doesn't appear to be a way to do this in P4V. I can do it by redirecting the output of the changes command to a file...

p4 changes -l > p4changes.txt

...(the -l switch tells it to dump the full text of the changelist descriptions) and then searching the file, but this is rather cumbersome. Has anyone found a better way?


Solution 1:

When the submitted changelist pane has focus, a CTRL+F lets you do an arbitrary text search, which includes changelist descriptions.

The only limitation is that it searches just those changelists that have been fetched from the server, so you may need to up the number retrieved. This is done via the "Number of changelists, jobs, branch mappings or labels to fetch at a time" setting which can be found by navigating to Edit->Preferences->Server Data.

Solution 2:

p4 changes -L | grep -B 3 searchstring

-B 3 means show 3 lines before the matched string, should be enough to show the change id with 2 line comments but you can change it as necessary.

Solution 3:

I use p4sql and run a query on the "changes" database. Here's the perforce database schema

The query looks something like this (untested)

select change from changes where description like '%text%' and p4options = 'longdesc'

edit: added the p4options to return more than 31 characters in the description.

Solution 4:

Here is a Powershell version of Paul's "grep" answer. Again, it searches for the specified string within the change description and returns the 3 lines before it, to include the change id:

p4 changes -L | select-string "search string" -Context (3,0)