use warnings; use strict; use Win32::Process; use File::Find; use File::Path; use Tk; my $cvs = '"C:\Program Files\GNU\WinCvs 1.3\CVSNT\cvs"'; my $diffTool; my $confictFile; my $listOnly = 0; while ($_ = shift) { ShowHelp (-3, "Too many parameters provided.\n\n") if defined $confictFile; $confictFile = $_ if defined $diffTool; $diffTool = $_ if ! defined $diffTool; } ShowHelp () if ! $diffTool; ErrorBox ("Missing Conflict File", "Can't find $confictFile\n\n") if ! -e $confictFile; (my $path = $confictFile) =~ s/^(.*)[\/\\](.*?)$/$1/; my $fileName = $2; find (\&setHeadFile, ($path)); my $headFile; # Set in setHeadFile @ARGV = ($confictFile); while (<>) { next if ! />>>>>>>\s+((?:\d+\.){2})/; my $commonRev = substr $1, 0, -1 + length $1; my $commonRevSrc = `$cvs update -P -p -r $commonRev $confictFile`; ErrorBox ("cvs failed", $commonRevSrc) if $?; my $tempFileName = "${confictFile}.$commonRev"; open tempFile, ">", $tempFileName; print tempFile $commonRevSrc; close tempFile; my $proc2; Win32::Process::Create ( $proc2, "$diffTool", "\"$diffTool\" $headFile $confictFile", 0, NORMAL_PRIORITY_CLASS, "." ) || ErrorBox ("Create failed", Win32::FormatMessage (Win32::GetLastError ())); my $proc1; Win32::Process::Create ( $proc1, "$diffTool", "\"$diffTool\" $tempFileName $headFile", 0, NORMAL_PRIORITY_CLASS, "." ) || ErrorBox ("Create failed", Win32::FormatMessage (Win32::GetLastError ())); exit (0); } ErrorBox ("No conflicts", "No conficts found in $confictFile"); sub ShowHelp { my $exitValue = 0; $exitValue = shift if defined $_[0] and $_[0] =~ /^[-+]?\d+$/; print $_ while $_ = shift; print "ConflictCompare opens two diff tool apps to compare the HEAD merged result\n"; print "against the common ancestor and the branch version that was merged.\n"; print "\n"; print "Usage:\n\n"; print "ConflictCompare [-n] <.# conflict file>\n"; print "\n"; print " -n: show progress information.\n"; print "\n"; exit ($exitValue || -1); } sub ErrorBox { my $main = MainWindow->new (); my $title = shift; my $message = shift; $main->withdraw (); $main->messageBox(-icon => 'error', -message => $message, -title => $title, -type => 'Ok'); exit (-2); } sub setHeadFile { return if $File::Find::name =~ /^\.\.?/; return if $File::Find::name !~ /$fileName(?:\.\d+)+/; return if $headFile and -M $headFile >= -M $File::Find::name; $headFile = $File::Find::name; }