cha*_*ool 46 diff clearcase cleartool
在clearcase快照视图中工作时,我想使用自己的diff.
据我所知,运行" cleartool diff" 时无法指定diff工具,因此我认为我可以运行像" mydiff <predecessor file> <modified file in my view>" 这样的东西,但我对ClearCase不太了解能够找到"前任"文件"以反对.
有什么办法吗?
忘了提到(直到现在,在阅读了处理windows的前两个响应之后),这是在Unix上,我不允许使用ClearCase配置.
Von*_*onC 59
您可以通过修改文件映射来指定外部差异工具,在"c:\ program files\rational\ClearCase\lib\mgrs"中
Paul建议的WinMerge实际上修改了该文件.
每个地图行有3个部分:CC文件类型,CC操作和应用程序.
在map文件中找到text_file_delta文件类型的部分.你会在那里找到CC动作比较的行,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
Run Code Online (Sandbox Code Playgroud)
如果你想在这个(我喜欢;-))上完全命令行,一点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";
Run Code Online (Sandbox Code Playgroud)
警告:扩展的pathname(@@\...)只能在动态视图中访问(M:\...而不是快照视图(c:\...).
该脚本与map上面提供的文件无关:
在这里,您向脚本提供了两个信息:文件(作为参数)和要运行的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";
Run Code Online (Sandbox Code Playgroud)
另一个选择是使用Git + ClearCase(或看到这个或这个),只是使用Git进行差异.
这非常容易设置,根据我的经验,它实际上会伤害你的大脑,而不是一次使用两个VCS系统,而不是试图将CC打成21世纪的工具.
想想Git是CC和差异之间的桥梁:-)
似乎有人已经在snip2code上考虑过了!
这里有一个tcsh bash脚本,可以完全满足您的需求.
如您所见,以下是获取给定文件的先前版本的关键代码:
cleartool descr -pred -short $1
$1要比较的文件名在哪里.
#!/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} &
Run Code Online (Sandbox Code Playgroud)
根据这里的建议,我找到了另一种工作方式。我发现了cleartool“get”命令,因此我执行此命令将以前的版本获取到临时文件:
cleartool get -to fname.temp fname@@predecessor
然后运行我的 diff,并删除该文件。
感谢所有的建议。
| 归档时间: |
|
| 查看次数: |
38740 次 |
| 最近记录: |