Search code examples
searchfilterperforcep4v

Search file in all shelves in Perforce Visual Client


I have many shelf changelists with customized code. I want to search with below criterion for all the shelf changelists in the current workspace

  1. Filter by file name
  2. Search for a string inside file contents

Do anyone one know how to achieve this thru Perforce visual client or command line?


Solution

  • Finding shelved changelists with a particular file is pretty simple:

    p4 changes -s shelved -c CLIENTNAME FILE

    https://www.perforce.com/perforce/doc.current/manuals/cmdref/Content/CmdRef/p4_changes.html

    Grepping for a string within shelves is a little more complicated since p4 grep doesn't take a -s shelved argument, but you can get there from the list of changes:

    p4 -Ztag -F @=%change% changes -s shelved -c CLIENTNAME | p4 -x - grep -e EXPR

    https://www.perforce.com/perforce/doc.current/manuals/cmdref/Content/CmdRef/p4_grep.html

    Unfortunately the p4 grep output doesn't include the shelved changelist (this seems like a bug IMO; it gives the revision the shelf was based on instead) so if getting it narrowed down to a set of files (which you can feed into the first query) isn't specific enough you might have to do a little more scripting, but those are the basic building blocks.