轉(zhuǎn)自:http://shashanzhao.com/archives/837.html
首先需要為perforce設(shè)置系統(tǒng)環(huán)境變量,以便perforce命令行可以正常使用.
| 環(huán)境變量名 | 值 |
| P4CLIENT | 填寫你的workspace的名字,例:code_myname |
| P4PORT | 填寫perforce服務(wù)器地址和端口號(hào),例:172.23.3.3:1666 |
| P4USER | 填寫你的用戶名,例:myname |
| P4DIFF(可選) | 填寫比較工具的路徑,例: d:/PRograms/BeyondCompare/BCompare.exe,如果使用perforce自帶的比較工具就不用設(shè)這個(gè)環(huán)境變量了 |
| P4PASSWD | 填寫登陸的密碼,例:passWord |
1. Source Insight菜單Options->Custom Commands,
選擇以下各個(gè)Command,填寫各個(gè)Command的Run.
| Command: | Run: |
| Check Out | p4 edit %f |
| Undo Check Out | p4 revert %f |
| Sync File to Source Control Project | p4 sync %f |
| Compare with Current | p4 diff –f %f |
其中Compare with Current命令需要自己添加.
點(diǎn)擊Add按鈕, 填入命名: Compare with Current即可添加一條.

另外Compare with Current必須在check out狀態(tài)下才能比較,比較的就是未check out出來時(shí)的文件.
2. 填完后Custom Commands窗口不要關(guān),點(diǎn)擊Menu按鈕
將剛才的那些命令添加到work菜單下.
操作方法:
a.右邊的Menu組合框中選擇Work
b.左邊窗口選中命令,右邊窗口選中<end of menu>,
c.點(diǎn)擊Insert按鈕把命令插入work菜單下
d.重復(fù)b-c,直至所有命令添加完畢
e.按下OK按鈕
3. 打開文件,在work菜單下就可以選擇Check Out, Undo Check Out, Sync File to Source Control Project, Compare with Current等菜單來操作文件了
另外也可以打開Source Control工具欄,通過主菜單View->Toolbars->Source Control,
在Source Control工具欄上默認(rèn)有Check Out, Undo Check Out, Sync File to Source Control Project等按鈕.
![]()
1. Visual Studio菜單:工具->外部工具,
添加以下各個(gè)工具,填寫各個(gè)工具的標(biāo)題,命令和參數(shù).注意添加時(shí)選中使用輸出窗口.
| 標(biāo)題: | 命令: | 參數(shù): |
| Check Out | p4.exe的路徑,例:C:/Program Files/Perforce/p4.exe | edit $(ItemPath) |
| Undo Check Out | p4.exe的路徑 | revert $(ItemPath) |
| Sync File to Source Control Project | p4.exe的路徑 | sync $(ItemPath) |
| Compare with Current | p4.exe的路徑 | diff –f $(ItemPath) |

2. 打開代碼后,在”工具”菜單下可以找到新增加的菜單.
3. 還可以在”工具”->”自定義”中把外部命令拖到工具欄上,方便使用.

注意:在自定義中只顯示外部命令+數(shù)字,所以先要看一下新加的外部命令排在第幾個(gè),然后選擇對(duì)應(yīng)的外部命令(例:外部命令10)拖到工具欄上即可.另外各個(gè)版本的Visual Studio的自定義可能會(huì)有些區(qū)別,我所測(cè)試的是VS2005.
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注