2

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 ?

brij
  • 217
  • 7
  • 19

1 Answers1

2

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • as you mentioned , I used md command to create the folders and then copied my file there. Now when I am using mkelem /MyVOB/folder1/folder2/folder3/MyFile.txt , its throwing ERROR --- **Not a vob object: ../MyVOB/folder1/folder2/folder3/** I have to do it using script not through UI – brij Jul 22 '14 at 11:05
  • @br001 why are you using `cleartool mkelem`, and not `cleartool mkelem -mkpath folder1\folder2\folder3 folder1\folder2\folder3\MyFile.java`, from the `m:\MyView\MyVob` folder, as I have explained in the answer? Why are you not using the `-mkpath` option? – VonC Jul 22 '14 at 11:11
  • @br001 I have edited the answer to clearly show what is the *unique* `mkelem` command that would add your file to source control, along all its parent directories. – VonC Jul 22 '14 at 11:13
  • i tried the commands that you mentioned, now I am getting this(I think it's expecting that directories already exists) - cleartool: Error: Unable to determine view for "demofolder1\demofolder2\demofolder3": No such file or directory. cleartool: Error: Unable to determine view for "demofolder1\demofolder2\demofolder3\MyDemoTest33.java": No such file or directory. – brij Jul 23 '14 at 11:44
  • I mentioned "However, the command must be ran within a versioned parent directory. ": make sure you are running the command from a versioned folder in which you have `demofolder1\demofolder2\demofolder3` – VonC Jul 23 '14 at 11:45
  • if I got you correct then you mean that my current working direcotry should be - The Directory in which these folders (demofolder1\demofolder2\demofolder3) needs to be created and that(parent) should already exist in clearcase? – brij Jul 23 '14 at 11:50
  • My Working Dir is ..MyVOB/Demo where demo already exist and checkedin clearcase. Now I am making demofolder1\demofolder2\demofolder3 inside Demo then it's giving me the error I posted earlier. I am not able to findout the mistake i am doing – brij Jul 23 '14 at 11:56
  • cleartool mkelem -nc -mkpath demofolder1\demofolder2\demofolder3 demofolder1\demofolder2\demofolder3\MyTestFile.java – brij Jul 23 '14 at 11:59
  • @br001 are those folders already there? Can you try first creating (`mkdir -p`) those folders and that file, then try the `mkelem` command? – VonC Jul 23 '14 at 12:18