In Perforce, how do I find the local path for files in a pending changelist?

江枫思渺然 提交于 2019-12-06 20:05:47

问题


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?


回答1:


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}'



回答2:


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.




回答3:


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.




回答4:


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]}



回答5:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!