From 94ffb7a9fb63cf16805b7c627d1914b499960088 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Thu, 16 Oct 2014 18:14:49 +0200 Subject: Bug 1068494: Remove CVS/Bonsai/LXR-specific bits of Patch Viewer r=gerv a=glob --- Bugzilla/Attachment/PatchReader.pm | 86 ++++++++------------------------------ Bugzilla/Config/PatchViewer.pm | 53 ----------------------- Bugzilla/Install/Localconfig.pm | 4 -- 3 files changed, 17 insertions(+), 126 deletions(-) delete mode 100644 Bugzilla/Config/PatchViewer.pm (limited to 'Bugzilla') diff --git a/Bugzilla/Attachment/PatchReader.pm b/Bugzilla/Attachment/PatchReader.pm index aa4df7294..d0e221220 100644 --- a/Bugzilla/Attachment/PatchReader.pm +++ b/Bugzilla/Attachment/PatchReader.pm @@ -23,17 +23,18 @@ use Bugzilla::Util; use constant PERLIO_IS_ENABLED => $Config{useperlio}; sub process_diff { - my ($attachment, $format, $context) = @_; + my ($attachment, $format) = @_; my $dbh = Bugzilla->dbh; my $cgi = Bugzilla->cgi; my $lc = Bugzilla->localconfig; my $vars = {}; - my ($reader, $last_reader) = setup_patch_readers(undef, $context); + require PatchReader::Raw; + my $reader = new PatchReader::Raw; if ($format eq 'raw') { require PatchReader::DiffPrinter::raw; - $last_reader->sends_data_to(new PatchReader::DiffPrinter::raw()); + $reader->sends_data_to(new PatchReader::DiffPrinter::raw()); # Actually print out the patch. print $cgi->header(-type => 'text/plain'); disable_utf8(); @@ -71,7 +72,7 @@ sub process_diff { $vars->{'description'} = $attachment->description; $vars->{'other_patches'} = \@other_patches; - setup_template_patch_reader($last_reader, $format, $context, $vars); + setup_template_patch_reader($reader, $vars); # The patch is going to be displayed in a HTML page and if the utf8 # param is enabled, we have to encode attachment data as utf8. if (Bugzilla->params->{'utf8'}) { @@ -83,11 +84,13 @@ sub process_diff { } sub process_interdiff { - my ($old_attachment, $new_attachment, $format, $context) = @_; + my ($old_attachment, $new_attachment, $format) = @_; my $cgi = Bugzilla->cgi; my $lc = Bugzilla->localconfig; my $vars = {}; + require PatchReader::Raw; + # Encode attachment data as utf8 if it's going to be displayed in a HTML # page using the UTF-8 encoding. if ($format ne 'raw' && Bugzilla->params->{'utf8'}) { @@ -177,10 +180,11 @@ sub process_interdiff { $warning = 'interdiff3'; } - my ($reader, $last_reader) = setup_patch_readers("", $context); + my $reader = new PatchReader::Raw; + if ($format eq 'raw') { require PatchReader::DiffPrinter::raw; - $last_reader->sends_data_to(new PatchReader::DiffPrinter::raw()); + $reader->sends_data_to(new PatchReader::DiffPrinter::raw()); # Actually print out the patch. print $cgi->header(-type => 'text/plain'); disable_utf8(); @@ -193,7 +197,7 @@ sub process_interdiff { $vars->{'newid'} = $new_attachment->id; $vars->{'new_desc'} = $new_attachment->description; - setup_template_patch_reader($last_reader, $format, $context, $vars); + setup_template_patch_reader($reader, $vars); } $reader->iterate_string('interdiff #' . $old_attachment->id . ' #' . $new_attachment->id, $stdout); @@ -208,7 +212,6 @@ sub get_unified_diff { # Bring in the modules we need. require PatchReader::Raw; - require PatchReader::FixPatchRoot; require PatchReader::DiffPrinter::raw; require PatchReader::PatchInfoGrabber; require File::Temp; @@ -220,14 +223,6 @@ sub get_unified_diff { my $reader = new PatchReader::Raw; my $last_reader = $reader; - # Fixes patch root (makes canonical if possible). - if (Bugzilla->params->{'cvsroot'}) { - my $fix_patch_root = - new PatchReader::FixPatchRoot(Bugzilla->params->{'cvsroot'}); - $last_reader->sends_data_to($fix_patch_root); - $last_reader = $fix_patch_root; - } - # Grabs the patch file info. my $patch_info_grabber = new PatchReader::PatchInfoGrabber(); $last_reader->sends_data_to($patch_info_grabber); @@ -274,46 +269,8 @@ sub warn_if_interdiff_might_fail { return undef; } -sub setup_patch_readers { - my ($diff_root, $context) = @_; - - # Parameters: - # format=raw|html - # context=patch|file|0-n - # collapsed=0|1 - # headers=0|1 - - # Define the patch readers. - # The reader that reads the patch in (whatever its format). - require PatchReader::Raw; - my $reader = new PatchReader::Raw; - my $last_reader = $reader; - # Fix the patch root if we have a cvs root. - if (Bugzilla->params->{'cvsroot'}) { - require PatchReader::FixPatchRoot; - $last_reader->sends_data_to(new PatchReader::FixPatchRoot(Bugzilla->params->{'cvsroot'})); - $last_reader->sends_data_to->diff_root($diff_root) if defined($diff_root); - $last_reader = $last_reader->sends_data_to; - } - - # Add in cvs context if we have the necessary info to do it - if ($context ne 'patch' && Bugzilla->localconfig->{cvsbin} - && Bugzilla->params->{'cvsroot_get'}) - { - require PatchReader::AddCVSContext; - # We need to set $cvsbin as global, because PatchReader::CVSClient - # needs it in order to find 'cvs'. - $main::cvsbin = Bugzilla->localconfig->{cvsbin}; - $last_reader->sends_data_to( - new PatchReader::AddCVSContext($context, Bugzilla->params->{'cvsroot_get'})); - $last_reader = $last_reader->sends_data_to; - } - - return ($reader, $last_reader); -} - sub setup_template_patch_reader { - my ($last_reader, $format, $context, $vars) = @_; + my ($last_reader, $vars) = @_; my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; @@ -328,22 +285,15 @@ sub setup_template_patch_reader { } $vars->{'collapsed'} = $cgi->param('collapsed'); - $vars->{'context'} = $context; - $vars->{'do_context'} = Bugzilla->localconfig->{cvsbin} - && Bugzilla->params->{'cvsroot_get'} && !$vars->{'newid'}; # Print everything out. print $cgi->header(-type => 'text/html'); $last_reader->sends_data_to(new PatchReader::DiffPrinter::template($template, - "attachment/diff-header.$format.tmpl", - "attachment/diff-file.$format.tmpl", - "attachment/diff-footer.$format.tmpl", - { %{$vars}, - bonsai_url => Bugzilla->params->{'bonsai_url'}, - lxr_url => Bugzilla->params->{'lxr_url'}, - lxr_root => Bugzilla->params->{'lxr_root'}, - })); + 'attachment/diff-header.html.tmpl', + 'attachment/diff-file.html.tmpl', + 'attachment/diff-footer.html.tmpl', + $vars)); } 1; @@ -364,6 +314,4 @@ __END__ =item process_interdiff -=item setup_patch_readers - =back diff --git a/Bugzilla/Config/PatchViewer.pm b/Bugzilla/Config/PatchViewer.pm deleted file mode 100644 index d090c1ee6..000000000 --- a/Bugzilla/Config/PatchViewer.pm +++ /dev/null @@ -1,53 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Config::PatchViewer; - -use 5.10.1; -use strict; -use warnings; - -use Bugzilla::Config::Common; - -our $sortkey = 1300; - -sub get_param_list { - my $class = shift; - my @param_list = ( - { - name => 'cvsroot', - type => 't', - default => '', - }, - - { - name => 'cvsroot_get', - type => 't', - default => '', - }, - - { - name => 'bonsai_url', - type => 't', - default => '' - }, - - { - name => 'lxr_url', - type => 't', - default => '' - }, - - { - name => 'lxr_root', - type => 't', - default => '', - } ); - return @param_list; -} - -1; diff --git a/Bugzilla/Install/Localconfig.pm b/Bugzilla/Install/Localconfig.pm index d4d1311cc..7f473cc77 100644 --- a/Bugzilla/Install/Localconfig.pm +++ b/Bugzilla/Install/Localconfig.pm @@ -100,10 +100,6 @@ use constant LOCALCONFIG_VARS => ( name => 'index_html', default => 0, }, - { - name => 'cvsbin', - default => sub { bin_loc('cvs') }, - }, { name => 'interdiffbin', default => sub { bin_loc('interdiff') }, -- cgit v1.2.3-24-g4f1b