7

I have a directory structure like so:

root_dir
  dir1
  dir2
    file1.txt
    file2.txt
    sub_dir
      file3.txt
      file4.txt

What is the best way to delete dir2 and all it's sub-elements using rmname? Can I simply do 'cleartool rmname dir2' and have it recursively delete all it's contents?

Ken Hirakawa
  • 7,831
  • 10
  • 38
  • 49

1 Answers1

6

You only need to:

cleartool checkout -nc root_dir
cleartool rmname dir2
cleartool checkin root_dir

That remove the reference to dir2 in the new version of root_dir, making dir2 and all its content invisible (not reachable).
And you can easily restore dir2 (and all its content) by merging the previous version of root_dir (which was still referencing dir2) with the current version (the one where you rmname'd dir2) in order to recreate a new version where you get back dir2.

Note: when using rmname, you might have an error message mentioning that the element is in checked out, even though it is not checked out in the branch where you are doing the rmname.
using rmname -force is the solution to still perform the rmname: see this technote.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 2
    That doesn't remove the entire structure from the underlying clearcase database - which is a good and bad thing. ie you can check out the version prior to the rmname and get it all back. Not quite the same as a recursive delete - but probably what you wanted. – hawkeye Jul 28 '11 at 04:37
  • @hawkeye: "but probably what you want": in my experience, this is usually enough. No need to go deeper than that. – VonC Jul 28 '11 at 05:31
  • This solution doesn't remove all elements from the VOB, which is a burden on VOB capacity. I suggest you'd delete all the elements by yourself – TripleS Mar 07 '17 at 06:02
  • @TripleS do you mean `rmelem` instead of `rmname`, to completely remove the element and all its history? – VonC Mar 07 '17 at 06:03
  • No , I suggest to delete all elements instead of merely delete the father directory, use rmelem for each element – TripleS Mar 07 '17 at 06:10
  • @TripleS so you *do* mean `rmelem`: that can be quite dangerous: http://stackoverflow.com/a/4941527/6309 – VonC Mar 07 '17 at 07:19
  • I mean rmname, remove symbolic links – TripleS Mar 08 '17 at 11:13
  • OK. You said "use rmelem for each element", hence my previous comment. – VonC Mar 08 '17 at 11:15