cleartool rmelem "has checkout" - clearcase

I have a new branch in which I would like to remove some files. I was able to remove some files with this commands:
cleartool co -nc .
cleartool rmname <filename>
cleartool ci -nc .
But for some other files I get this error:
$ ct rmname file
cleartool: Error: Element "file" has checkouts.
In my branch, in my view, these files are not checked out. However I can find some checkout with ct lsco file in other branches.
Why do I get an error. Removing a file from my branch shouldn't affect the other branches, right?
Can I force the command with -f ?

You could try the -force option for the cleartool rmname command, to get past the fact there are other versions checked out. But that -force option might not be available (depending on the cleartool version)
I have seen that option in "Cleartool removing a checkedout file from a folder with rmname" for rmname.
If rmname -f works, then it is the way to proceed.
That error message is more about warning the users that, while the file won't be visible anymore, it is still being modified elsewhere.

Related

How to avoid repeat check outs on already checked out files or directories?

I have some files and directories out of which few are already checked out and few are not.
To check out those uncheck out files I am running recursive checkout:
ct co -nc ./*
Which gives below message for already checkout files or directory:
cleartool: Error: Element "abc/xyz" is already checked out to view "pqr".
Is there any way I can avoid performing ct co on already checked out files or directories?
First, you can check if you have the same issue when applying my old method "How do I perform a recursive checkout using ClearCase?".
cleartool find somedir -type f -exec "cleartool checkout -c \"Reason for massive checkout\" \"%CLEARCASE_PN%\""
(which is mirrored by the IBM technote swg21122520)
The other option is to:
first find checked out files (see "How to find all checkedout files with ClearCase cleartool?", without the -cview option, in order to list checked out files in all views)
redirect that find into a file
Then you can replace the -exec directive above in order, for each \"%CLEARCASE_PN%\" found, to:
check if it is listed in the checked out files found in the previous point
if it is not, proceed with the checkout.
In short: a two-step process.

ClearCase: How to Uncheckout Files in Shapshot View Deleted From File System

Four months ago a colleague had a shapshot view that he deleted from the file system while there were still directory checkouts on a certain branch, say branch 'A'. Now some of directories are obsolete and need to be rmname'd from other views, but this cannot happen apparently while they are still checked out on branch A.
What is the most direct way to unco these directories on branch a?
You can unregister completely this view (even if the actual view is gone from the filesystem).
See "ClearCase: Is it possible to cancel checkouts not made from your own view?":
cleartool rmview -force -uuid (uuid_of_the_view) -vob \aVob
That will trigger, as a side-effect, the removal of the checkout status of any file checked out by this view (referenced by its uuid) in this vob (the -vob option).
See more at "How to delete clearcase views created by other users?":
cleartool lsview -l theViewToRemove # get its uuid
cleartool rmtag -view theViewToRemove
cleartool unregister -view -uuid uuid_of_viewToRemove
You even can use the nuke_view.pl script.
Now some of directories are obsolete and need to be rmname'd from other views, but this cannot happen apparently while they are still checked out on branch A.
As I mention in "How do delete a file in ClearCase?", even if you don't unregister the view, you can still remove a file from a branch, even if it is checked out in another branch.
You simply need to do it from the command-line:
cleartool rmname -force /path/to/file
Eric Schnipke proposes in the comments:
(1) cleartool lsview -l theViewToRemove to get the view's UUID and then
(2) cleartool rmview -force -uuid (uuid_of_the_view) -vob \aVob to remove the view and offending file version.

How to find clearcase symlinks?

Currently, I have to wait for a symlink error when updating a clearcase view. I then take the name for the broken symlink and search for it specifically.
is there a way to find all broken symlinks, without necessarily knowing the name?
how to find one at a time:
cleartool> cd C:\cc_view\view_name\source_app
cleartool> find -all -type l -name "missing.link.name" -nxname -print
You shouldn't need a -all in your find query.
Broken symlink in a snapshot view update are element which are visible:
cleartool find . -type l -name "missing.link.name" -nxname -print
You can execute that command in a DOS session ("cleartool find", instead of a cleartool one "cleartool> find"): that allows you to redirect the result in a text file and parse the result.
The IBM article "How to find broken (orphaned) Symlinks" can also help.
Cause
User renamed the target, so the symbolic link is pointing to a non existing target.
After the rename of the versioned target file (a.doc -> a.docx, done by ClearCase Explorer) I get the update error, that the symlink a.doc does not exist.
Unable to resolve symlink "filename.doc". The symlink target will not be loaded.
Where can I find the link itself (in which folder is it located?)?
How can I solve the rename (?) of the symlink?
Answer
To find and remove the symlink:
Use a dynamic view (snapshot views cannot load the missing links).
Run M:\viewtag\vobtag>cleartool find . -kind slink -print
Refer to the following technote for information about how to remove the symlinks as found in the output of the above command: "Unable to resolve VOB symlink":
A cleartool ls from the command prompt will show:
virt.46e5e94ff9024144ab0fe9ed432ce6e6 --> ../virt
virt.5043bcc7c8f44439938d634bd5ba9ac2 --> ..virt [not loaded]
The above symbolic link is to a resource outside of ClearCase, which renders the hyperlink invalid for use in UCM.
Resolving the problem
Remove the broken (dangling) link from the VOB to clear the error, using the cleartool rmname command.
Example:
cleartool rmname virt.46e5e94ff9024144ab0fe9ed432ce6e6
Using cleartool rmname allows you to preserve the symbolic link, but remove references
to it from future directory versions.
Symbolic links can be permanently removed using cleartool rmelem, refer to technote 1148781 for more details.

Cleartool: How to apply label to files which are in my current view only?

I could not find the proper command to apply a label to files which are in my current view. I have tried the following command:
cleartool mklabel -r TEST_LABEL /vob/test/a
However, the problem is that this command will apply the "Test_Label" label to every files in the "vob/test/a" directories regardless of whether the files are in my current view.
Is there any command to apply label only to the files listed in my current view?
cleartool mklabel -r(ecurse) LABEL_NAME <directory name>
This command will apply LABEL_NAME to all files in folder and below of your view, you can just go to that directory,then type following command to create and apply label
> cd /vob/test/a
> cleartool mklbtype –nc TEST_LABEL
> cleartool mklabel -r TEST_LABEL .
The mklabel documentation state states, as to what version is labeled:
Processes the entire subtree of each pname that is a directory element (including pname itself). VOB symbolic links are not traversed during the recursive descent into the subtree.
One example mentions:
Attach that label to the version of the current directory selected by your view, and to the currently selected version of each element in and below the current directory.
Now, if you want to be really sure of the versions actually labelled, one solution is to use a find command, combined with your mklabel:
cleartool find . -cview -exec "cleartool mklabel TEST_LABEL \"%CLEARCASE_XPN%\""
If you had already that label applied to incorrect version and want to move it:
cleartool find . -cview -exec "cleartool mklabel -replace TEST_LABEL \"%CLEARCASE_XPN%\""
That way, you can first list the versions involved:
cleartool find . -cview -print
And then, if you agree with the output, apply the mklabel through the -exec directive.
The OP user1096966 reports making it work with a cleartool ls, to be sure to select only element visible in the current view:
cleartool ls -r -vis
The is no '-exec' directive, so a pipe might be involved, as in (not tested, but you get the idea):
cleartool ls -r -vis -s -nxn | xargs cleartool mklabel -replace TEST_LABEL
The doco is really clear about what is being labelled, in fact the first example shown in doco states that exactly...current view objects are labelled by default & currently selected versions (i.e. if in your view then label it, else not.)
....extract below from doco below (note: context and command and that label-type-selector pname is the last parameter...left blank below because resident in working dir)...
Example:
•Create a label type named REL6. Attach that label to the version of the current directory selected by your view, and to the currently selected version of each element in and below the current directory.
cmd-context> mklbtype –nc REL6
Regards
Jim2

How can I discover who's checked out a file in ClearCase?

I use ClearCase. How can I find out who's checked out a given file?
That kind of request is often prompted when you try to rmname (DEL) a file through the GUI.
If the file is checked-out in any other branch or any other view... the GUI will refuse to rmname the file!
To quickly see where the file is checked-out, try a
ct lsvtree myFile
and look (or grep) for "CHECKEDOUT" string.
You will se one or several line like:
path\to\myFile##\main\aBranch\CHECKEDOUT view "aViewTag"
But remember: you can also force a rmname through the CLI (Command-Line Interface) cleartool.
Assuming you are in the correct path of the file:
cleartool co -nc .
cleartool rmname -force myFile
cleartool ci -nc .
the -force option (not available through GUI) will allow you to rmname your file even if it is already checked-out in another view/branch.
Just do a cleartool lsco on the file element:
%cleartool lsco <element_name>

Resources