Clear tool command (Clear case) for getting the versions of the files in the directory - clearcase

In the clear case, I want versions of the file in the particular directory with complete file path. By right click on the file and after that going for properties in the file it is possible to take, but in case in the directory 100 files are there, so it will become very huge task. I want to know the clear tool command , which i can execute from the command prompt and after that I can redirect output to some text file
Example of path I am using:
M:\My_Project\Verif_Folder\TP\Functional_TP\ETP\ here

Check the command cleartool find, combined with a cleartool describe and fmt_ccase option:
cd M:\Myproject\...\here
cleartool find . -type f -exec "cleartool describe \"%CLEARCASE_XPN%\" -fmt \"%Xn\""
%Xn: Extended name: Same as default
%n output, but for checked-out versions, append the extension ##\branch-pathname\CHECKEDOUT
The result will be the path of the file, its name, and its extended path including its current selected version.

Related

How to delete a view tag with special characters in ClearCase

I have a view, for some reason, it was named with a special character: "0x7f", at least I think so..
For example:
MyView123456 -> MyView'0x7f'123456
I can only found this view by
ct lsview #list all views.
And I found this "0x7f" when dump the outputs to a file.
And using vim.
Now I'm trying to delete this view totally.
I can unregistered and delete the view itself by -uuid.
But I cannot delete the view tag.
And I also found wildcard '*' seems not working.
Does anyone know how to delete this view tag?
P.s. I'm under Linux, and no GUI.
Try first if dome of the workaround described in "Removing ClearCase objects whose name begins with a hyphen", when using cleartool rmtag:
cleartool rmtag -- MyView*
Note the use of '--' in order to separate the command from its parameters
The wildcard being expanded by your shell, try and use it instead in the cleartool interractive session:
cleartool
> rmtag -- MyView*
In Linux shell, see if a single quote is enough:
cleartool rmtag -- MyView'0x7f'123456
# or
cleartool rmtag -- 'MyView0x7f123456'
I was able to create and remove a view with binary data in the tag using Perl. You have to use the OCTAL value of 177 in the strings.
I created my view using this command line:
perl -e '`cleartool mkview -tag myview\177tag /net/bullwinkle/export/vobstg/binarytag.vws`'
And I successfully removed that view tag using this command line:
perl -e '`cleartool rmview -tag myview\177tag`'
If the view was unique enough, you could also use (on Unix) or at least try:
cleartool rmview -tag `cleartool lsview 'myview*123456'`
There is another mechanism, if all else fails: you can edit the vob_tag registry file. This would require an outage as the registry file is loaded into the registry server's memory on clearcase startup and only re/written after that point.
The process is:
Stop ClearCase on the registry server
CD to /var/adm/rational/clearcase/rgy (Unix) or {CC Install dir}\var\rgy (Windows)
Back up the vob_tag file.
load the vob_tag file in an editor. (vi/gedit on unix, but I'd use notepad++ on windows)
locate the problem view tag (you may need to search on the global path or some other component of the name).
Make note of the path to the view.
Delete the line.
Start ClearCase on the registry server
unregister the view or retag it with an easier-to-access tag.

How do I label new files on a branch using cleartool?

To provide some context, I am trying to write a script which will take a text file with clearcase elements in it, and label all of those elements.
To generate the text file, I am basically using the following command:
cleartool find -a -nxn -ele "brtype(branchName)" -print > "textfile.txt"
Then I go through the text file and remove the elements I don't want to label. The last step would be to feed the text file into a script which would repeatedly call a cleartool command on each line of the file.
For all existing files/folders, I can run this command:
cleartool mklabel -rep "label_name" (element_path)
Where I run into trouble is with files that have been added to the branch. They print out to the text file in a format that isn't recognized by the "mklabel" command and I can't find a good way to parse them.
The format of the files is similar to the following:
\original_folder_path##\branch_name\version_number\new_sub_folder_path\branch_name\version_number\file_name.java
In the past I have used this generic command we use at my company to blindly label all files in a branch:
cleartool find -all -branch "brtype(<branch>)" -version "version(.../<branch>/LATEST) && !version(.../<branch>/0)" -visible -exec "cleartool mklabel -rep <label_name> %CLEARCASE_XPN%"
But I only want to label about half the files on the branch I am using, and there are too many to label them individually. I am sure I am missing something obvious here. Does anyone know how I should change my find or mklabel command to accommodate the new files and folders?
That format "\original_folder_path##\branch_name\version_number" is an extended pathname, and isn't reserved for "added file".
It is current rather for files listed by a cleartool find, but not visible (directly accessible) in the view used by the cleartool find.
You need to make sure to use a view which is set to select the LATEST from brname.
If you see extended pathnames in your cleartool find, you can ignore them: they are not accessible by said view.
Or you could use a cleartool find -cview, in order to limit the results to what you view is able to select and see.

How to specify -log parameter in cleartool update command

I am trying to automate updating my clearcase view and build the code in a bat file. I want to run the update command and then check the log to verify its success. For this I want to save the update log in a specified location rather than its default location
Now, cleartool allows you to specify your own log file within the cleartool console
cleartool>update -log pname
but when i use the same as a single command, it doesnt work
D:> cleartool -log pname --------- THIS DOESNT WORK
any ideas?
Thanks
RB
you need to do (from cleartool update man page):
cleartool update -log pname /path/to/root/view/directory
A cleartool update outside a view won't work.
A cleartool update with the path of a root view directory will work.
If you specify that root directory, then you can execute the cleartool update command from any path, including D:\.
pname ...
If you do not specify –add_loadrules, this argument specifies the files and directories to update.
All specified directories, including the root directory of the snapshot view, are updated recursively.

Get specific version of unloaded file with cleartool

So I'm writing a script at work where I have to go through all the projects in a ClearCase vob, look for a file and parse some info from said file.
Naturally, I wouldn't want to load every single project so I'm using cleartool to retrieve the unloaded files.
First, I'm using the find command to locate the files. This was my first attempt:
root>cleartool find C:/viewpath -name file.txt -version "lbtype(Version-label)" -print -nr
Viewpath is the path to the project where I'm currently looking for the file. The file I'm looking for is file.txt on the version specified by Version-label.
This gave me no result whatsoever, even though I knew file.txt existed on that version.
I figured out it was looking through an old version of the directory, the latest on the main-branch, which was before file.txt was added to the directory. I tried this instead:
root>cleartool find C:/viewpath##/Version-label -name file.txt -version "lbtype(Version-label)" -print -nr
And got this result, which was what I was looking for
C:/viewpath\file.txt##\main\branch\41
So now that I knew where I could find the file I tried to get it.
root>cleartool get -to savepath C:/viewpath\file.txt##\main\branch\41
Which gave me this result
cleartool: Error: "C:/viewpath\file.txt##\main\branch\41" does not exist, or is not a ClearCase version, or is a checked out version which was removed.
Also tried
root>cleartool get -to savepath C:/viewpath\file.txt##/Version-label
With the same result
I can get files added to the directory when it was still on the main-branch, so it is still searching through the directory on the main-branch, where file.txt is nowhere to be found.
How do I tell it to look through a version of the directory from after it was branched from main?
I would really recommend for you to try those same commands in a dynamic view.
As illustrated here, a dynamic view gives you access to extended path (the file##/branch/version syntax), which means command like get will work.
You have in this question an example of search (cleartool find) using extended paths.
As explained in "In ClearCase, how can I view old version of a file in a static view, from the command line?", you can browse (as in 'change directory to') the various extended paths of a file in a dynamic view.

rename element in clearcase with ## in filename

For some reason some users produced some files that end in "##" (...) (I think because they have in the CCRC the gui option to show the version extended pathname and i think that has somewhere a little bug).
Now... they are unable to remove or rename these files (it returns "not a object in the vob")
how can they rename or remove these files?
update
Resolved I forgot to use the complete rmname "a.doc####\bla\1", after the full path i could delete them.
The simplest solution would be to try to list and remove those objects from a base ClearCase view directly on the CCRC server (or any base ClearCase client).
From this kind of ClearCase installation (CCRC server or full ClearCase client), you do have access to cleartool (the ClearCase CLI -- Command Line Interface --), and you can:
cleartool ls: list the files in the view, to check those files with ## are indeed there
cleartool rmane -force to remove them
The OP used
cleartool rmname "a.doc####\bla\1"
, meaning he had to use the extended path (file name + ## + version path) of the file ended with ##, hence the four #: file####version.

Resources