brij
brij

Reputation: 217

Create Directory Tree and add file in clearcase

I want to add a file to clearcase source control. For that I am using the command as

clearfsimport -preview -rec -nset D:\TestCreated\folder1\folder2\folder3\MyFile.java m:\MyView\MyVob\

Now, what I want is - it should create the folders inside MyVob (if already NOT exist) - folder1, folder2, folder3 and then copy the file MyFile.java into folder3.

I don't wan't everything to be copied to clearcase but just a particular file MyFile.java as folder1 , folder2 can have other files too. Do I need to do mkdir everytime for making each folder separately and then mkelem file or is there a simpler solution using any simple command or script ?

Upvotes: 2

Views: 3654

Answers (1)

VonC
VonC

Reputation: 1324537

If you need to do this in a script, then your script will have to recursively mkelem -mkp for the file.
(as explained in "To add elements (files and directories) to source control from the command line" and cleartool mkelem)

-mkp/ath

This option enables elements to be created within its view-private parent directories.
However, the command must be ran within a versioned parent directory
.

For example, if you have a view-private file foo.c, it's view-private parent directory dir1, and dir1's versioned parent directory dir2, you must run mkelem -mkpath in dir2:

cleartool mkelem -nc -mkpath dir1 dir1\foo.c

By default, the element's parent directories (including those that are already elements) are checked out, as well as the element itself.

See a more complete example in this ctadd script.

In your case:

cd m:\MyView\MyVob
cleartool mkelem -mkpath folder1\folder2\folder3 folder1\folder2\folder3\MyFile.java

An easier (non-script) solution is to:

  • copy folder1\folder2\folder3\MyFile.java in m:\MyView\MyVob\
    (if the folders don't exists yet, the windows command md will create the intermediate folders in one step)

  • open the ClearCase Explorer and add that file to source control: it will add any missing parent folder to source control as well (or will update their content if they already exist).

See "To add files and directories to an existing directory tree (Windows)":

Right-click one of the selected objects and click Add to Source Control.

Select items that are the farthest from the root of the directory tree: the Add to Source Control command for any given file or directory also adds any parent directories (up to the VOB root directory) that are not already elements.

Upvotes: 2

Related Questions