Can we uncheckout elements in hierarchy basis? - clearcase

I would like to uncheckout list of elements in hierarchical manner
Ie: Lt say folder1 & folder2, folder3 are framed in hierarchical basis:
folder3 is child,
folder2 is parent,
folder1 is grand parent
I would like to uncheckout child first then parent then garand parent:
how I can become to know which one is parent and which one is grand parent?
Leads are welcomed.

You would need to write a script which walks all elements of each folder, starting with the one having the most depth: "F3".
The script would then go one level up (possibly F2) and repeat the process for all elements, except subfolders.
And then one level up, until you get to F1.
In each folder, you can combine cleartool find -exec with the unco command in order to automate the ct unco step.
See "How do I perform a recursive checkout using ClearCase?" (except in your case, it is unco, with files first, folders second)
Reminder: unco means unco files first, and then only then: unco folders.

Related

How can I uncheckout a file in all of my temporary views in command line?

Background
I currently am testing a script that creates a temporary view and checks out four package files to be updated by a process. However, my script hasn't gotten to the point where it can reach the uncheckout step. This results in 30+ temporary views that all contain a checkedout version of the package files.
Attempted solution
I could go in to the graphical clearcase tree and manually ctrl-click all the temp views that are checked out, then click on the uncheckout button. However, this will get unweildy after a few hundred tests, so I want to know of a command line way to do this. All of my temporary views are formatted with "TMP_abc_QUA_###".
Question
How can I uncheckout a file across all temporary views from linux command line with bash?
As described in "How to remove checked-out references of a view from a VOB", you can simply describe a vob:
cleartool describe -long vob:\baseccvob
You will see which views are holding objects:
VOB holds objects from the following views:
MYHOST:C:\VIEW\TEST.vws [uuid a7fc590.42f34d53.ae68.b6:30:f5:30:c5:a4]
For each views which are part of your temporary views, you can do:
cd /aview/aVob
cleartool rmview -uuid fa7fc590.42f34d53.ae68.b6:30:f5:30:c5:a4
That will remove any checkout status for any file in aVob for that view.
Loop and repeat for other temp views.
I used in the past (Windows syntax)
cd M:\aview\avob
ct descr -l vob:\aVob|grep TMP_|gawk "{gsub(/]/,\"\",$3); print \"cleartool rmview -uuid \"$3}"|cmd
On Linux:
cd /views/aView/vobs/aVob
cleartool descr -l vob:/vobs/aVob|grep TMP_|gawk "{gsub(/]/,\"\",$3); print \"cleartool rmview -uuid \"$3}"|sh

Clearcase: how to copy/fork a file?

In Clearcase, I want to copy (fork, split) a file while preserving its history. Something like svn cp old.txt new.txt. How do I do it?
It isn't possible do fork a file in ClearCase.
If you refactor your code and split a file in two, one of them will appear as a new file and you will loose the information about who coded it. The annotate command will say the author of the lines are who splited it.
UCM or not, you cannot duplicate easily the full history of a file.
The best way to isolate an history is still to create a branch in order to make new versions to that file without impacting the same file in the original branch.
Thinking 'svn cp' should be available in ClearCase might come from the fact that, in SVN, branches are directories, and a tool like cc2svn will actually replicate ClearCase branches using 'svn cp'.
But since, with ClearCase, branches are first-class citizen, it is best to reason in term of branch than in term of copy/fork.
From the main page of cc2svn:
There is a difference in creating the branches in ClearCase and SVN:
SVN copies all files from parent branch to the target like: svn cp branches/main branches/dev_branch
ClearCase creates the actual branch for file upon checkout operation only.
Pretty simply done
Check out parent folder
Move element you wish to duplicate to appropriate location (not within the checked out parent folder)
Undo Checkout of parent folder
All the files get returned to the original folder with history and also the duplicate ones remain in the new location with the history too. Now each file can be checked out and changed individually

Script to prepare scenarios to test findmerge command

I'm testing a clearcase merge script and I'd like to be able to have another script that could produce these 2 test scenarios every time it runs:
Modify 3 files for a trivial merge (100% automatic, no diff needed)
Modify 3 files for a conflicting merge, user resolution required
What I'd like to know are the steps/clearcase commands needed to prepare these files. All must be done through command-line (using cleartool commands). I already have a dynamic view and some test files I can use. Probably I'll need to create a destination test branch too.
The merge is done using the ct findmerge command like this:
`cleartool findmerge filepath -fver version -merge -log NUL -c comment`
I need to validate the output in each of the cases, to include them in a report and also ensure that no user interaction is required.
You need:
to have two branches where you makes your parallel evolutions in your files
to use simply cleartool checkout -nc myFile ; echo new modif >> myFile ; cleartool checkin -nc myFile for adding evolution with a trivial merge in one branch (leave the same file untouched in the other branch)
to use the same process in both branches with a different echo each time in order to add a new line different in both version of myFile: that will result in non-trivial merge.
Don't forget that you can also have trivial/non-trivial merges on the directory level (when files are added/removed): a non-trivial one would be in case of an evil-twin.

How to find new undelivered files for a given UCM "stream"

We use UCM for development. We create streams under streams, like this
Question is how to find new files in a given stream.
In the example "feat1" would have new files relative to its parent lis1 (lis=local integration stream). The new files could be from "feat1" or its child streams like "developer1". How could I identify new files in lis1?
One option is to create dynamic views on a stream (say feat1) and its parent stream(lis1) and take diff and figure out files new in the child stream.
Another option is to use cleartool deliver -preview and get list of versions and then somehow (I do not know it yet) figure out the list of files.
The problem is the child stream is not necessarily rebased to its parent, and we enforce a "rebase to latest baseline before delivery" rule.
I hope there is a better and correct way :)
I don't think a cleartool deliver -preview (like its non-UCM equivalent cleartool findmerge -preview) would display the full list of modified/new files.
For new files, it would only display the directories that need merges (in order to reference or un-reference the files added/removed during that merge).
One way (without using an external diff tool) would be a cleartool find request in order to find any file:
with versions in a 'developer1' branch
without any versions in a 'lis' branch
Something like (not tested):
cleartool find . -type f -version "brtype(developper1) && !brtype(lis)" -print
In the OP Jayan's case:
cleartool find . -type f -element "brtype(developper1) && !brtype(lis)" -print
Will list only the needed elements (ie files, and not all the versions of those files)

Whats the easiest way to completely remove a directory element & all its sub-contents from VOB?

What I know is, using rmelem to remove the folder first, and this will cause all of its child elements to be moved to lost+found.
Then, go into lost+found, and repeatedly execute rmelem * until all of the elements are removed.
Is there a better way?
The technote about lost+found is quite clear:
if you rmelem a directory, all its content will indeed be moved to lost+found, where it will has to lost+found. The technote adds:
Note: If a directory element is deleted from lost+found with rmelem, its contents will be moved to lost+found in the same manner described in the first section above.
That is why I always try to rmelem files first, then directories, in order to avoid a trip (or several trips) in lost+found.
Except I very rarely rmelem anything, as the same technote warns:
Use rmelem carefully when deleting elements or symbolic links from the lost+found directory.
While the content of lost+found typically consists of unwanted elements and symbolic links, in some circumstances it can contain elements that are cataloged elsewhere in the VOB (that is, not orphaned) that are associated by symbolic or hard links.
For this reason, do not run rmelem recursively in lost+found without first verifying it contents.
If you need to save an element that is currently in lost+found, catalog it in a versioned directory using mv as explained in the previous section
Actually, with ClearCase UCM, it is almost impossible to rmelem any element with some history, because of all the hyperlink you would compromised (related to baselines mainly).

Resources