perforce使用心得(持續更新中)

Perforce 爲軟件配置管理系統,簡稱P4。系統由服務器端,客戶端組成,還包括若干中介服務器 (Proxy Server)。

 上傳的文件分爲兩類,一類是已經存在的公用文件,比如a ;另一個是自己新建的文件,比如b.

p4上傳文件步驟:

詳細的命令解讀:https://www.perforce.com/manuals/v15.2/cmdref/p4_sync.html

p4v後圖形界面的操作:https://gameinstitute.qq.com/community/detail/127465

                                       https://blog.csdn.net/kuangyeliangguang/article/details/83791483

較好的可以參考的博客:https://blog.csdn.net/qq_31019565/article/details/86509905

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的路徑,,然後在把對應workspace的文件夾rm -rf掉)

12、添加client, 這裏使用的腳本 mkpwa -s //depot/file1  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 用於登錄

 

 

以下爲轉載的別人的p4 resolve 的解釋:https://blog.csdn.net/lbt_dvshare/article/details/86479997

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 的使用  https://blog.csdn.net/iteye_13237/article/details/81689248

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章