Stephen Rasku
Stephen Rasku

Reputation: 2682

Get local location for Perforce opened files

I want to write a script to process files that have been edited. p4 opened gives a good list but it is using depot syntax. Is there a way to get the output in local syntax so I can pass the results to my script?

I am running Perforce on Linux.

Upvotes: 3

Views: 935

Answers (2)

P4Shimada
P4Shimada

Reputation: 803

If you just want the client syntax for the file you can use the 'p4 -Ztag opened' command such as either of the following examples:

$ p4 -Ztag opened | grep clientFile
... clientFile //admin14streams/depot/www/dev/Jam.html
... clientFile //admin14streams/depot/www/dev/Jambase.html
... clientFile //admin14streams/depot/www/dev/Jamfile.html
... clientFile //admin14streams/depot/www/dev/Jamlang.html
... clientFile //admin14streams/depot/www/dev/images/jamgraph-jam.gif
... clientFile //admin14streams/depot/www/dev/index.html


$ p4 -Ztag opened | grep clientFile | cut -d ' ' -f3
//admin14streams/depot/www/dev/Jam.html
//admin14streams/depot/www/dev/Jambase.html
//admin14streams/depot/www/dev/Jamfile.html
//admin14streams/depot/www/dev/Jamlang.html
//admin14streams/depot/www/dev/images/jamgraph-jam.gif
//admin14streams/depot/www/dev/index.html

The 'p4 where' command will give you the local file system location if that is what you want, however.

$ p4 where //depot/www/dev/Jam.html
//depot/www/dev/Jam.html //admin14streams/depot/www/dev/Jam.html /home/bruno/myspaces/admin14streams/depot/www/dev/Jam.html


$ p4 -Ztag where //depot/www/dev/Jam.html
... depotFile //depot/www/dev/Jam.html
... clientFile //admin14streams/depot/www/dev/Jam.html
... path /home/bruno/myspaces/admin14streams/depot/www/dev/Jam.html

Hope this helps.

Upvotes: 0

Jon-Eric
Jon-Eric

Reputation: 17275

p4 where will tell you where a depot file is located locally.

You'll need to take the output of p4 opened and use p4 where to translate each depot path to a local path.

This answer might provide some hints.

Edit: Also see if p4 -ztag opened suits your needs. -ztag frequently produces a more verbose, but script-friendly output.

Upvotes: 3

Related Questions