Perforce 为软件配置管理系统,简称P4。系统由服务器端,客户端组成,还包括若干中介服务器 (Proxy Server)。
上传的文件分为两类,一类是已经存在的公用文件,比如a ;另一个是自己新建的文件,比如b.
p4上传文件步骤:
详细的命令解读:
p4 sync // P4 Command Reference
p4v后图形界面的操作:
Perforce使用教程-腾讯游戏学堂
Perforce使用教程_旷野亮光-CSDN博客_perforce
在工作中打开P4图形界面通过输入p4v&,(这个都不用管在哪个目录下,只是打开P4的图形界面,local和depot文件需要在图形界面去做比较)
较好的可以参考的博客:
HelixCore P4 Command Reference(详解,持续更新中)_浅尝辄止,未尝不可的博客-CSDN博客
1、
p4 sync
(-q静默模式,sync前要cd到相应的目录下,若只想sync某一个子目录,p4 sync name/... 或者sync某个文件 p4 sync file1)
2、
p4 edit a
(p4 识别我编辑了这个文件,处于opened状态,
先p4 edit 文件才有写权限,之后可以通过gvim或者cp命令去修改覆盖文件
)
3、
p4 add b
(告诉p4我自己增加了这个文件,
一般先在本地mkdir或者直接cp文件,然后p4 add告知服务器这个client添加了这个文件
)(若要在某个子目录下添加一个文件,而且这个子目录local不存在,使用p4 add a/b/c.sv会自己创建a/b/目录,其实在一想,我
我可以现在本地mkdir -p a/b/c.sv ,在通过gvim/cp去更改文件,然后 p4 add即可)
4、
p4 opened
(查看我更改过的文件,此时会显示出 a b 两个文件)
5、
p4 revert filename
(把文件恢复到修改之前的版本,首先要 p4 edit filename , revert 才有效)
6、
p4 submit -d "your comment"
7、执行完6 后,非常不幸地出现以下提示:
Merges still pending -- use 'resolve' to merge files.
Submit failed -- fix problems above then use 'p4 submit -c 74346' (若出现问题,想要查看,可以使用p4 submit -c 74346 > submit_c_74346_txt,在gvim查看)
个人暂时理解是我要上传的文件已经有人改过,我需要把我增加的部分merge进去,执行步骤8
8、
p4 resolve a
出现提示要不要把你的和别人的merge在一起, 键入 am ,表示接受merge
9、执行步骤7出现的
p4 submit -c 74346
(submit完成)。
10、
p4 delete
(delete,add ,edit,都为进入opened状态,但三者不能同时修改在一个文件上,想要delete整个子目录 p4 delete ./...,本地在rm -rf 掉)
11、
p4 client
(若要删掉client使用p4 client -d client_name一定是client名字而不是workspace的路径,“P4 workspace 是 p4 client 的alias,所以p4 client -d workspace 就是指删掉workspace和depot 之间的联系,”,然后在把对应workspace的文件夹rm -rf掉) “p4 client用于编辑client的信息,p4 set 可以查看client的信息”
12
、添加client
, 这里使用的脚本 mkpwa -s //depot/file1 file1_workspace (执行完mkpwa之后,会自动的生成file1_workspace目录)
13、
与stream
有关的提交(不具有适用性,特定在目前搭建的版本库里使用)
1. p4 edit import.cif
2. gvim/cp文件做修改
3. cfg2spec -edit import.cif
4. p4 submit -d "description"
14.用
diff
进行比较的时候,推荐使用gvimdiff a/b/c.file1 d/f/g.file2
15、
p4 client
可以查看和编写client的信息
16、
p4 login
用于登录
17、
P4 change
遇到 edit 了多个文件,eg: a,b,c,d. 但是只需要上传其中的部分文件, eg: a,b.
p4 opened // 显示 a b c d 四个文件被编辑
p4 change // 通过p4 change,得到一个change list (eg:116119), 并自动生成打开一个 vim 文件,编辑文件,把不需要的文件 c d 从vim里去掉,添加description, 保存并退出。
p4 submit -c CL //CL为刚才得到的change list, 比如 116119, 我需要输入命令p4 submit -c 116119, 就会把需要上传的 a b 上传
p4 opened // 此时会发现, 只有c d 还在, a b 已经被上传
p4 resolve
-am或-as参数
-am表示accept merged,具体为如果theirs与base一致,接受yours,如果yours与base一致,接受theirs,如果yours和theirs都与base不同,但是yours和theirs没有冲突,接受自动merged的结果,否则如果yours和theirs也有冲突,则忽略此文件。
-as比-am更严谨,不管yours与theirs是否有冲突,只要yours和theirs都与base有不同就忽略此文件。
-ay Accept Yours, ignore theirs.
-at Accept Theirs.
--------------------------------------------------------------------------------------------------------------------------------------------
解释下theirs,base和yours
theirs: The head revision of the file in the depot.(P4 上的最新版)
base: The file revision synced to the client workspace before it was opened for edit.(P4上open for edit之前的P4版本)
yours : The revision of the file in the client workspace(当前open for edit编辑的local file)
举个栗子:某个文件你在第3版时open for edit ,别人在此时进了一版,即最新版时第4版;此时,第四版是theirs,第三版是base,基于第三版编辑的local file是yours.
-------------------------------------------------------------------------------------------------------------------------------------------
在执行p4 resolve 时会show出diff的结果,比如
Diff Chunks: 2 yours + 3 theirs + 5 both + 7 conflicting
The meanings of these values are:
| Count | Meaning |
| n yours | n non-conflicting segments of yours are different than base. |
| n theirs | n non-conflicting segments of theirs are different than base. |
| n both | n non-conflicting segments appear identically in both theirs and yours, but are different from base. |
| n conflicting | n segments of theirs and yours are different from base and different from each other. |
p4 integrate 的使用 Perforce的各种命令_basictk-CSDN博客
假如误传的文件@CL:12345,那么需要执行如下2条命令:
p4 undo @12345
p4 submit
以上2条命令会把@CL12345中的文件回退到之前的版本,即撤销此次上传。
注意:这儿所说的退板,是指文件内容退到上个版本,但是由于执行了submit,文件版本号还是会增加。
如果只想回退@CL12345中的riscv_ptg_rtl.sv该怎么办?需要3步
p4 undo @12345
p4 submit riscv_ptg_rtl.sv
p4 revert ...
p4 shelve的使用
1. user A edit f1 and shelve it:
p4 open f1 # user A can open multiply files
[eidt it] #p4 eidt/add also opn f1
p4 shelve #like with submit, need to be added description
2. user B get f1 to his local by:
p4 unshelve -s <user A's shelve's changelist> #f1 is also opned by user B after this command
3. user B edit f2:
p4 open f2
[edit it, to make RunSanity pass]
[told user A f1 is ok, and got user A's permission to submit f1]
p4 submit # this command will submit both f1 and f2 together
4. user A discard shelve changlist:
p4 shelve -d -c <user A's shelve's changelist> #discard the shelved changelist
p4 shelve filename // 在库上备份一份文件,生成一个 changelist, 但是不会submit, 因此,别人p4 sync 的时候, 不会把 shelve 的文件sync 下来。
// 用于把修改的但是还不能上传的文件放在库上, 其他同事可以根据 changelist 把shelve 的文件放到本地。
如果第一次shelve了文件a, 但是想把文件b也放到同一个changelist里。
- p4 reopen -c changelist b // 把 changelist打开,把b 加进去
- p4 shelve -r -c changelist // shelve changelist 里包含的所有文件
p4 shelve 的文件不能通过p4 submit 上传到库上,需要:
- p4 shelve -d -c changelist // 删掉在库上保存的备份(这个是个人理解,可能有错)
- p4 submit -c changelist // 把 shelve 的文件上传到库上
Perforce 为软件配置管理系统,简称P4。系统由服务器端,客户端组成,还包括若干中介服务器 (Proxy Server)。 上传的文件分为两类,一类是已经存在的公用文件,比如a ;另一个是自己新建的文件,比如b.p4上传文件步骤:详细的命令解读:https://www.perforce.com/manuals/v15.2/cmdref/p4_sync.htmlp4v后图形界...
export P4PASSWD=abcdefg
export P4CLIENT=dyoldfish.com //这个是workspce
export P4USER=dyoldfish
export P4PORT=192.168.1.198:1666
Copy the latest revision of all files from the depot to the client workspace, as mapped through the client view.
If the file is alre...
尝试参考 官方文档 Helix Core Command-Line (P4) Guide (2022.1) 学习如何使用命令行执行P4操作。
(P4所有命令见:Helix Core Command-Line (P4) Reference (2022.1))
(本篇测试环境上接《学习从零创建并配置一个P4服务器》,只是又新加了一个名为yaksue的用户,并在仓库中新加了一个测试文件名为 guaguga.txt)
确认:已经连上服务器
输入p4 info来确认是否已经连上了服务器,如果没有,则会出现以下提
http://www.perforce.com/documentation/perforce_technical_documentation
http://blog.csdn.net/brucexu1978/article/details/7181768
http://www.perforce.com/perforce/doc.current/manuals/cmdref/sync.html...
Perforce 版本管理服务
Perforce版本管理服务管理公用文件信息库(或称之为depots)。
该服务维护一个数据库以记录变更日志、用户权限以及某个用户在某个时点签出某个文件。
Perforce服务通过本地操作系统来管理数据库和版本化文件,因而不需要专门的文件系统或者卷。
Perforce 应用程序
作用:与版本管理服务进行通讯,管理用户工作站上存储了depot中部分文件的本地拷贝的客户端工作区。