`

clearcase 操作指南

阅读更多

请注意:不同版本,命令用法有可能不同

1.将整个目录导入clearcase
clearfsimport -r
‘源路径’‘目标路径’
2.加锁
find . -name '*.*' -exec 'cleartool lock nuser userame1,username2 "%CLEARCASE_PN%"'
3.
解锁
find . -name '*.*' -exec 'cleartool unlock  "%CLEARCASE_PN%"'
4.
转换格式
chtype  -f compressed_file “fileName”
5.
查看VOB的基本信息和UUID
des -l vob:.
6.
删除视图
rmview -uuid "UUID"
7.
删除lost+found
find . -name '*.*' -exec 'cleartool rmelem -f "%CLEARCASE_PN%"'
8.
查询某一天的修改记录
cleartool lshis -r -since 07-dec
9.
最基本的操作
cleartool co -nc filename
cleartool ci -nc filename
10.
查看自己总共co了多少文件
cleartool lscheckout -cview -me -avobs
11.make
目录和文件
cleartool mkdir -c comment newdirectory
cleartool mkelem -c comment newfilename
12.
主线、分支文件合并
//查找需要合并的文件
cleartool findmerge . -fversion /main/TEST_Path -print 
//
比较文件不同
cleartool diff filename filename@@/main/TEST_Path/LATEST

//查看最新版本
cleartool lsvtree filename
//
合并
cleartool merge -to filename  filename @@/main/TEST_path/LATEST  filename @@/main/LATEST
13.
标签相关
cleartool mklbtype -nc TEST_LABEL
cleartool mklabel -r TEST_LABEL filename
cleartool rmtype lbtype:TEST_LABEL
//
给所有打上TEST_LABEL标签的文件打上TEST_LABEL标签
cleartool mklabel -replace -version /main/TEST_LABEL TEST_LABEL *
//
查找打上TEST_LABEL标签的所有文件
cleartool find . -version "lbtype(TEST_LABEL)" -print
//
查找打上TEST_LABELTEST_LABEL1标签的文件
cleartool find . -element 'lbtype_sub(TEST_LABEL) && lbtype_sub(TEST_LABEL1)' -print
14.
察看某目录下的文件
ls
15.man/help
命令
cleartool man  xxx
cleartool help xxx
16.
放弃co某个文件
cleartool unco -keep filename
cleartool unco -rm   filename
17.
更改VOBOwner:
cleartool protectvob –chown root  /vob/vob.vbs
18.
更改VOBGroup:
cleartool protectvob –chgrp alluser  /vob/vob.vbs
19.
增加Additional Group:
cleartool protectvob –add_group group1  /vob/vob.vbs
20.
删除Additional Group:
cleartool protectvob –delete_group group1  /vob/vob.vbs
21.
更改groupownermod
protect -r -chgrp groupname–chown username -chmod 770 .
22.
创建VOB
cleartool mkvob -tag /vobtags/test_code -c "Test" "D:\Data\Tets.vbs"
23. Mount vob
Cleartool mount /vobtags/vob
24.
创建视图
cleartool mkview –tag test /ccvob/views/test.vws
25.
设置当前视图
cleartool setview test
26
.设置当前的activity
cleartool setactivity activityname 
27. Check out
Check out
一个文件
Cleartool checkout [-reserve][-unreserve] filename

Check out前目录
Cleartool checkout .

Check out当前目录下所有文件
Cleartool Checkout –nc *.* 
Check out
当前目录下所有的文件和目录中的文件
cleartool find . $file -exec ‘cleartool checkout -nc $CLEARCASE_PN’
28. Check in
Check in
一个文件
Cleartool checkin filename
Check in
当前目录
Cleartool checkin .
Check in
当前目录下所有文件.
Cleartool Checkin –nc *.*
Check in
当前目录下所有的文件和目录中的文件
cleartool find . $file -exec ‘cleartool checkin -nc –ide $CLEARCASE_PN’

 

 

Clearcase命令深入

Some useful clearcase commands

a .Create branches branch_name1 from /main/0, merge them from other branch branch_name2

clt find . -version 'version(.../main/0)' -print -exec 'cleartool mkbranch -nc -version /main/0 branch_name1 $CLEARCASE_PN;cleartool merge -to $CLEARCASE_PN -version /main/branch_name2/LATEST'

b. check in all the checkedout elements 

        clt lsco -cview -recurse -short .|xargs cleartool ci -nc

c. label the last version of branch branch_name

        clt find . -version 'version(/main/brach_name/LATEST)' -print -exec 'cleartool mklabel -nc LABEL_NAME $CLEARCASE_PN'

        use this command to check whether all the files are labeld:

        clt find . -version 'version(/main/brach_name/LATEST) &&! lbtype(LABEL_NAME)' -print

 d. check the labeled files. This command print the files labeled by LABEL_04, but LABEL_03.

        clt find . -version 'lbtype(LABEL_04) &&! lbtype(LABEL_03)' -print

 e. merge from version

    print the file need merge

         clt findmerge . -fver LABLE_01 -print 

 

 

 

创建viewclt mkview -tag view_abcd /view_store/view_abcd.vws

 

设置view: clt setview view_abcd

编辑config specification: clt edcs

创建branch typeclt mkbrtype dbg_branch1_comments

在某个文件的当前branch上, 拉出一个branch

clt mkbranch dbg_branch1_comments filename.c

now you have make branch on the file, and checked it out.

you can edit it with gvim.

After changed codes, you can complie it successfully, and test the result, you can check it in.

clt ci filename.c

If you want to check out it again:

clt co filename.c

To change the branch name to a formula name you can use the command:

clt chtype brtype:dbg_branch1_comments brtype:crnumber_branch1_comments

 

To see the version tree of a file:

clt lsvtree -g filename.c

 

To see which files is included in a branch, you can edit a script like this find_branch.sh:

echo ""
cleartool find -avobs -element "brtype("")" -nxn -print | xargs cleart
cleartool ls -s|grep ""

   

lsview -l 视图名称(可查询uuid)

unregister -view -uuid uuid

rmview -f -all -uuid uuid

rmtag -view 视图名称

 

Removing a View

To permanently remove a view (including its entries in the ClearCase registry and all

references to the view held by any VOBs), use the ClearCase Administration Console:

1 Navigate to the view storage node for the view. This is a subnode of the host node

for the host where the view storage directory resides.

2 Click Action > All Tasks > Remove View.

You can also use the cleartool rmview command.

If you have tried to remove a view by simply removing its storage directory, use the

following procedure to remove references to the view still held by VOBs:

1 Run the cleartool describe command, and note the view’s UUID from the list of

views referenced by a VOB:

cleartool describe –long vob:vob_tag

If the view tag still exists, you can use lsview –long to find the view UUID.

2 If the view tag still exists, remove it from the registry. In the ClearCase

Administration Console, you can use the View Tags node for the tag’s regions to

remove view tags. You can also use the following command:

cleartool rmtag –view view_tag

3 Unregister the view. In the ClearCase Administration Console, you can use the

View Object node to remove a view object. You can also execute the following

command, using the view’s UUID from Step 1:

cleartool unregister –view –uuid uuid

4 Remove references to this view from each VOB that holds them. In the ClearCase

Administration Console, you can use the Referenced Views subnode of a VOB

storage node to remove a view’s records from a VOB. You can also execute the

following command, using the view’s UUID from Step 1:

cleartool rmview –all –uuid uuid

After you have removed references to the view from all VOBs, remove the view storage

directory if any of it remains.

 

 

1. When you come to work, the first thing you need to do is: Create a View

 

ct mkview -tag <view_tag> <view_storage_path>

 

   example:   ct mkview -tag alex_test /net/nj2/ 

Other Command:

ct lsview                  list all the views reside in the hosts 

ct lsview | grep name      list specified view by name 

ct rmview -tag <view_tag>  remove an exist view 

2. After you create a vew, you need to Set the View to enter it. Then you are able to see the vob content only when you set the view.

ct setview <view_tag> 

Example: ct setview alex_test 

Other Commands
ct pwv                     see which view you are currently in 
exit                       quit from current view 

3. When you are in a view, you need to set the config spec correctly to pick up the right version of element.

ct catcs                   view your config spec 
ct edcs                    edit your config spec by vi editor 
Other Commands
ct catcs > filename        Copy your config spec to a file 

ct setcs filename          Set your config spec from a file 

 

For example:
element* CHECKEDOUT

element* .../ISGcq00123456/LASTEST

element* BLUETOOTH_00.07.00

element* AP_SIPC.01.32.00

element* AP_IB2.00.38_ARM

element* /main/LATEST

 

Command

element <file path> <version path> 

file path: hello.c, *, /vob/su_java/...

version path: Label or Branch

 

4. Now you may have a task to do. You have a CR assigned, and you know the baseline version.

Set config spec to the baseline version. 

Create branch type associated with the CR.

ct mkbrtype ISGcq00123456 

Make branch on the baseline version

ct mkbranch ISGcq00123456 hello.c@@/main/2 

   Result: hello.c@@/main/ISGcq00123456/0 is created and checked out(a copy of hello.c in the dir was created and you can edited it. If there is not hello.c in the dir, the clearcase would submit a error).

Add a rule to pick up this branch in the config spec, just below the CHECKEDOUT rule.

element* .../ISGcq00123456/LATEST 

Accessional:

Branch type shall have naming convention designed by every project. 

Don't want check out:

ct mkbranch -nco ISGcq00123456 hello.c@@/main/2 

 

Remove a branch from an element:

ct rmbranch hello.c@@/main/ISGcq00123456. 

 

Make sure no checked out version on this branch

 

Rename a branch name

ct rename brtype:old_name brtype:new_name 

It will apply to all the created branch.

Remove a branch type as well as all the related element branch

ct rmtype -rmall brtype:ISGcq00123456 

5. After making your CR branch on the file to be changed, check out the version if it hasn't been checked out(checkout后会产生一个自己的私有文件,你可以自己修改,别人看不到,只有这个文件被checkin后才会放到vobs).

ct co -nc hello.c@@/main/ISGcq00123456/0

    Then, you are able to edit this file. After you finish the change, check in the file to vob.

ct ci -nc hello.c

    The result is, the element will increase one version on the branch:

hello.c@@/main/ISGcq00123456/1

Accessional

A checked out version is only in your view. Other engineer can not see it. If you remove that view, you will lost the checked out version.

You can undo checkout by:

ct unco hello.c

If a checked version has no change, it can't be checked in. You will get an error message like "The file is identical"

An unreserved checked out will not block other people check out the same version. Normally, we just use reserved checkout.

You can only check out a file on the branch which has mastership role.

6. If your task is to create a new file, you need to do below steps:

Make branch on the directory that you will add the file to

ct mkbranch ISGcq00123456 /vob/su_jave/code/src 

The directory will be automatically checked out. Then make element in this dir.

ct mkelem -nco hello.c 

     Create a folder

ct mkelem -eltype directory test 

      Dont check it out, because you need to make the CR branch on this file.

ct mkbranch ISGcq00123456 hello.c 

Check in this directory. Otherwise, other people can not see your new file.

ct ci -nc /vob/su_java/code/src 

Accessional

We usually only check in the file, but forget to check in the directory. This will cause the file you created can't be stored in the VOB and can't be seen by other people. 

Go to the top project folder, use below command to list all checked out files and directories int the current dir and sub dir in your view. It will help you check in all elements.

ct lsco -cview -r 

 

7. Now, your task is ongoing. In coding and testing, you may need to merge your file to other version. below example gives the merge steps:

Example: Merge file from hello.c@@/main/branchfrom/5 to hello.c@@/main/branchto/2

ct co -nc hello.c@@/main/branchto/2 

ct merge -to hello.c hello.c@@/main/branchfrom/5 

  Usually you may also need to compare two versions

ct diff hello.c hello.c hello.c@@/main/branchfrom/5 hello.c@@/main/branchto/2 

Compare this version from the previous version

ct diff -pre hello.c@@/main/branchto/2 

 

Accessional

Use this command to list all versions of an element

ct lsvt hello.c 

     include the merge info

ct lsvt -merge hello.c 

     Remove a merge arrow:

ct rmmerge hello.c@@/main/branchfrom/5 hello.c@@/main/branchto/2 

     Dont do actual merge, just draw a merge line

ct merge -ndata hello.c@@/main/branchfrom/5 hello.c@@/main/branchto/2 

 

In what cases we need merge:

Integrate with the code developed by someone else. 

If baseline version has been incresed, need upermage. 

Merge for release.

8. If you want to remove an un-use version, use the command

ct rmver hello.c@@/main/branchto/2 

     Then the version 2 will be removed, but next time the version will increase from 1 to 3.

     If you want to remove a file, you can use remove name command:

ct rmname hello.c 

     Be sure to make branch and check out the current directory before rmove it, just like the steps of make element.

     If you want to rename a file, you can use

ct mv old_name new_name 

     If you want to create an element link, you can use

ct ln source_file file_link 

     (checkout current folder like above)

9. Now you may have completed the task of coding, testing, inspection, and prepare to release it. You need to check your developed version is complied with below rules:

Must make branch from the baseline version. 

Must have up merged your branch if the baseline version is not the LATEST version. 

All the files and directories have no checkou.

10. How to label the version

     Make the label type:

ct mklbtype BLUETOOTH_00.07.00 

     Make label on a version:

ct mklabel BLUETOOTH_00.07.00 hello.c@@/main/branchto/2 

     Move a label from the old version to a new version:

ct mklabel -replace BLUETOOTH_00.07.00 hello.c@@/main/branchto/3 

     Remove label on a version:

ct rmlabel BLUETOOTH_00.07.00 hello.c@@/main/branchto/3 

     Remove the label type

ct rmtype lbtype:BLUETOOTH_00.07.00 

11. How to search the reuqired version

     Find all files with the version(.../ISGcq00373766/LATEST) and with no label SAMBA_AP_DSL_BLUETOOTH_00.00.07:

ct find /vob/directory -version 'version(.../ISGcq00373766/LATEST)  && !version(SAMBA_AP_DSL_BLUETOOTH_00.00.07)' -print 

     Find all files with the version SAMBA_AP_DSL_BLUETOOTH_00.00.07, and then search STRING in all found files:

ct find .-version 'version(SAMBA_AP_DSL_BLUETOOTH_00.00.07)' -exec 'grep STRING $CLEARCASE_PN' 

 

  

错误地删除 clearcase view 后,不能再创建同名 view 的问题的解决

这是由于数据库中仍然保存了对相关 view 的引用。可使用 clearcase 的小工具 cleartool.exe 来彻底删除旧的 view.

1、cleartool lsview -long viewName

----记录得到的uuid
----形如:0a05ad0d.41024ac6.9a80.63:d8:3a:b4:14:c6
2、cleartool rmtag -view   viewName

3、cleartool rmview -force -all -uuid uuid的值

4、cleartool unregist -view -uuid uuid的值

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics