Commit 275eb1b3 authored by Byron Jones's avatar Byron Jones

Bug 784352: Show a warning when interdiff reports errors

r=dkl, a=LpSolit
parent 87badf1d
...@@ -10,6 +10,9 @@ package Bugzilla::Attachment::PatchReader; ...@@ -10,6 +10,9 @@ package Bugzilla::Attachment::PatchReader;
use 5.10.1; use 5.10.1;
use strict; use strict;
use IPC::Open3;
use Symbol 'gensym';
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::Attachment; use Bugzilla::Attachment;
use Bugzilla::Util; use Bugzilla::Util;
...@@ -100,8 +103,23 @@ sub process_interdiff { ...@@ -100,8 +103,23 @@ sub process_interdiff {
# Send through interdiff, send output directly to template. # Send through interdiff, send output directly to template.
# Must hack path so that interdiff will work. # Must hack path so that interdiff will work.
$ENV{'PATH'} = $lc->{diffpath}; $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); my ($reader, $last_reader) = setup_patch_readers("", $context);
if ($format eq 'raw') { if ($format eq 'raw') {
...@@ -114,7 +132,7 @@ sub process_interdiff { ...@@ -114,7 +132,7 @@ sub process_interdiff {
} }
else { else {
# In case the HTML page is displayed with the UTF-8 encoding. # 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->{'warning'} = $warning if $warning;
$vars->{'bugid'} = $new_attachment->bug_id; $vars->{'bugid'} = $new_attachment->bug_id;
...@@ -125,9 +143,9 @@ sub process_interdiff { ...@@ -125,9 +143,9 @@ sub process_interdiff {
setup_template_patch_reader($last_reader, $format, $context, $vars); 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); ' #' . $new_attachment->id);
close $interdiff_fh; waitpid($pid, 0);
$ENV{'PATH'} = ''; $ENV{'PATH'} = '';
# Delete temporary files. # Delete temporary files.
......
...@@ -119,15 +119,18 @@ Interdiff of #[% oldid %] and #[% newid %] for [% terms.bug %] #[% bugid %] ...@@ -119,15 +119,18 @@ Interdiff of #[% oldid %] and #[% newid %] for [% terms.bug %] #[% bugid %]
[% END %] [% END %]
[% IF warning %] [% IF warning %]
<h2 class="warning">Warning: <h2 class="warning">
Warning:
[% IF warning == "interdiff1" %] [% IF warning == "interdiff1" %]
this difference between two patches may show things in the wrong places due this difference between two patches may show things in the wrong places due
to a limitation in [% terms.Bugzilla %] when comparing patches with different to a limitation in [% terms.Bugzilla %] when comparing patches with
sets of files. different sets of files.
[% END %] [% ELSIF warning == "interdiff2" %]
[% IF warning == "interdiff2" %] this difference between two patches may be inaccurate due to a limitation
this difference between two patches may be inaccurate due to a limitation in in [%+ terms.Bugzilla %] when comparing patches made against different
[%+ terms.Bugzilla %] when comparing patches made against different revisions. revisions.
[% ELSIF warning == "interdiff3" %]
interdiff encountered errors while comparing these patches.
[% END %] [% END %]
</h2> </h2>
[% ELSE %] [% ELSE %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment