[SCM]源码管理 - perforce命令行高级

本文档详细介绍了如何使用Perforce的各种命令行工具进行版本控制操作,包括文件状态检查、文件增删改提交等基本操作,以及分支整合、冲突解决等高级特性。同时提供了实用的技巧说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一 p4命令行

1)p4counter.bat


call p4env.bat

REM counter is one persistant variable which is storaged in p4 server

REM p4 default counter for latest cl
p4 counter change

REM all p4 counters
p4 counters

REM need superuser permission
p4 counter lastpassedcl 25000

pause

REM use counter
p4 counter lastpassedcl 

pause

REM delete counter
p4 counter -d lastpassedcl 

pause

counter是存储在p4 server的一个环境变量,只有有管理员权限的用户才可以设置p4 counter变量。p4 counter change存储了最新的CL。

 

2)p4diff.bat

call p4env.bat

REM compare local workspace with latest version, but the file must be checked out.
p4 diff //depot/TestProject/Components.txt

pause

REM if the file is not checked out, the file version cannot be the latest version.
p4 diff //depot/TestProject/Components.txt#10

pause

 

3)p4add+edit+delete+submit.bat


call p4env.bat

p4 add 
//depot/TestProject/addfile.txt
echo test > H:\TestProject\addfile.txt

pause

p4 edit 
//depot/TestProject/components.txt
attrib -r H:\TestProject\components.txt
echo ccc 100>>H:\TestProject\components.txt

pause

p4 delete 
//depot/TestProject/File3.txt

pause

p4 submit -d 
"testaddeditdeletesubmit"

pause

p4 add :增加文件到default CL;

p4 edit :checkout(open for edit)文件到default CL;

p4 delete : 将文件标识为delete,且添加到到default CL;

p4 submit :提交default CL,但是必须用-d来指定Description;

 

3)p4print.bat


call p4env.bat

p4 
print -q //depot/TestProject/components.txt#head

pause

p4 
print -q -o c.txt //depot/TestProject/components.txt#head

pause

 获得p4 上文件的内容。

 

4)p4branch+integrate+resolve+submit.bat


call p4env.bat

set branchname=TestProjectAndTestProject2

echo Branch: %branchname% > branchspec.txt
echo.>> branchspec.txt
echo Description: the branch spec will be used for integration between TestProject and TestProject2 >> branchspec.txt
echo.>> branchspec.txt
echo Owner: %p4user% >> branchspec.txt
echo.>>branchspec.txt
echo Options: unlocked >> branchspec.txt
echo.>>branchspec.txt
echo View//depot/testProject/... //depot/testproject2/... >> branchspec.txt


cat branchspec
.txt | p4 branch -i


pause

p4 integrate -b %branchname% -Dt -Ds

pause

p4 resolve -am
p4 resolve -n

pause

p4 submit -d 
"sumbit for integration"

pause

 

自动完成branch的integration。

  

二 其他技巧

1)文件版本参数

#0或#none :表示从本地workspace中删除;
#have :表示本地workspace的版本;
#head :表示p4 server最新的;
@now, @labelname, @datetime, @changelistnumber ; 

实例:
doc/...@Good2Go 
doc/...@3405
doc/...@2004/01/04 
doc/index.html#14

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值