How to use perform a mkelem on view private files using the ClearCase Menu Editor - find

I'm working in a Windows dynamic view.
I am trying to create a tool shortcut using the ClearCase Menu Editor to automatically perform a 'mkelem' on all private files in my view.
I'm aware of 'cleartool lsprivate -other' to get a full path listing of all private files but I don't know how to feed that resulting list into the 'mkelem' command.
I'm also aware of the 'find' command and that at the end you can specific '-exec' to cause it to perform the additional action to be performed on the resulting list but once again I don't know what arguments to give to 'find' in order for it to only find view private files.
Can anyone help me with this?

Another approach I would consider/test is one I mentioned in "How can I use ClearCase to “add to source control …” recursively?", with clearfsimport.
I suspect clearfsimporting the view folder into the view itself should automatically add the private files, while keeping the existing files untouched. But, as commented, you would need to import in a new dynamic view (with same config spec) for that to work.
The problem with cleartool find is that it find versioned elements.
It can use %CLEARCASE_PN% or %CLEARCASE_XPN% as argument in its exec clause: that reference the pathname or extended pathname of already versioned element.

Well, it's complicated, because you would need to check out the parent directories before creating the elements.
Have you tried a command similar to this:
for /f "delims==" %x ('cleartool lsprivate -other') do #cleartool co -nc "%~px" & cleartool mkelem -mkpath -ci -c "autoadd" "%x" & cleartool ci -nc "%~px"
-mkpath makes any missing parts of the path to the elements at the same time the element is created. That should -- with appropriate massaging to make it work in a "cmd /c" or batch job do the basics... Of course, this also goves you 1 new version of the parent directory per new element.
If you're not averse to Perl, you can expand upon this by taking that list, making any needed directories, and them making the elements.

Related

Is there a way to skip given files when performing a cleartool findmerge?

In our development environment, we have certain files that are autogenerated by some parsing tools, and they should never be merged from one branch to another. We do have them under source control, however, so that only one user needs to run the generation tool for any given branch; all other users will get the generated files automatically.
Is there a way to tell "findmerge" to skip these files when it traverses the VOB? If findmerge cannot resolve the differences in a file, it loads the default diff tool so the user can resolve the differences manually. For these autogenerated files, this is a waste of time; the user just has to cancel it and then run the autogeneration tool when the findmerge is complete.
If it matters, we use dynamic views.
You might consider the same approach as with binary files
Your project manager can overcome this problem by creating a special element type for the binary file type and specifying one of the following mergetypes:
never: A merge or findmerge operation ignores versions whose element type has never as a mergetype.
So, as in this page, something like:
cleartool mkeltype -supertype file -mergetype never -nc FILE_NEVER_MERGE
And then, in the folder with your generated files (here for instance for XML files):
ct find path/to/generated -type f -ele "{eltype(xml)}" -exec "cleartool chtype -force FILE_NEVER_MERGE %CLEARCASE

Label ClearCase Content As Seen On A Given Date (without changing the config specs)

I need to label the contents of a view as seen at specific dates, and the only way I know of doing it is by using the -time version selector in the config specs. I set the time to the date I want, and then I apply the label on the view. Simple.
However, I was hoping if there is a way to do it pro-grammatically without changing the config specs. I was hoping that I could use the cleartool find in combination with -exec and mklabel. However, if I do this:
cleartool find . -cview -version "! created_since(some-date)"
It only pulls what was created before that date on the view, not necessarily what should be seen in the view if we were using the -time selector.
And if I use cleartool find with a -branch selector
cleartool find . -cview -version "! created_since(some-branch)"
it only selects that which was created before that date, on that branch only. It will not show what is also seen in the view on other branches via the config specs rules.
So, am I using cleartool find wrong? Or is it just impossible?
Is there a way, from the command line, to direct cleartool find to find exactly and precisely the elements that
would be seen by the active config rules
in a given directory
regardless of the branch or branches involved,
AS IF there was a -time directive in them?
Thanks.
To my knowledge, the query language isn't rich enough to include what the config spec time rule does.
A time-based selection rule is the best option.
What I generally do, in order to use the -time programmatically (since the find wouldn't work) is to:
use a dedicated dynamic view (quicker to update than a snapshot view)
write in a file the config spec I need
cleartool setcs -tag myView myFile # update the config spec of the dynamic view
(See setcs man page)
use the result of the updated content of the dynamic view.

What's the best way to perform a differential between a list of directories?

I am interested in looking at a list of directories and comparing the previous list with a current list of directories and setting up a script to do so. Maybe in perl or as a shell script.
Should I use something like diff? Programatically, what would be an ideal way to do this? For example let say I output the diff to an output file, if there is no diff then exit, if there is results, I want to see it.
Let's for example I have the following directories today:
/foo/bar/staging/abc
/foo/bar/staging/def
/foo/bar/staging/a1b2c3
Next day would look like this where a directory is either added, or renamed:
/foo/bar/staging/abc
/foo/bar/staging/def
/foo/bar/staging/ghi
/foo/bar/staging/a1b2c4
There might be better ways, but the way I typically do something like this is to run a find command in each directory root, and pipe the output to separate files. You can then diff the files using the diff tool of your choice. If you want to filter out certain directories or files, you can throw in some grep or grep -v commands in the pipeline, or you can experiment with options on the find command.
The other main option is to find a diff tool that offers directory/folder comparisons. Most of the goods ones support this, but I like the command line method, because you get more control over what you're diffing.
cd /my/directory/one
find . -print | sort > /temp/one.txt
cd /my/directory/two
find . -print | sort > /temp/two.txt
diff /temp/one.txt /temp/two.txt
also check the inotifywait command. it allows you to monitor files in RT.
You might also consider the find command using the -newer switch.
The usage is:
find . -newer timefile.txt -print
The -newer switch makes find return a list of files that are created or updated after the specified file's modification time. In the example above, any file created or updated after timefile.txt would be returned. You'd have to create a timefile.txt file, most likely once per day. Some versions of find have variations of newer that compare against other time stamps for a file (last modified, last accessed, last created, etc.)
This technique would not report a file that was deleted, however. A daily diff of the file listings could report that.

a command line or a script who is able to display each version of each element archived in a vob since the beginning?

For example,
I am in a vob called: avob
I add to source control a folder:
avob/afolder
I add to source control two files afile1 and afile2
avob/afolder/afile1
avob/afolder/afile2
I uncatalogued the file afile2
I add to source control afile3
avob/afolder/afile3
I would like (a command line or a script who is able to) display each version of each element archived since the beginning, here:
avob#version1
avob#version2
avob#version2/afile1#version1
avob#version2/afile2#version1
avob#version3
avob#version3/afile1#version1
avob#version4
avob#version4/afile1#version1
avob#version4/afile3#version1
The only command which could come close of what you are looking for would be
ct lshist vob:\yourVob
which would list all the events for all versions of all files (add to source control, rmname, merges, ...)
But that would involve a lot of parsing of a huge log file if your vob has a few years of history...
A script could scan the entire VOB for all its elements/history and generate a report.
If you wanted to script it, you'd start by collecting version information on the root dir of the vob:
cleartool lsvtree -all /vobs/myvob/
It would list all the versions of the root dir of the VOB, and then you could lsvtree every single version of that dir for every element in every version of the root dir, keeping track of them all and recursing into directory versions, etc., until you have all the elements and versions cataloged. It could use a lot of memory.
It will take a long time, as Von points out.

How to browse each version of each element archived?

I am looking for a command line either for an algorithm (script) which allows to browse all the versions of each of the elements archived in a VOB UCM or Base Clearcase.
The command find allows to browse each of the elements accessible from an existing view. But It does not thus allow to browse elements uncatalogued.
It is more complicated than the browse of a tree because it is a question of browsing at once the tree of archived elements (files and directory). As well as the tree of branches and versions of every element.
ct find -all -nvis -print|gawk "{print \"cleartool lsvtree \"$0}"|cmd
(windows syntax, note: some double quotes may be needed around the $0 is the file has space in it)
That should list all versions (with the -nvis option to list elements not visible from the current view).
Since a find -all list only one version per element, you have to pass it to a command listing all versions.