Reputation: 18135
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?
Upvotes: 75
Views: 43945
Reputation: 1406
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.
Upvotes: 24
Reputation: 5729
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.
Upvotes: 75
Reputation: 89965
Why redirect to a file when you can pipe the output through less
and use less
's search?
p4 changes -l | less
And then press / to prompt for a search string. Afterward, n will jump to the next match, and Shift+n will jump to the previous one.
An implementation of less
for Windows is available as part of UnxUtils.
Upvotes: 3
Reputation: 314
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)
Upvotes: 10
Reputation: 509
Eddie on Games posted his Perforce Changelist Search 0.1 at http://www.eddiescholtz.com/blog/archives/130
But, I do like using my favorite text editor with the simple: p4 changes -s submitted //prog/stuff/main/... >temp.txt
Upvotes: 1
Reputation: 615
If you still love your command line, you can write a small perl script that:
usage would be something like 'p4 -ztag changes -l | yourperlfilter.pl searchterm1 searchterm2'
if that worked ok, you could integrate it into the p4win tools menu.
Upvotes: 0
Reputation: 84043
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.
Upvotes: 17
Reputation: 10162
Using p4sql is really the only way to effectively do what you want. I am not aware of any other way. The benefit of course is that you can use the select statements to limit the range of changelist values (via date, user, etc). Your method will work but will get cumbersome very quickly as you generate more changelists. You can limit the scope of the changes command, but you won't get the flexibility of p4sql.
Upvotes: 1