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.
Related
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.
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.
I was trying to migrate a file from directory A to directory B in a branch, call it file.txt. What I did was:
cd A
cp file.txt ../B/
ct rm A
cd ../B
ct mkelem -ci -nc file.txt
Thereby losing all the history. I am trying to recover from this to do what I should have done which is simply ct mv file.txt ../B
I read that for this I should do something like this:
cd A
ct ln .##/main/?/file.txt ./file.txt
where luckily, from another view, I've figured out ? should be 27. Unfortunately when I try to do the above I get:
cleartool: Error: Entry named "file.txt" already exists.
cleartool: Error: Unable to create link: "./file.txt".
and I try to do:
ct rmelem file.txt
but got:
cleartool: Error: Element "file.txt" has branches not created by user
though presumably that's not what I should be doing anyway. How do I get back that file? It was simply a ct rm. I even get the entry already exists error if I do ct rm on the new copy file I added to directory B..
You are on the right track, but I would recommend a simple rmname, instead of a rmelem (which deletes the element with all its versions, branches and such).
That would remove file.txt from the latest version of the parent directory, and allows you to proceed with the symlink.
Next time, a cleartool mv might be easier, and keep the history of the file being moved.
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>
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