From 57bb3c82a1aa0bf0de24ebeea586182e6178c2d2 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Mon, 11 Aug 2008 00:06:05 +0000 Subject: [PATCH] Fix bug 168860 in kdesvn-build (source conflicts are not detected on subsequent build, leading to confusing build failure messages) BUG:168860 svn path=/trunk/KDE/kdesdk/scripts/kdesvn-build; revision=844934 --- kdesvn-build | 104 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/kdesvn-build b/kdesvn-build index 9f601ea..91efefb 100755 --- a/kdesvn-build +++ b/kdesvn-build @@ -294,6 +294,9 @@ use constant { IPC_ALL_SKIPPED => 4, # Used to indicate a skipped update process (i.e. build anyways) IPC_ALL_FAILURE => 5, # Used to indicate a major update failure (don't build) IPC_ALL_UPDATING => 6, # Informational message, feel free to start the build. + + # Used to indicate specifically that a source conflict has occurred. + IPC_MODULE_CONFLICT=> 7, }; my $versionNum = '1.6.2'; @@ -1983,7 +1986,7 @@ sub update_module_path my $count = eval { run_svn($module, 'svn-up', \@args); }; - if($@) # Update failed, try svn cleanup. + if($@ && $@ !~ /conflict exists/) # Update failed, try svn cleanup. { info "\tUpdate failed, trying a cleanup."; my $result = safe_system('svn', 'cleanup'); @@ -1992,7 +1995,7 @@ sub update_module_path info "\tCleanup complete."; - # Now try again. + # Now try again (allow exception to bubble up this time). $count = run_svn($module, 'svn-up-2', \@args); } @@ -4145,12 +4148,25 @@ sub dont_build if ($ipc) { - $ipc->sendIPCMessage(IPC_MODULE_FAILURE, $module); + if (get_option($module, '#conflict-found')) + { + $ipc->sendIPCMessage(IPC_MODULE_CONFLICT, $module); + } + else + { + $ipc->sendIPCMessage(IPC_MODULE_FAILURE, $module); + } } else { # Weed out matches of the module name @build_list = grep (!/^$module$/, @build_list); + + if (get_option($module, '#conflict-found')) + { + # Record now for posterity + set_persistent_option($module, "conflicts-present", 1); + } } push @{$fail_lists{'update'}}, $module; @@ -4950,6 +4966,9 @@ sub run_svn warning "Source code conflict exists in r[$module], this module will not"; warning "build until it is resolved."; + # If in async this only affects the update process, we need to IPC it + # to the build process. + set_option($module, '#conflict-found', 1); die "Source conflicts exist in $module"; } @@ -5347,6 +5366,76 @@ sub prettify_seconds return $str; } +# Subroutine to check for subversion conflicts in a module. Basically just +# runs svn st and looks for "^C". +# +# First parameter is the module to check for conflicts on. +# Returns boolean true if a conflict exists, false otherwise. +sub module_has_conflict +{ + my $module = shift; + my $srcdir = get_fullpath($module, 'source'); + + info "\tChecking for source conflicts... "; + + # svn up should set this option, so use it as a speedup. + return 0 unless get_persistent_option($module, 'conflicts-present'); + + my $pid = open SVN, "-|"; + if (not defined $pid) + { + error "\tUnable to open check source conflict status: b[r[$!]"; + return 0; # false allows the build to proceed anyways. + }; + + if (0 == $pid) + { + close STDERR; # No broken pipe warnings + exec (qw/svn --non-interactive st/, $srcdir) || + die "Cannot execute 'svn' program: $!"; + # Not reached + } + + while () + { + if (/^C/) + { + error <{'#was-rebuilt'}) { @@ -5596,7 +5687,7 @@ EOF $svn_status{$buffer} = 'success'; info "\tNo source update needed for g[$buffer]"; } - elsif($ipcType == IPC_MODULE_FAILURE) + elsif($ipcType == IPC_MODULE_FAILURE or $ipcType == IPC_MODULE_CONFLICT) { $svn_status{$buffer} = 'failed'; push @{$fail_lists{'update'}}, $buffer; @@ -5609,6 +5700,11 @@ EOF $fail_count = 0 unless defined $fail_count; ++$fail_count; set_persistent_option($buffer, 'failure-count', $fail_count); + + if ($ipcType == IPC_MODULE_CONFLICT) + { + set_persistent_option($buffer, 'conflicts-present', 1); + } } }