How can I discover who's checked out a file in ClearCase? - 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>

Related

cleartool rmelem "has checkout"

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.

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.

Clearcase CASE INSENSITIVITY

I am trying to write a windows batch file to automate the checkout/check-in process for the ClearCasr tool but facing an issue with Case letters of the file name.
For example: if filename is "Hello_Working.txt" when I copied to my vob its becoming "hello_working.txt".
So when I do a checkout/check-in its prompting error as "Pathname not found".
I know MVFS "Clear Preserve" will solve the problem but if we change the setting other vobs which are running will affect, My admin suggested that your batch file script commands has to negotiate the cases of the file name. I am writing the command as below
Checkout:
ct co -nc H:\test1_view\test1_vob\Hello_working.txt
ct co -cfile "Comment"
Checkin:
ct ci -nc H:\test1_view\test1_vob\Hello_working.txt
ct ci -cfile "Comment"
Please let me know what needs to modify in the commands?
First, you don't have to co/ci -nc, and then co/ci -cfile "comment".
You can checkout with comment, and then ci -nc: a checkin without comment will use by default the comment given in the checkout step.
ct co -c "Comment" H:\test1_view\test1_vob\Hello_working.txt
ct ci -nc H:\test1_view\test1_vob\Hello_working.txt
Second, you can try checkin all the checked-out files, as in "Recursive checkin using Clearcase", which would make ClearCase find the right name (even when the filename is converted to lowercase in Windows dynamic view).
ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct
Even for one file, try the command ct lsco (cleartool lscheckout) in order to ask ClearCase for the right name.

How to remove label of a directory and all its contents in clear case?

I have applied a label to directory in clear case recursively. How can I remove all those labels?
The simplest approach would be in command line, using cleartool rmlabel
cleartool rmlabel -rec YOUR_LABEL yourDirectory
Note: this is for ClearCase V7.1+ only, not CC7.0.x or CCV6.x, and not for CCRC (ClearCase Remote Client)
With older ClearCase versions, you had to do (see technote swg21126736):
# Unix syntax
cleartool find yourDirectory -version "lbtype(YOUR_LABEL)" -exec 'cleartool rmlabel YOUR_LABEL"$CLEARCASE_XPN"'
# Windows syntax
cleartool find yourDirectory -version "lbtype(YOUR_LABEL)" -exec "cleartool rmlabel YOUR_LABEL\"%CLEARCASE_XPN%\""
Note: you could remove a label using a GUI, but as described in technote swg21146450, this is a file-by-file operation only!
(Not very practical if you have hundreds of elements -- files and directories -- to process...)

Recursive checkin using Clearcase

I want to check in a directory and all the sub-directories into the clear case.
Is there a specific command to achieve it?
Currently I am going into each directory and manually checking in each file.
I would recommend this question:
Now the problem is to checkin everything that has changed.
It is problematic since often not everything has changed, and ClearCase will trigger an error message when trying to check in an identical file. Meaning you will need 2 commands:
ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct
ct lsco -r -cvi -fmt "unco -rm %n\n" | ct
(with 'ct being 'cleartool' : type 'doskey ct=cleartool $*' on Windows to set that alias)
But if by "checkin" you mean:
"enter into source control for the first time"
"updating a large number of files which may have changed on an existing versionned directory"
I would recommend creating a dynamic view and clearfsimport your snapshot tree (with the new files) in the dynamic view.
See this question or this question.
the clearfsimport script is 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.
:
clearfsimport -preview -rec -nset c:\sourceDir\* m:\MyView\MyVob\MyDestinationDirectory
did you used -recurse option in the clearfsimport command.
Example: clearfsimport -recurse source_dir .
This should help.
If you're using the Windows client, right-click on the parent folder, select Search, leave the file name field empty, click Search, select all the files in the result window (ctrl-A), right-click on them and select ClearCase -> Add to Source Control
If you are in windows you may try,
for /f "usebackq" %i in (`cleartool lsco -cview -me -r -s`) do cleartool ci -nc %i

Resources