Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
701 views
in Technique[技术] by (71.8m points)

Command to delete branches of Clearcase element with "0" versions

What is the command in Clearcase to delete the branches of an element in which it is not modified (Element's version in that branch is "0") ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can simply remove the version 0 of that element (that I detail here).

That will remove the associated branch.

cleartool rmver file@@/main/aBranch/0

You would need to "cleartool find" all elements with a version 0 (and no version 1), and rmver those version 0.
For a given branch, this would return all the versions to delete:

cleartool find -type f -version "version(.../blah/LATEST)&&version(.../blah/0)" -print

You can combine that with an exec directive:

# on Windows:
cleartool find ... -exec "cleartool rmver --force "%CLEARCASE_XPN%"
# on Unix:
cleartool find ... -exec 'cleartool rmver --force "$CLEARCASE_XPN"'

Be careful with rmver, this is a destructive operation, so do test that carefully before executing the full find -exec rmver command!


Another approach is mentioned in "Purging Zero-Version-Only Elements in ClearCase" article, by George F. Frazier:

you need to purge your view of those troublesome entities.
Run the following command to find all zero-version elements:

cleartool find -avobs -branch'{
    brtype(mybranch)&&!
    (version(.../mybranch/1))}' 
     -print > c:files.txt 

This will find all elements with no version 1 on mybranch (if you read closely you'll notice it doesn't do the right thing if you have removed the 1 version of an element that already has versions greater than or equal to 2 — this is a rare situation though).
Once finished, it's simply a matter of using rmbranch to nuke the elements (make sure you know what you're doing here!).
There are many ways to do that; since I run the MKS toolkit, I execute the following from a command window:

cleartool rmbranch -f 'cat c:files.txt' 

Tamir suggests a trigger to automatically remove version 0, as listed in the IBM Rational ClearCase: The ten best triggers, under the section Empty Branch.

cleartool mktrtype -c "Automatically remove empty branch" -element -all -postop uncheckout -execwin "ccperl \mw-ddieboltriggersest_empty_branch.bat" REMOVE_EMPTY_BRANCH

That is good for future cases where an undo checkout leaves a version 0.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...