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") ?
2 Answers
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 usingrmbranch
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-ddiebolt\triggers\test_empty_branch.bat" REMOVE_EMPTY_BRANCH
That is good for future cases where an undo checkout leaves a version 0.
-
The command is applicable to a single file. But, say if I have a list of 100 files in a directory, then how to go about it ? – Bhaskar Aug 12 '13 at 09:48
-
@VonC, you may mention that there's also a trigger he can use to automatically remove those versions (he can apply it for the next times) – Tamir Gefen Aug 12 '13 at 09:59
-
@Bhaskar I have edited the answer to address your point (100 files to clean up). – VonC Aug 12 '13 at 10:35
-
1@TamirGefen good point. I have edited the answer to include a reference to that trigger. – VonC Aug 12 '13 at 10:35
-
Doesn't the find avobs command find any version which is NOT version 1? Thus if there is a version 2, it is listed. I just tried it out and that is what i found. – Andrew T Finnell Jun 14 '18 at 17:38
-
@AndrewTFinnell 5 years later... that is possible (I don't have access to ClearCase anymore). Did you manage to find a query which does exclude any branch with a version 1? – VonC Jun 14 '18 at 17:46
-
@VonC Are you trying to find any branch which ONLY has a Version 1? Or exclude any branch which happens to have a version >= 1? It's been a bit of time and I missed your question. Feel free to start a chat or ask a Question on here and link it to me. I'll be glad to answer here, in the question or chat. I just had to do this a month ago and moved from CC to Git. – Andrew T Finnell Jul 26 '18 at 12:11
-
@AndrewTFinnell No, the goal is to edit the answer above in order to address those different use case you mentioned in your comments. Feel free to add those in the answer. – VonC Jul 26 '18 at 12:14
-
@VonC No worries. I'm hoping you can clarify your question though. I asked an either or question so I know which way to answer it. Perhaps I was unclear my apologies for mixing two discussions. Do you wish to exclude elements which ONLY have a Version 1 on a branch, or exclude elements which have version >= 1? Which would mean you want to find version=0. – Andrew T Finnell Jul 26 '18 at 12:18
-
@AndrewTFinnell myquestion stemmed from your question ;) Your question was that my answer would find "any version which is NOT version 1", which means it would not be a good answer to the OP. The goal was to find any branch with *only* a version 0. In order to then delete them. – VonC Jul 26 '18 at 12:20
rmver won't work.
/home/ccadmin $ cleartool rmver -force ./VaREngine/Makefile@@/main/nz_mig/nz_relOne/0 cleartool: Error: Cannot delete version zero without deleting branch: "./VaREngine/Makefile".

- 309
- 1
- 5
- 13
-
2The try out the second option of my answer above: `cleartool rmbranch -f`. – VonC Oct 15 '13 at 18:12