【发布时间】:2023-03-15 05:04:01
【问题描述】:
我有一个特定的更改列表,我想从命令行列出属于该更改列表的所有文件。我该怎么做?
【问题讨论】:
-
可能是最简单的方法:
p4 files @=<cl> -
@user114245 那更准确,你应该添加一个答案
标签: perforce
我有一个特定的更改列表,我想从命令行列出属于该更改列表的所有文件。我该怎么做?
【问题讨论】:
p4 files @=<cl>
标签: perforce
这就是describe 命令。要描述特定的变更列表,您需要p4 describe <changelist number>。
更新:
如果只需要文件名,可以使用带有 -F 选项的 files 命令来覆盖输出格式:p4 -Ztag -F "%depotFile%" files @=<changelist>
有关 -F 选项的更多信息,请参阅http://www.perforce.com/blog/130826/fun-formatting。
【讨论】:
p4 -G describe -s <changelist number>,它将导致输出格式化为编组的 Python 字典对象,然后您可以只解析和检索文件。
Mike O'Connor 的回答也帮助了我。
至于只是获取更改的文件列表,难道就这么简单吗?
p4 describe -s {change number} | grep '^\.\.\.' | awk '{print $2}'
这就是我要使用的。
【讨论】:
awk '/^\.\.\./{print $2}'
p4 改变 -o
最后有文件列表。
【讨论】:
What opened files from the default changelist are to be added to this changelist. You may delete files from this list. (New changelists only.)
user114245 给出了最佳答案,但仅在评论中。我正在添加作为答案,以提高其知名度并进行一些改进。
对于更改 12345,这是您可以通过 p4 命令获得的最接近的值
p4 files @=12345
只给出这个输出
//depot/file1#3 - delete change 3 (text)
//depot/file2#3 - edit change 3 (text)
//depot/file5#1 - add change 3 (text)
如果您想删除每个文件的无关信息,您需要通过命令行上的更多工具处理该输出。假设是标准的 unixy 环境,您可以像这样使用单个 sed 命令
p4 files @=12345 | sed s/#.*//
得到想要的结果
//depot/file1
//depot/file2
//depot/file5
Mike 的currently accepted answer 是这个
p4 describe 12345
在输出中提供所有这些额外的细节
Change 12345 by day@client1 on 2013/06/21 00:25:28
Some example changes
Affected files ...
... //depot/file1#3 delete
... //depot/file2#3 edit
... //depot/file5#1 add
Differences ...
==== //depot/file2#3 (text) ====
1c1
< This is file 2
---
> This is file 2 - edited
Doug's answer 对此进行了改进,它使用 grep 和 awk 过滤掉噪音,只保留更改文件,但命令很长
p4 describe -s 12345 | grep '^\.\.\.' | awk '{print $2}'
我认为这里给出的解决方案更简洁。
【讨论】:
p4 fstat -T "depotFile" @=12345 也不错。但是你必须剪掉... depotFile 的前导文本。
如果您的更改列表仍处于待处理状态,您可以运行 p4 opened 或 p4 opened -c <changeListNumber> 以获得特定(未提交的)更改列表编号。
来自official documentation: "列出挂起的更改列表中打开的文件。"
【讨论】: