Search code examples
clearcase

how to commit an arbitrary directory tree


I am looking for a process that would allow me to commit an arbitrary directory tree to ClearCase. The tree might contain regular files, directories and symlinks (to either files or directories).

We are working with dynamic views exclusively, and I have been given by older team members the following process to follow in such cases (assume that I need to commit to ClearCase the entire structure of directory foo):

  1. change to the directory where foo appears and check it out:

    ct checkout .

  2. register all files in foo as ClearCase objects:

    ct mkelem -mkpath $(find foo -type f)

  3. check-in the newly minted ClearCase objects:

    ct ci $(ct lscheckcout -me -cvi -recu -sho foo)

  4. commit

    ct ci .

The above seems to work for regular files, but not when symlinks are present.

E.g. if I do the following:

mkdir foo && cd foo
touch a && ln -s a a2 && cd ..

… and then follow the above process (changing the find incantation in step 2 to use find -type f -o -type l), steps #1 and #2 execute successfully:

$ ct co .
Checkout comments for ".":
.
Checked out "." from version "/main/dbdev_br/2".
$ ct mkelem -mkpath $(find foo -type f  -o -type l)
Creating parent directory element "foo".
Created directory element "foo".
Checking out parent directory "foo".
Created branch "dbdev_br" from "foo" version "/main/0".
Creation comments for "foo/a":
.
Created element "foo/a" (type "text_file").
Created branch "dbdev_br" from "foo/a" version "/main/0".
Checked out "foo/a" from version "/main/dbdev_br/0".
Creation comments for "foo/a2":
.
Created element "foo/a2" (type "text_file").
Created branch "dbdev_br" from "foo/a2" version "/main/0".
Checked out "foo/a2" from version "/main/dbdev_br/0".

… but when I try to execute step #3, I get:

Checked in "foo/a" version "/main/dbdev_br/1".
Private version of "foo/a2" saved in "foo/a2.keep".
cleartool: Warning: Operation "view_change_oid" failed ("foo/a2"): Read-only file system.
cleartool: Warning: VOB updated, but view update of uncheckout of "foo/a2" failed: error detected by ClearCase subsystem.
Checked in "foo/a2" version "/main/dbdev_br/1".

What's the process I should use to commit an arbitrary directory tree (with regular files, directories and symlinks) in ClearCase? I am looking for something that I can script away so that I don't have to do this manually, file by file, directory by directory, etc. A script would also allow me to apply the same commit message throughout.

In git it would be as simple as:

git add foo
git commit -m 'foo added'

Solution

  • What's the process I should use to commit an arbitrary directory tree (with regular files, directories and symlinks) in ClearCase?

    Try first clearfsimport that I detail in "How can I quickly checkin a large number of files in clearcase".
    That is the official command for adding a large number of files from any folder (that folder can be in another view or a simple OS regular folder) into a ClearCase view (snapshot or dynamic, UCM or not)

    No more checkout of the destination folder, no more mkelem: clearfsimport takes care of that.

    You have the choice of using the -follow option:

    Processes the object to which a UNIX or Linux symbolic link points, instead of importing the link itself into the VOB.