如何更改默认差异工具
您可以通过修改文件映射来指定外部差异工具,在“c:\program files\rational\ClearCase\lib\mgrs”
Paul 建议的 WinMerge 实际上修改了该文件。
每个地图行包含 3 个部分:CC 文件类型、CC 操作和应用程序。
在映射文件中查找 text_file_delta 文件类型的部分。在那里,您将找到 CC 操作 compare、xcompare、merge 和 xmerge 的行,如下所示:
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
您可以将它们替换为您选择的差异工具的可执行文件。
或者,一个简单的差异脚本
如果您想对此使用完整的命令行(我喜欢 ;-)),一点 ccperl 可以提供帮助:
#!/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";
警告:扩展路径名 ( @@\...
) 只能在动态视图 ( M:\...
,而不是快照视图 ( c:\...
) 中访问。
map
该脚本与上述文件无关:
- 该文件定义了“类型合并管理器”。
- 此脚本允许您在所需的任何文件上运行任何合并管理器,而无需读取任何映射文件来查找用于给定文件的正确 diff exe。
在这里,您向脚本提供两个信息:文件(作为参数)和要运行的 diff exe(在脚本实现中:替换mydiff
为您想要的任何 diff exe)。
或者,改进的差异脚本(也适用于静态/快照视图)
这是此脚本的一个版本,适用于快照和动态视图。
对于快照视图,我使用 chacmool 的建议:cleartool get
.
同样,您可以用diff
您选择的工具替换此脚本中包含的命令。
#!/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";