Recursively Adding to Multiple Files / Directory in Clearcase

Since last few months, I am working on Clearcase (UCM one) .  My project was in SVP phase.  As usual, we were running out of time.  Deadline followed by another deadline. Commitment always overrun and are being suger coated to client.  As per working model, task were assigned to offshore colleague. offshore team mate made mistakes while check in files into wrong directory.  Things went very bad and went to escalation.  It was time to rely on computers and not on human beings.  I decided to have a neat way of recursively adding a complete folder or directory to Clearcase’s source control. There is no rocket science here. It needs little bit of Google and got few very good tips.

It uses the clearfsimport command, which is intended to be used by the vob owner or a privileged user [ if you come here, you dont need to worry about vob owner 🙂 ] to import a copy of a directory tree.

By default, clearfsimport sets the time stamp of the new elements to that of the source objects (which is why the command requires privileged access), but if you use the -nsetevent flag, Clearcase won’t do anything special with the time stamps, and consequently, you can run it as a normal user.

I am sure,  above will not make more sense and you are eager to see how things are done.

For this example, I’m going to import the folder[From]  /tmp/Final-Config and all of its contents into the vob [To]  /vobs/demo.

A: Set to View

B: Set an activity.
Step1:  Check out the folder/directory that you want to import the directory tree into (which in my case is /vobs/demo):

Command to type : ct co /vobs/demo
Step 2:. Create the Final-Config  folder in /vobs/demo:

Command to type : ct mkdir /vobs/demo/Final-Config
Step 3. Before we actually import all of the files, you can preview exactly what clearfsimport is going to import when you execute it. To do that, you need to use the -preview flag:

Command to type :  clearfsimport -preview -rec -nsetevent /tmp/Final-Config/*  /vobs/demo/Final-Config

-rec makes clearfsimport search the specified source path recursively

-nsetevent allows a normal user to run the command, as discussed earlier.

 

Step 4: If you’re sure that you want to import all of the listed files, simply remove the -preview flag, and execute the command:

Command to type :  clearfsimport -rec -nsetevent /tmp/Final-Config/* /vobs/demo/Final-Config

This can take quite a while depending on the speed of your connection to the Clearcase repository, but it will do it all automatically without any interrupts required.

 

Step 5: Check in the /vobs/demo/Final-Config  directory, if necessary, and the /vobs/demo directory.

Command to type :

ct ci /vobs/demo/Final-Config

cd ..

ct ci /vobs/demo

Hope above will help you.

Thanks