How can I use ClearCase to "add to source control ..." recursively?
Asked Answered
P

10

47

I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an "Add to source control ..." for individual files/directories. Do you know how to recursively add the whole tree?

(I'm on a Windows system, but have Cygwin installed.)

Puzzlement answered 26/9, 2008 at 8:35 Comment(0)
S
64

I would rather go with the clearfsimport script, better equipped to import multiple times the same set of files, and automatically:

  • add new files,
  • make new version of existing files previously imported (but modified in the source set of files re-imported)
  • remove files already imported but no longer present in the source set of files.
  • make a clear log of all operations made during the import process.

So if your 'zip-file delivery needs to be updated on a regularly basis, clearfsimport is the way to go, but with the following options:

clearfsimport -preview -rec -nset c:\sourceDir\* m:\MyView\MyVob\MyDestinationDirectory

Note the :

  • -preview option: it will allow to check what would happen without actually doing anything.
  • '*' used only in Windows environment, in order to import the content of a directory
  • -nset option.

From CMWiki, about that 'nset' option:

By default, clearfsimport is meant to be used by the vob owner or a privileged user, but users often overlook the -nsetevent option, with which it may be used by any user.
This option drives clearfsimport not to set the time stamps of elements to this of the source file object outside the vob (which requires privileged access).
There is a minor non-obvious side-effect with this: once a version will have been created with a current time stamp, even the vob owner will not be able to import on top of it a version with an older (as it would be) time stamp, without this -nsetevent option. I.e. once you use this option, normal or privileged user, you are more or less bound to use it in the continuation.

Schedule answered 27/9, 2008 at 19:41 Comment(6)
Indeed, that would be the normal use case. One disadvantage of this approach is that you can't extract into the target directory. But I guess I could work with a fixed "import" directory.Puzzlement
That would be the way to do such an import, (i.e. from a separate 'source' directory), because of the preview capability (which can allow you to detect some files from your zip that you may actually not want to import!)Schedule
I had the problem that it renamed my original folder (which was already view-private) by appending '.keep' so then all of the operations failed because the source folder name had changed.Snowfield
@Snowfield - I ran into this same problem. Here is what I found out and what worked for me: clearfsimport does not allow for the source and target directories to be the same. If they are the same, it will create a .keep directory. You can then re-run the clearfsimport script using the .keep directory as the source (then you can remove the .keep directory when it is finished).Wharve
@VonC- My Clearcase server is too slow. I cant add all files one shot, so for taht I manually selected Folders and Search All files and Add to Source Control. Like that I have Attahced 47 folders, If I perform the command there will be any issue after I added manually..?Ridenhour
No issue, except I would recommend not selecting all 47 folders for your add to source control, but adding them gradually (4-5 folders at a time)Schedule
P
24

Here is one other way I found by using the Windows Explorer:

  1. Select Search... from the context menu on the target directory.
  2. Search for *.
  3. Select all (Ctrl-A) files/directories in the result list.
  4. Select ClearCase > Add to source control... from the context menu on an item in the result list.

There you go ...

Puzzlement answered 29/9, 2008 at 8:15 Comment(6)
This worked for me, but I did get some popup errors saying that the item was already in source control, presumably due to the order in which it does things? I did have the checkout after adding option selected. Seems to all be ok though, just clicking ok on the error popupsLogical
as a note this doesn't work on x64: www-01.ibm.com/support/docview.wss?uid=swg21251833Marine
@Markus, I do not see Search for * option ClearCase Remote Client 7.1.2, Is this version specific ?Projectionist
@hawkeye when we search using '*; it displays all the files recursively from sub folders also, so it does help to add to clearcase recursively.Blackfish
I think it does work but if it comes across a file that is already in clearcase you can easily cancel the entire process accidentally. Its very tedious and error prone , but then everything Clearcase is...Mandrake
I tried this on a very large (around 106 MB of data ) and explorer went into a crash!Granger
E
7

Since I did not have access to clearfsimport , I added the files/directories in a two step process:

1.) find . ! -path . -type d | xargs cleartool mkelem -mkpath -nc

This will create nodes for all new directories recursively

2.) find ./ -type f | xargs cleartool mkelem -nc

This will create nodes for all new files recursively

Emaciation answered 11/4, 2016 at 13:29 Comment(3)
This works for me. Around 1944 files added to source controlConsanguinity
Worked nicely for me as well (on cygwin). It is actually sufficient to just use 2) with -mkpath -- the directories are added on the fly. (Perhaps it is less efficient -- I'm afraid directories are checked out for every single file in it).Epigraphy
Xargs is not a default command for Windows. You should make it clear for readers.Spaulding
C
6

ClearTeam Explorer, version 8 (maybe earlier as well), has recursive add of subdirectories/files when you select "Add to Source Control". When the "Add to Source Control" dialog box appears, check the "Include descendant artifacts of the selected directories" checkbox and uncheck the "Checkout descendant files only, do not checkout descendant directories" checkbox.

Consort answered 25/6, 2013 at 18:51 Comment(2)
The answer that was accepted for this question was four years ago was fairly thorough. If you are looking for unanswered questions to look through, you can do so here: stackoverflow.com/unansweredLerma
@Lerma except he provided new information, so it was valuable to add his answer hereEnplane
A
4

You have to use the commandline. The Context menu in Explorer doesnt do this recursively!

clearfsimport –recurse /usr/src/projectx /vobs/projectx/src
Alec answered 26/9, 2008 at 8:37 Comment(0)
A
3

Heres a script to do it And tips to integrate the script from Explorer

http://www.ibm.com/developerworks/rational/library/4687.html

Alec answered 26/9, 2008 at 9:8 Comment(0)
D
3

Had a similar requirement to add a directory recursively to ClearCase. Since I did not have access to clearfsimport tool nor do I have ClearCase integrated with Windows Explorer, found an easy solution within ClearCase GUI.

1) Add the root directory using "Add to Source Control" menu option. 2) Click on this directory and then use "ClearCase Search" to search for all Private Files in this directory. 3) Select all from the Search Results and "Add to Source Control"

There you go ! The entire directory is recursively added from within ClearCase GUI

Dramamine answered 15/12, 2011 at 9:35 Comment(0)
H
1

you can get a fix at

http://www-01.ibm.com/support/docview.wss?ratlid=cctocbody&rs=984&uid=swg21117629

Hyperbolism answered 3/11, 2010 at 21:45 Comment(1)
Interesting technote, for CC7.0 and lower. +1Schedule
M
0

You can also add this command to your context menu with a small script...

Ten best Triggers

edit: oh, sorry. didn't saw that this was already suggested...

Maritamaritain answered 9/12, 2008 at 13:45 Comment(0)
P
0

I agree, find+select+add-to-source-control from Windows explorer is not a good option if the number of files to be version controlled is huge. As already mentioned above, explorer.exe crashes if we try to add a large number of files.

clearfsimport is the best and the most hassle free utility for this task.

-GP

Paugh answered 26/4, 2010 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.