summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-02-07 08:03:00 +0100
committerByron Jones <bjones@mozilla.com>2013-02-07 08:03:00 +0100
commit275eb1b39a25ef88f47fa5b592c9cf02ad9f754d (patch)
tree0104e2d11a3e7ecac5c8901a3e3bafe01763dff9 /Bugzilla
parent87badf1db52d0f54fd83a940fb4a884b56e159ff (diff)
downloadbugzilla-275eb1b39a25ef88f47fa5b592c9cf02ad9f754d.tar.gz
bugzilla-275eb1b39a25ef88f47fa5b592c9cf02ad9f754d.tar.xz
Bug 784352: Show a warning when interdiff reports errors
r=dkl, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Attachment/PatchReader.pm28
1 files changed, 23 insertions, 5 deletions
diff --git a/Bugzilla/Attachment/PatchReader.pm b/Bugzilla/Attachment/PatchReader.pm
index cf1648579..29ff1f93f 100644
--- a/Bugzilla/Attachment/PatchReader.pm
+++ b/Bugzilla/Attachment/PatchReader.pm
@@ -10,6 +10,9 @@ package Bugzilla::Attachment::PatchReader;
use 5.10.1;
use strict;
+use IPC::Open3;
+use Symbol 'gensym';
+
use Bugzilla::Error;
use Bugzilla::Attachment;
use Bugzilla::Util;
@@ -100,8 +103,23 @@ sub process_interdiff {
# Send through interdiff, send output directly to template.
# Must hack path so that interdiff will work.
$ENV{'PATH'} = $lc->{diffpath};
- open my $interdiff_fh, "$lc->{interdiffbin} $old_filename $new_filename|";
- binmode $interdiff_fh;
+
+ my ($interdiff_stdout, $interdiff_stderr);
+ $interdiff_stderr = gensym;
+ my $pid = open3(gensym, $interdiff_stdout, $interdiff_stderr,
+ $lc->{interdiffbin}, $old_filename, $new_filename);
+ binmode $interdiff_stdout;
+
+ # Check for errors
+ {
+ local $/ = undef;
+ my $error = <$interdiff_stderr>;
+ if ($error) {
+ warn($error);
+ $warning = 'interdiff3';
+ }
+ }
+
my ($reader, $last_reader) = setup_patch_readers("", $context);
if ($format eq 'raw') {
@@ -114,7 +132,7 @@ sub process_interdiff {
}
else {
# In case the HTML page is displayed with the UTF-8 encoding.
- binmode $interdiff_fh, ':utf8' if Bugzilla->params->{'utf8'};
+ binmode $interdiff_stdout, ':utf8' if Bugzilla->params->{'utf8'};
$vars->{'warning'} = $warning if $warning;
$vars->{'bugid'} = $new_attachment->bug_id;
@@ -125,9 +143,9 @@ sub process_interdiff {
setup_template_patch_reader($last_reader, $format, $context, $vars);
}
- $reader->iterate_fh($interdiff_fh, 'interdiff #' . $old_attachment->id .
+ $reader->iterate_fh($interdiff_stdout, 'interdiff #' . $old_attachment->id .
' #' . $new_attachment->id);
- close $interdiff_fh;
+ waitpid($pid, 0);
$ENV{'PATH'} = '';
# Delete temporary files.