From 84f94fe3316480c7bebebf0858579ef3a94c1101 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Fri, 30 Mar 2012 09:49:28 -0400 Subject: [PATCH] Filter svn output as it's generated. As opposed to opening the log file afterwards and searching for conflicts a second time. --- kdesrc-build | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/kdesrc-build b/kdesrc-build index 28b6265..984c81c 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -2978,7 +2978,6 @@ END my ($self, $logfilename, $arg_ref) = @_; assert_isa($self, 'SvnUpdate'); my $module = $self->module(); - my $conflict = 0; my $revision = $module->getOption('revision'); if ($revision ne '0') @@ -2991,37 +2990,26 @@ END $arg_ref = \@tmp; } - # Do svn update. - my $result = log_command($module, $logfilename, $arg_ref); - - return 0 if pretending(); - - croak_runtime("Error updating $module!") unless $result == 0; - - my $logdir = $module->getLogDir(); - $logfilename = "$logdir/$logfilename.log"; - - # TODO: Use callback filter instead of opening log. + my $count = 0; + my $conflict = 0; - # We need to open the file and try to determine what the Subversion process - # did. - open SVN_LOG, "<$logfilename" or return undef; + my $callback = sub { + return unless $_; - my $count = 0; - while () - { # The check for capitalized letters in the second column is because # svn can use the first six columns for updates (the characters will # all be uppercase), which makes it hard to tell apart from normal # sentences (like "At Revision foo" + $count++ if /^[UPDARGMC][ A-Z]/; + $conflict = 1 if /^C[ A-Z]/; + }; - # Count all changes to the files. - $count++ if /^[UPDARGMC][ A-Z]/; + # Do svn update. + my $result = log_command($module, $logfilename, $arg_ref, { callback => $callback }); - $conflict = 1 if /^C[ A-Z]/; - } + return 0 if pretending(); - close SVN_LOG; + croak_runtime("Error updating $module!") unless $result == 0; if ($conflict) {