Given a Perforce changelist number, I want to find the local path of all files in that pending changelist.
- p4 describe changelist -- gets me the depot path for files in the changelist (method 1)
- p4 opened -c changelist -- gets me the depot path for files in the changelist (method 2)
- p4 have -- gets me the depot path and local path for all files that have previously been submitted
Using a combination of p4 describe and p4 have, I can find the local paths for all files in the changelist that have previously been submitted to Perforce (and are opened for delete or edit).
But what about files that are opened for add? p4 have does not know anything about files that are opened for add.
Given a pending Perforce changelist, how do I find the local path for files that are about to be added to Perforce?
To output the local path of all pending adds of a changelist you can use:
p4 opened -c changelist | grep -w add | sed 's/#.*//' \
| p4 -x - where | awk '/^\// {print $3}'
This does the same without grep but is a bit more obscure:
p4 opened -c changelist | sed -n 's/\(.*\)#.*- add .*/\1/p' \
| p4 -x - where | awk '/^\// {print $3}'
You could of course also use
p4 -ztag opened -c changelist
This will report both the depotFile and the clientFile for each opened file. To list only client files:
p4 -ztag opened -c changelist | grep clientFile | awk '{print $3}'
Replacing //client/ with the client's root is left as an exercise for the reader.
Local path for all files in a pending changelist without any external or platform-specific tools:
p4 -F %clientFile% fstat -Ro -F action=add [-e CHANGE] //...
Remove the '-F action=add' if you want to get files opened for all actions.
Based on Peter G's answer, translated into powershell 2.0:
p4 opened -c changelist
| Where-Object{$_ -match "add"}
| ForEach-Object{p4 where ($_.split('#')[0])}
| ForEach-Object{$_.split()[2]}
p4 opened -s -c <changelist#> | awk -F " " '{print $1}' | p4 -x - where | awk -F " " '{print $3}'
来源:https://stackoverflow.com/questions/5749807/in-perforce-how-do-i-find-the-local-path-for-files-in-a-pending-changelist