Any way to use a special comparison tool with cleartool / clearcase?

I would like to use my own diff when working as a snapshot in cleanup mode.

As far as I can see, there is no way to specify the diff tool when running " cleartool diff ", so I thought I could run something like " mydiff <predecessor file> <modified file in my view> ", but I don't know enough about ClearCase. to be able to find the "predecessor file" for comparison.

How to do it?

I forgot to mention (so far, after reading the first two answers regarding windows) that this is on Unix, and I am not allowed to mix the ClearCase configuration.

+46
clearcase diff cleartool
Dec 17 '08 at 17:49
source share
11 answers

I have another way of working based on the suggestions here. I found the cleartool "get" command, so I execute it to get the previous version of the temporary file:

cleartool get -to fname.temp fname @@ predecessor

Then run my diff and delete this file.

Thanks for all the suggestions.

+3
Dec 18 '08 at 16:02
source share

How to change default reversal tools

You can specify an external comparison tool to change the map file to "c: \ program files \ rational \ ClearCase \ Lib \ MGRS"

WinMerge, proposed by Paul, actually modifies this file.

Each card has 3 parts: CC file type, CC action and application.

Locate the section in the map file for the text_file_delta file types. There you will find lines for comparing the actions of CC, xcompare, merge and xmerge, which look like this:

 text_file_delta compare ..\..\bin\cleardiff.exe text_file_delta xcompare ..\..\bin\cleardiffmrg.exe text_file_delta merge ..\..\bin\cleardiff.exe text_file_delta xmerge ..\..\bin\cleardiffmrg.exe 

You can replace them with the executable file of your comparison tool .




Or a simple diff script

If you want to use the full command line (which I like ;-)), a little ccperl might help:

 #!/bin/perl my ($file, $switches) = @ARGV; $switches ||= '-ubBw'; my ($element, $version, $pred) = split(/;/,`cleartool describe -fmt '%En;%Vn;%PVn' $file`); unless ($pred) { die "ctdiff: $file has no predecessor\n"; } exec "mydiff $switches $element\@\@$pred $file"; 

Warning: the extended path name ( @@\... ) is only available in the dynamic view ( M:\... , not a snapshot ( c:\... ).

The script has nothing to do with the map file above:

  • this file defines "Type Merge Managers".
  • This script allows you to run any merge manager for any file you want, without reading any map file, in order to look for a suitable diff exe to use for this file.

Here you provide the script with both information: the file (as a parameter) and diff exe to run (as part of the script implementation: replace mydiff with any other option you want).




Or, improved diff script (also works in static / snapshot view)

Here is a version of this script that works for both snapshot and dynamic viewing.

To represent the snapshot, I use the chacmool clause: cleartool get .

Again, you can replace the diff included in this script with the tool of your choice.

 #!/bin/perl my ($file, $switches) = @ARGV; $switches ||= '-u'; my ($element, $version, $pred) = split(/;/,`cleartool describe -fmt '%En;%Vn;%PVn' $file`); unless ($pred) { die "ctdiff: $file has no predecessor\n"; } # figure out if view is dynamic or snapshot my $str1 = `cleartool lsview -long -cview`; if($? == 0) { dodie("pred.pl must be executed within a clearcase view"); } my @ary1 = grep(/Global path:/, split(/\n/, $str1)); if($str1 =~ /View attributes: snapshot/sm) { $is_snapshot = 1; } my $predfile = "$element\@\@$pred"; $predfile =~ s/\'//g;#' #printf("$predfile\n"); if ($is_snapshot) { my $predtemp = "c:\\temp\\pred.txt"; unlink($predtemp); my $cmd = "cleartool get -to $predtemp $predfile"; printf("$cmd\n"); my $str2 = `$cmd`; $predfile = $predtemp; } sub dodie { my $message = $_[0]; print($message . "\n"); exit 1; } exec "diff $switches $predfile $file"; 
+59
Dec 17 '08 at 17:58
source share

Another option is to use Git + ClearCase (or see this or that ) and just compare with Git.

This is surprisingly easy to install, and in my experience, your brain actually hurts less when using two VCS systems at the same time than when trying to turn CC into a 21st century tool.

Just think of Git as a bridge between CC and diff :-)

+6
Dec 17 '08 at 22:32
source share

It seems someone has already thought about this on snip2code!
Here's a tcsh bash script that does exactly what you want.

Custom-diff-tool-for-clearcase-object

As you can see, the following key code to get the previous version of this file:

cleartool descr -pred -short $1

Where $1 is the name of the file to compare.




 #!/bin/tcsh -e set _CLEARCASE_VIEW = `cleartool pwv -short -setview` echo Set view: "$_CLEARCASE_VIEW" set my_firstversion = "" set my_secondversion = "" set my_difftool = kdiff3 # check clearcase view if ( "$_CLEARCASE_VIEW" == "** NONE **" ) then echo "Error: ClearCase view not set, aborted." exit -1 endif if ( "$1" == "" ) then echo "Error: missing 1st file argument!" echo "Eg: `basename $0` file1.txt -> This will diff file1.txt with its previous version" echo "Eg: `basename $0` file1.txt file2.txt -> This will diff file1.txt and file2.txt" exit -1 endif set my_firstversion = "$1" echo "my_firstversion=$my_firstversion" if ( "$2" == "" ) then echo "No 2nd file passed, calculating previous version of $my_firstversion" set my_secondversion = $my_firstversion@@`cleartool descr -pred -short $my_firstversion` else echo "Setting 2nd file to $2" set my_secondversion = "$2" endif echo "my_secondversion=$my_secondversion" ${my_difftool} ${my_firstversion} ${my_secondversion} & 
+5
Sep 19 '13 at 8:23
source share

Kdiff3 has built-in integration. Open the tool - go to Settings → Configure → Integration and click the “Integrate with ClearCase” button. This tool has excellent trilateral diff support, handles UTF-8 and with this automatic integration you don’t have to worry about element types, etc. In the map file.

+4
Sep 30 '13 at 11:25
source share

Here's a link to IBM docs about changing the XML ClearCase cleanup tool:

Changing the Diff / Merge XML Type Manager

http://www-01.ibm.com/support/docview.wss?rs=984&uid=swg21256807

+3
Sep 10 2018-10-10
source share

You can try this trick :

  • Create an empty file

    % touch empty

  • Get for version A

    % cleartool diff -ser empty File@@/main/28 > A

  • Get for version B

    % cleartool diff -ser empty File@@/main/29 > B

  • Diff and profit!

    % your-diff-here AB

Put it in a script and make the parameters a little more flexible and you have it.

If you want, you can easily cut cleartool diff with a little awk or cut or perl or poison of choice.

Hooray for ClearCase!

+1
Dec 17 '08 at 22:28
source share

I installed "WinMerge" (a free diff tool), and it installed itself as a clear-clearing tool. I'm not sure how this happened.

0
Dec 17 '08 at 17:56
source share

WinMerge, as already mentioned, automatically detects the ClearCase installation and modifies the map file in the Clearcase installation path.

I'm having problems since ClearCase will open its own comparison tool, because installing WinMerge has not changed all the necessary positions. Therefore, it’s nice to read the documentation for ClearCase so that you can fix it manually if necessary.

0
Feb 23 '09 at 17:35
source share

This works well for me:

 %vimdiff my_file.c my_file.c@@/main/LATEST 
0
Nov 15 '10 at 9:35
source share

I usually do that.

For unified diff cleartool diff -pred <my file>

For graphic differences, cleartool diff -pred -g <my file>

0
Jan 05 '15 at 17:52
source share



All Articles