现在的位置: 首页 > 综合 > 正文

[SCM]源码管理 -perforce label实例

2013年04月11日 ⁄ 综合 ⁄ 共 5655字 ⁄ 字号 评论关闭

 

一 静态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

  

完!

抱歉!评论已关闭.