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

一 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

posted @ 2011-08-09 14:30  iTech  阅读(2382)  评论(0编辑  收藏  举报