一 靜態label
靜態label使用labelsync或tag來產生,實際上包含了具體的檔案和版本資訊。 檔案必須同時包含在clientspec和label的view中,clientspec和label的view可以不相同。
1)server上兩個depots(depot和depot2),且本地sync到最新的changelist@2
C:\>p4 -p localhost:1666 -u aaa -c aaa_test depots Depot depot 2012/10/20 local depot/... 'Default depot' Depot depot2 2012/10/20 local depot2/... 'Created by AAA. '
C:\>p4 -p localhost:1666 -u aaa -c aaa_test changes
Change 2 on 2012/10/20 by AAA@AAA_Test 'second '
Change 1 on 2012/10/20 by AAA@AAA_Test 'first '
2)但是clientspec只包含了一個depot
C:\>p4 -p localhost:1666 -u aaa -c aaa_test client -o Client: AAA_Test Update: 2012/10/20 11:12:11 Access: 2012/10/20 11:21:04 Owner: AAA Host: AAA-PC Description: Created by AAA. Root: D:/p4/AAA_Test Options: noallwrite noclobber nocompress unlocked nomodtime normdir SubmitOptions: submitunchanged LineEnd: local View: //depot/... //AAA_Test/depot/...
3) 建立label1
C:\>p4 -p localhost:1666 -u aaa -c aaa_test label label1 Label label1 saved. C:\>p4 -p localhost:1666 -u aaa -c aaa_test label -o label1 # A Perforce Label Specification. # # Label: The label name. # Update: The date this specification was last modified. # Access: The date of the last 'labelsync' on this label. # Owner: The user who created this label. # Description: A short description of the label (optional). # Options: Label update options: [un]locked, [no]autoreload. # Revision: Optional revision specification to make an automatic label. # View: Lines to select depot files for the label. # # Use 'p4 help label' to see more about label views. Label: label1 Update: 2012/10/20 11:27:16 Access: 2012/10/20 11:27:16 Owner: AAA Description: Created by AAA. Options: unlocked noautoreload View: //depot2/... //depot/... 4)將本地的depot下的檔案sync到label1中 (可以看到雖然label中view包含了depot2,但是由於我們本地的client中只包含depot下的檔案,所以最終label1中也只有depot下的檔案) C:\>p4 -p localhost:1666 -u aaa -c aaa_test labelsync -l label1 //...#have //depot/File1.txt#1 - added //depot/file2.txt#1 - added
C:\>p4 -p localhost:1666 -u aaa -c aaa_test files //...@label1
//depot/File1.txt#1 - add change 1 (text) //depot/file2.txt#1 - add change 1 (text)
5)用tag命令建立label2 (可以看到雖然label中view包含了depot2,但是由於我們本地的client中只包含depot下的檔案,所以最終label2中也只有depot下的檔案)
C:\>p4 -p localhost:1666 -u aaa -c aaa_test tag -l label2 //...#have //depot/File1.txt#1 - added //depot/file2.txt#1 - added
C:\>p4 -p localhost:1666 -u aaa -c aaa_test label -o label2 # A Perforce Label Specification. # # Label: The label name. # Update: The date this specification was last modified. # Access: The date of the last 'labelsync' on this label. # Owner: The user who created this label. # Description: A short description of the label (optional). # Options: Label update options: [un]locked, [no]autoreload. # Revision: Optional revision specification to make an automatic label. # View: Lines to select depot files for the label. # # Use 'p4 help label' to see more about label views. Label: label2 Update: 2012/10/20 11:30:43 Access: 2012/10/20 11:30:43 Owner: AAA Description: Created by AAA. Options: unlocked noautoreload View: //depot2/... //depot/... C:\>p4 -p localhost:1666 -u aaa -c aaa_test files //...@label2 //depot/File1.txt#1 - add change 1 (text) //depot/file2.txt#1 - add change 1 (text) 6)修改clientspec包含depot2 C:\>p4 -p localhost:1666 -u aaa -c aaa_test client Client AAA_Test not changed. C:\>p4 -p localhost:1666 -u aaa -c aaa_test client -o Client: AAA_Test Update: 2012/10/20 11:31:47 Access: 2012/10/20 11:31:04 Owner: AAA Host: AAA-PC Description: Created by AAA. Root: D:/p4/AAA_Test Options: noallwrite noclobber nocompress unlocked nomodtime normdir SubmitOptions: submitunchanged LineEnd: local View: //depot/... //AAA_Test/depot/... //depot2/... //AAA_Test/depot2/... 7) 使用label1來sync代碼 C:\>p4 -p localhost:1666 -u aaa -c aaa_test sync -f //...@label1 //depot/File1.txt#1 - refreshing D:/p4/AAA_Test\depot\File1.txt
//depot/file2.txt#1 - refreshing D:/p4/AAA_Test\depot\file2.txt
8)不使用label來sync代碼
C:\>p4 -p localhost:1666 -u aaa -c aaa_test sync -f //... //depot/File1.txt#1 - refreshing D:/p4/AAA_Test\depot\File1.txt //depot/file2.txt#1 - refreshing D:/p4/AAA_Test\depot\file2.txt //depot2/test1.txt#1 - added as D:/p4/AAA_Test\depot2\test1.txt
//depot2/test2.txt#1 - added as D:/p4/AAA_Test\depot2\test2.txt
二 動態label
動態label需要建立的時候指定revision來指定版本,其實內部並沒有記錄具體的檔案,只指定了版本。不需要使用labelsync或tag來sync檔案。
1)建立label3 (注意 Revision:@2 表示此label與changlist 2 關聯)
C:\>p4 -p localhost:1666 -u aaa -c aaa_test label label3 Label label3 saved. C:\>p4 -p localhost:1666 -u aaa -c aaa_test label -o label3 # A Perforce Label Specification. # # Label: The label name. # Update: The date this specification was last modified. # Access: The date of the last 'labelsync' on this label. # Owner: The user who created this label. # Description: A short description of the label (optional). # Options: Label update options: [un]locked, [no]autoreload. # Revision: Optional revision specification to make an automatic label. # View: Lines to select depot files for the label. # # Use 'p4 help label' to see more about label views. Label: label3 Update: 2012/10/20 11:46:23 Access: 2012/10/20 11:46:23 Owner: AAA Description: Created by AAA. Options: unlocked noautoreload Revision: @2 View: //depot2/... //depot/...
2)當前所有的chagnelist
C:\>p4 -p localhost:1666 -u aaa -c aaa_test changes
Change 3 on 2012/10/20 by AAA@AAA_Test 'c ' Change 2 on 2012/10/20 by AAA@AAA_Test 'second ' Change 1 on 2012/10/20 by AAA@AAA_Test 'first ' 3)查看label3的使用 C:\>p4 -p localhost:1666 -u aaa -c aaa_test files //...@label3 //depot/File1.txt#1 - add change 1 (text) //depot/file2.txt#1 - add change 1 (text) //depot2/test1.txt#1 - add change 2 (text) //depot2/test2.txt#1 - add change 2 (text) C:\>p4 -p localhost:1666 -u aaa -c aaa_test sync -f //...@label3 //depot/File1.txt#1 - refreshing D:/p4/AAA_Test\depot\File1.txt //depot/file2.txt#1 - refreshing D:/p4/AAA_Test\depot\file2.txt //depot2/test1.txt#1 - updating D:/p4/AAA_Test\depot2\test1.txt //depot2/test2.txt#1 - refreshing D:/p4/AAA_Test\depot2\test2.txt
完!