【发布时间】:2020-03-10 08:39:13
【问题描述】:
我是 p4 命令行用户。 典型用例,我在所有文件中搜索一个模式,打开这些文件进行编辑,SED 替换模式,只提交那些修改过的文件。
如何通过命令执行此操作?有没有办法创建一个新的更改列表,将这些文件添加到更改列表并将新的更改列表提交到默认更改列表。
【问题讨论】:
标签: perforce changelist
我是 p4 命令行用户。 典型用例,我在所有文件中搜索一个模式,打开这些文件进行编辑,SED 替换模式,只提交那些修改过的文件。
如何通过命令执行此操作?有没有办法创建一个新的更改列表,将这些文件添加到更改列表并将新的更改列表提交到默认更改列表。
【问题讨论】:
标签: perforce changelist
p4 -x 全局标志允许您将文件(或标准输入为 -)的内容作为参数传递给 p4 命令。 p4 edit 命令接受任意数量的文件参数;默认情况下,p4 submit 命令将对所有打开的文件进行操作。
C:\Perforce\test\grep>p4 print ...
//stream/main/grep/bar#1 - add change 145 (text)
wibble
//stream/main/grep/baz#1 - add change 145 (text)
wibble
//stream/main/grep/foo#1 - add change 145 (text)
weeble
//stream/main/grep/ola#1 - add change 145 (text)
weeble
C:\Perforce\test\grep>grep -l weeble * | p4 -x- edit
//stream/main/grep/foo#1 - opened for edit
//stream/main/grep/ola#1 - opened for edit
C:\Perforce\test\grep>sed -i -e s/weeble/wobble/ *
C:\Perforce\test\grep>p4 diff
==== //stream/main/grep/foo#1 - c:\Perforce\test\grep\foo ====
1c1
< weeble
---
> wobble
==== //stream/main/grep/ola#1 - c:\Perforce\test\grep\ola ====
1c1
< weeble
---
> wobble
C:\Perforce\test\grep>p4 submit -d "weeble wobble"
Submitting change 146.
Locking 2 files ...
edit //stream/main/grep/foo#2
edit //stream/main/grep/ola#2
Change 146 submitted.
请注意,上例中的p4 print 和p4 diff 命令不是提交文件所必需的;为了理解示例,我只是包含该输出以显示过程中这些点的文件状态。
【讨论】: