Utilities for element types and default.magic testing George Moberly, Rational ClearCase/Windows Engineering georgem@rational.com These utilities are useful for managing element types, changing types based on additions to the default.magic file or creation of new element types in a VOB. They have been tested against ClearCase v3.2.1.NT only. They also provide some testing structure for evaluating changes to default.magic or creation of your own magic files. Installation: After extracting the .zip file to a directory of your choice, simply put the pathname to this directory in your system or user PATH variable through start->settings->control panel->system->environment. Also, create a user environment variable MAGIC_PATH. If you extracted to "c:\george\t0043" and ClearCase is installed in "c:\atria", you would set MAGIC_PATH to "c:\george\t0043;c:\atria\config\magic". You must exit and restart the command shell before the new settings take effect. In the cmd.exe shell, type "set". Correct values are: MAGIC_PATH=c:\george\t0043;c:\atria\config\magic PATH=;c:\george\t0043; File manifest, and command usage/examples: my.magic : This version adds two entries for "*.doc" to handle Microsoft Word 97 documents. This is matched before the installed default.magic because of setting MAGIC_PATH. Now, "cd" into the installation directory for these utilities. magicfile.exe : This makes the same library call that "cleartool mkelem" does to determine the element type. > magicfile -v Magic file search path: c:\george\t0043;c:\atria\config\magic This shows the search path in effect, since we set MAGIC_PATH > magicfile readme.doc readme.doc : ms_word_97 ms_office binary_delta_file This matches the rule in my.magic, if we mkelem "readme.doc" it will have as its element type the first match in the element type list. If you have not installed any element types with "cleartool mkeltype" then "binary_delta_file" will be used. This can be useful in situations where you might want to know the type before performing the mkelem, perhaps in a pre-mkelem trigger. isprint.exe : This utility basically implements the "-printable" algorithm that many of the rules in the shipping default.magic use. It can be useful to determine why something you think SHOULD be printable is not, and edit the file appropriately. > isprint readme.doc file "readme.doc" is NOT printable character:- line:1 column:1 This is a binary file, so this result is expected. > isprint findchtype.bat file "findchtype.bat" is NOT printable character:, line:8 column:17 This result IS surprising. You would think a .bat file would be printable. If you look at the file, you can see that the offending character is the "copyright" character in the Rational Copyright. If you remove this character, it becomes printable. >isprint findmagic.bat file "findmagic.bat" is printable, avg. linelength is 46.6 This batch file has the copyright character removed, so is printable. Reconfirming these findings with magicfile: >magicfile findmagic.bat findmagic.bat : text_file >magicfile findchtype.bat findchtype.bat : compressed_file isprint directory: This is a Visual C++ 6.0 project for isprint.exe and contains source and project files. Now, convert this directory into a VOB to follow the remaining examples. clearexport_ffile -r . Go to the VOB, for example \vob3, and import. Optionally, run "cleartool protect -chmod a+x" on *.exe and *.bat. > cd vob3 >clearimport c:\george\t0043\cvt_data Validating directories and symbolic links. Validating elements. Creating element ".\findchtype.bat".  findmagic.bat : This does a "find ." from where you are at and dumps the results of a magicfile.exe on each file element. >findmagic .\findchtype.bat : compressed_file .\findmagic.bat : text_file .\findnoexist.bat : compressed_file .\isprint\debug\isprint.exe : program compressed_file .\isprint\debug\isprint.ilk : compressed_file .\isprint\debug\isprint.obj : object_module compressed_file .\isprint\debug\isprint.pch : compressed_file .\isprint\debug\isprint.pdb : compressed_file .\isprint\debug\vc60.idb : compressed_file .\isprint\debug\vc60.pdb : compressed_file .\isprint\isprint.c : c_source source text_file .\isprint\isprint.dep : text_file .\isprint\isprint.dsp : text_file .\isprint\isprint.dsw : text_file .\isprint\isprint.mak : text_file .\isprint\isprint.ncb : compressed_file .\isprint\isprint.opt : compressed_file .\isprint\isprint.plg : text_file .\isprint.exe : program compressed_file .\magicfile.exe : program compressed_file .\my.magic : text_file .\readme.doc : ms_word_97 ms_office binary_delta_file .\readme.html : html_source source text_file Note: if you have MKS toolkit or other "find" implementation, you can uncomment the find in all three scripts and do this in any filesystem, not just a VOB. findnoexist.bat : This is a specialized testing utility that you probably won't need or use, but what it does is compare the element type for an existing file to that which would be used if you "mkelem" a non-existing file with the same name. Here you see that there is no rule for many of the files, and mismatch on the .doc file. Note that we are planning on releasing a default.magic in a future release that will produce significantly better results. >findnoexist no .\findchtype.bat : "compressed_file" no .\findmagic.bat : "text_file" no .\findnoexist.bat : "compressed_file" no .\isprint\debug\isprint.ilk : "compressed_file" no .\isprint\debug\isprint.pch : "compressed_file" no .\isprint\debug\isprint.pdb : "compressed_file" no .\isprint\debug\vc60.idb : "compressed_file" no .\isprint\debug\vc60.pdb : "compressed_file" no .\isprint\isprint.dep : "text_file" no .\isprint\isprint.dsp : "text_file" no .\isprint\isprint.dsw : "text_file" no .\isprint\isprint.mak : "text_file" no .\isprint\isprint.ncb : "compressed_file" no .\isprint\isprint.opt : "compressed_file" no .\isprint\isprint.plg : "text_file" no .\my.magic : "text_file" mismatch .\readme.doc : "ms_word_97 ms_office binary_delta_file" "document compressed_file" findchtype.bat : This utility scours every element in the current VOB for cases where the element type of the file does not match what a newly-created element with the current magic files would have. It then queries and performs "cleartool chtype" operations where there is a mismatch. For example: >findchtype element types in this vob: file compressed_text_file file_system_object text_file compressed_file directory binary_delta_file CHANGE: C:\atria\views\sna\vob3\findchtype.bat "text_file" "compressed_file " "compressed_file" ? > n SAME: C:\atria\views\sna\vob3\findmagic.bat "text_file" "text_file " "text_file" CHANGE: C:\atria\views\sna\vob3\findnoexist.bat "text_file" "compressed_file " "compressed_file" ? > n SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.exe "compressed_file" "program compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.ilk "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.obj "compressed_file" "object_module compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.pch "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.pdb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\vc60.idb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\vc60.pdb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.c "text_file" "c_source source text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.dep "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.dsp "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.dsw "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.mak "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.ncb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.opt "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.plg "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint.exe "compressed_file" "program compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\magicfile.exe "compressed_file" "program compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\my.magic "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\readme.doc "binary_delta_file" "ms_word_97 ms_office binary_delta_file " "binary_delta_file" SAME: C:\atria\views\sna\vob3\readme.html "text_file" "html_source source text_file " "text_file" We answered no on the queries, these are the funny batch files with the copyright characters in them, and we leave them as text. The format of the output is as follows: file-path current-eltype magic-eltypes target-eltype-for-chtype The current-eltype is the actual current element type as produced by "cleartool describe". The magic-eltypes is a list of element types produced by a lookup against the magic files. The targets-eltype-for-chtype is the result of looking up, in turn, each type in the magic-eltypes list, and matches on the first element type that is present in this VOB. If there is a change, then you can optionally actually chtype that element. For example, we create a ms_word_97 element type in this VOB and rerun. Newly created elements will then have this element type, but existing elements will not. Existing elements can be "upgraded" by running this utility >cleartool mkeltype -supertype binary_delta_file -nc ms_word_97 Created element type "ms_word_97". Now running again, we "upgrade" readme.doc to be ms_word_97. >findchtype element types in this vob: file compressed_text_file ms_word_97 file_system_object text_file compressed_file directory binary_delta_file CHANGE: C:\atria\views\sna\vob3\findchtype.bat "text_file" "compressed_file " "compressed_file" ? > n SAME: C:\atria\views\sna\vob3\findmagic.bat "text_file" "text_file " "text_file" CHANGE: C:\atria\views\sna\vob3\findnoexist.bat "text_file" "compressed_file " "compressed_file" ? > n SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.exe "compressed_file" "program compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.ilk "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.obj "compressed_file" "object_module compressed_file " "compressed_fiile" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.pch "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\isprint.pdb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\vc60.idb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\debug\vc60.pdb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.c "text_file" "c_source source text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.dep "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.dsp "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.dsw "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.mak "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.ncb "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.opt "compressed_file" "compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\isprint\isprint.plg "text_file" "text_file " "text_file" SAME: C:\atria\views\sna\vob3\isprint.exe "compressed_file" "program compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\magicfile.exe "compressed_file" "program compressed_file " "compressed_file" SAME: C:\atria\views\sna\vob3\my.magic "text_file" "text_file " "text_file" CHANGE: C:\atria\views\sna\vob3\readme.doc "binary_delta_file" "ms_word_97 ms_office binary_delta_file " "ms_word_97" ? > y Changed type of element "C:\atria\views\sna\vob3\readme.doc" to "ms_word_97". SAME: C:\atria\views\sna\vob3\readme.html "text_file" "html_source source text_file " "text_file"