如何获取待处理的 Perforce 变更列表中所有文件的差异?
我想获取特定待定更改列表中文件的差异。 我希望我能做到这一点:
p4 diff -c 999
有人可以帮我组合一些 csh 魔法来实现这一点吗?
也许可以将 p4 opens -c 999
的输出通过管道传输到 p4 diff
吗?
I want to get diffs on files in a specific pending changelist. I wish I could do this:
p4 diff -c 999
Can someone help me string together some csh magic to make this happen?
Maybe take the output of p4 opened -c 999
and piping it to p4 diff
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
将更改搁置到挂起的更改列表中,然后运行
Shelve the changes in the pending changelist, then run
最简单的方法是在 p4v 或 p4win 中,但这不是您要问的。
尝试这个:
当然,您需要确保子 shell 的路径中有 p4,并且 $P4CLIENT 等...都已设置。
The easiest way is in p4v or p4win, but that's not what you were asking about.
Try this:
You, of course, need to make sure that the sub shell has p4 in its path, and $P4CLIENT, etc... are all set up.
解决方案
说明
p4 -x
为您提供xargs
类似的能力,而无需使用 xargs。 来自p4 help utils
:因此,您几乎可以按照问题中的建议“获取 p4 opening -c 999 的输出并将其通过管道传输到 p4 diff”。 一个棘手的部分是 p4 opening 的输出在每个打开文件的名称后面包含修订号和解释文本,例如
但我们可以通过简单的 sed -e 's/# 来运行它.*//' 删除从
#
开始的所有内容,只留下路径:然后可以从标准输入中使用这些路径并馈送到
p4 diff
感谢p4 -x -
。如果任何文件的名称中包含
#
,那么您需要更巧妙地使用sed
命令。 并去看心理医生。Solution
Explanation
p4 -x
gives youxargs
like ability without having to usexargs
. Fromp4 help utils
:So you can almost just "take the output of p4 opened -c 999 and pipe it to p4 diff" as suggested in the question. The one tricky part is that the output of
p4 opened
contains revision numbers and explanatory text after the name of each open file e.g.But we can run this through a simple
sed -e 's/#.*//'
to strip off everything from the#
onwards to leave just the paths:which can then be consumed from standard input and fed to
p4 diff
thanks top4 -x -
.If you have
#
in the names of any files then you'll need to get more clever with thesed
command. And see a psychiatrist.p4 描述 999 | grep '#' | | grep '#' | 剪切-d"#" -f1|剪切-d" " -f2 | xargs p4 差异
p4 describe 999 | grep '#' | cut -d"#" -f1|cut -d" " -f2 | xargs p4 diff
您可以像这样使用 shell 脚本:
使用更改列表编号调用它,您将在标准输出中获得补丁。
You can use shell script like this:
call it with changelist number and you'll get patch in stdout.
我使用了与 Mark 类似的方法,但我使用 Perl 而不是 Awk,以及 shell 函数(在 zsh 中):
请注意,除了更改列表名称/编号之外,您还可以提供文件路径:
I used a similar approach as Mark, but I used Perl instead of Awk, and a shell function (in zsh):
Note that you can provide a file path too, in addition to just the changelist name/number:
对于在 Windows cmd shell 中工作的单行代码,请尝试以下操作:
要在批处理文件中执行此操作,您需要使用
%%F
而不仅仅是%F
。请注意,如果您安装了类似 UNIX 的实用程序包,例如 cygwin 或 unixutils,但是这个单行代码没有外部依赖项。
For a one-liner that works from the Windows cmd shell, try this:
To do this in a batch file you need to use
%%F
instead of just%F
.Note that some of the solution above will work under Windows if you have installed a unix-like utilities package such as cygwin or unixutils, but this one-liner has no external dependencies.
上面回答了您的问题,但是,如果将tile读取为比较更改列表上的目录,则可以用以下内容回答:
这将根据更改列表999将目录中的所有文件进行比较,如果它有,则使用“有”版本进行检查,否则它使用最新版本。
这是用 GNU Awk 3.1.3 测试的
The above answers your question but, if tile is read as diffing a directory on a change list it can be answered with the following:
This will diff all the files in the directory against the changelist 999 it uses the "have" version if it has be checked out otherwise it uses the latest version.
this was tested with GNU Awk 3.1.3
对于未搁置的更改(尚未在软件仓库中的更改)
对于搁置的更改(在软件仓库中的更改(p4 shelve -c 999)
For Unshelved Changes( Changes still not in depot)
For Shelved Changes( Changes that in depot ( p4 shelve -c 999)