tags:

views:

2415

answers:

8

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?


Ctrl+F searching of change list descriptions is finally available in P4V 2009.1. It will only search what you pull from the server, however. We have less than 6000 CLs, so telling it to retrieve them all is not a problem for us, but if you have a huge number of change lists, searching them all this way may not be an option.

+10  A: 

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.

jop
That didn't work. For some reason, "like" behaves like "=". Suppose the description is "foo bar". like 'foo' fails, but like 'foo bar' succeeds. More importantly, they don't make the entire text of the description available, only the first 30 characters.
raven
@raven - The % characters are important to the SQL, and hould make teh query work. I also don't think you are correct in the description - you should be able to get to all of it. Can you post your query?
Greg Whitfield
@Greg Whitfield: You're right, I wasn't using the % characters. The queries are working, but not of much use. I verified that it is only querying on, and displaying, the first 31 characters of the description.
raven
@raven - updated the query to include p4options='longdesc'. that should return the full description.
jop
p4options makes the query a bit slower though.
jop
@jop: Great! That did it. I created a custom tool to make it easy to use and... It doesn't freakin' work! There's a bug in the custom tool argument parser. I reported it to Perforce. Hopefully they will address it and get an update out soon. Thanks for your help.
raven
FYI: Perforce acknowledged the bug when I reported it last October, and have released updates to both P4V and P4Report, but the problem still exists.
raven
A: 

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.

Mark
A: 

If you still love your command line, you can write a small perl script that:

  • changes the record separator $/ to double newline "\n\n" so it filters the input into full records of the ztagged p4 output.
  • scans the '/^... desc/..//' part with regular expressions from the args.

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.

Epu
+3  A: 

There is another alternative using P4Win. 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 (via tha Options dialog).

There is a feature request in to add this to P4V too - if you want this then please email [email protected] to add your vote to it.

Greg Whitfield
Now available in P4V 2009.1!
raven
Nice. Tried this out, and it jumps to select each matching changelist. Really handy.
Epu
A: 

Yeah I wish they would put it into P4V not sure why they didn't. Someone is coming out with a nice history browsing tool that I am looking forward to: http://www.eddiescholtz.com/blog/archives/99

Nathan
A: 

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

WireGuy
+3  A: 

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 for 2 line comments but you can change it as necessary.

Paul Medcraft
+1  A: 

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)
Julian Martin