ack*_*ack 37 shell terminal perforce csh
我想在特定的挂起更改列表中获取文件差异.我希望我能做到这一点:
p4 diff -c 999
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我串联一些csh魔法来实现这一目标吗?
也许把它的输出p4 opened -c 999
和管道输送到p4 diff
?
Ale*_*ird 25
保留挂起的更改列表中的更改,然后运行
p4 describe -S -du 999
Run Code Online (Sandbox Code Playgroud)
Mar*_*ark 20
最简单的方法是在p4v或p4win中,但这不是你要问的.
试试这个:
p4 opened -c 999 | awk 'BEGIN { FS = "#" } // { print "p4 diff " $1 }' | csh
当然,你需要确保子shell在其路径中有p4,并且$ P4CLIENT等等都已设置好.
Day*_*Day 13
p4 opened -c 999 | sed -e 's/#.*//' | p4 -x - diff
Run Code Online (Sandbox Code Playgroud)
p4 -x
xargs
无需使用即可为您提供相似的能力xargs
.来自p4 help utils
:
-x标志指示p4从指定文件读取每行一个参数.如果指定" - ",则读取标准输入.
因此,您几乎可以"按照p4打开-c 999的输出并将其输出到p4 diff",如问题所示.一个棘手的部分是输出p4 opened
包含每个打开文件名称后的修订号和说明文字,例如
//depot/example#123 - edit change 999 (text) by day@office
//depot/new-example#1 - add change 999 (text) by day@office
Run Code Online (Sandbox Code Playgroud)
但是我们可以通过一个简单的方法sed -e 's/#.*//'
来执行此操作,从一#
开始就剥离所有内容,只留下路径:
//depot/example
//depot/new-example
Run Code Online (Sandbox Code Playgroud)
然后可以从标准输入中消耗并馈送到p4 diff
感谢p4 -x -
.
如果您拥有#
任何文件的名称,那么您需要使用该sed
命令更加聪明.并看一位精神科医生.
小智 6
您可以像这样使用shell脚本:
#!/bin/sh
list=`p4 opened -c $1 | cut -d# -f1`
for file in $list ;
do
p4 diff -dwbu $file
done
Run Code Online (Sandbox Code Playgroud)
用变更列表号码调用它,你就可以在stdout中获得补丁.