Monday, February 22, 2010

Stupid perforce trick #517


p4 fstat //depot/mycode/myfile.html | grep clientFile | awk '{print $3}'


Perforce command line often spits out filenames in the 'depot' format. You will need to translate these 'depot' names into local paths in order to work with the files in your favorite editors and GNU utilities.


p4 fstat

p4 fstat is a very useful command that can access all sorts of fun information about a file under perforce control. Do yourself a favour and look it up right now by typing
p4 help fstat
into your terminal. Then try out as many options as you can before screaming 'i hate perforce and what is so f@#$king wrong with SVN..' but i digress

the output of p4 fstat filename is something like this
... depotFile //depot/mycode/myfile.html
... clientFile /home/username/mycode/myfile.html
... isMapped 
... headAction integrate
... headType text
... headTime 1253307019
... headRev 2
... headChange 73363
... haveRev 2

grep clientFile

Filter out the line containing the filename on the local filesystem
... clientFile /home/username/mycode/myfile.html

awk '{print $3}'

print the 3rd field which contains the actual file name

No comments:

Post a Comment