From 28654678cff4c7b78f87a6768a896d76a1784d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 3 Mar 2018 15:38:13 +0000 Subject: perl: move CPAN loader wrappers to another namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the Git::Error and Git::Mail::Address wrappers to the Git::LoadCPAN::Loader::* namespace, e.g. Git::LoadCPAN::Error. That module will then either load Error from CPAN (if installed on the OS), or use Git::FromCPAN::Error. When I added the Error wrapper in 20d2a30f8f ("Makefile: replace perl/Makefile.PL with simple make rules", 2017-12-10) I didn't think about how confusing it would be to have these modules sitting in the same tree as our normal modules. Let's put these all into Git::{Load,From}CPAN::* to clearly distinguish them from the rest. This also makes things a bit less confusing since there was already a Git::Error namespace ever since 8b9150e3e3 ("Git.pm: Handle failed commands' output", 2006-06-24). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- perl/Git.pm | 2 +- perl/Git/Error.pm | 46 --------------------------------------- perl/Git/LoadCPAN/Error.pm | 46 +++++++++++++++++++++++++++++++++++++++ perl/Git/LoadCPAN/Mail/Address.pm | 24 ++++++++++++++++++++ perl/Git/Mail/Address.pm | 24 -------------------- 5 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 perl/Git/Error.pm create mode 100644 perl/Git/LoadCPAN/Error.pm create mode 100644 perl/Git/LoadCPAN/Mail/Address.pm delete mode 100644 perl/Git/Mail/Address.pm (limited to 'perl') diff --git a/perl/Git.pm b/perl/Git.pm index 151b0e7144..9f246c7988 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -104,7 +104,7 @@ increase notwithstanding). use Carp qw(carp croak); # but croak is bad - throw instead -use Git::Error qw(:try); +use Git::LoadCPAN::Error qw(:try); use Cwd qw(abs_path cwd); use IPC::Open2 qw(open2); use Fcntl qw(SEEK_SET SEEK_CUR); diff --git a/perl/Git/Error.pm b/perl/Git/Error.pm deleted file mode 100644 index 09bbc97390..0000000000 --- a/perl/Git/Error.pm +++ /dev/null @@ -1,46 +0,0 @@ -package Git::Error; -use 5.008; -use strict; -use warnings; - -=head1 NAME - -Git::Error - Wrapper for the L module, in case it's not installed - -=head1 DESCRIPTION - -Wraps the import function for the L module. - -This module is only intended to be used for code shipping in the -C repository. Use it for anything else at your peril! - -=cut - -sub import { - shift; - my $caller = caller; - - eval { - require Error; - 1; - } or do { - my $error = $@ || "Zombie Error"; - - my $Git_Error_pm_path = $INC{"Git/Error.pm"} || die "BUG: Should have our own path from %INC!"; - - require File::Basename; - my $Git_Error_pm_root = File::Basename::dirname($Git_Error_pm_path) || die "BUG: Can't figure out lib/Git dirname from '$Git_Error_pm_path'!"; - - require File::Spec; - my $Git_pm_FromCPAN_root = File::Spec->catdir($Git_Error_pm_root, 'FromCPAN'); - die "BUG: '$Git_pm_FromCPAN_root' should be a directory!" unless -d $Git_pm_FromCPAN_root; - - local @INC = ($Git_pm_FromCPAN_root, @INC); - require Error; - }; - - unshift @_, $caller; - goto &Error::import; -} - -1; diff --git a/perl/Git/LoadCPAN/Error.pm b/perl/Git/LoadCPAN/Error.pm new file mode 100644 index 0000000000..3513fe745b --- /dev/null +++ b/perl/Git/LoadCPAN/Error.pm @@ -0,0 +1,46 @@ +package Git::LoadCPAN::Error; +use 5.008; +use strict; +use warnings; + +=head1 NAME + +Git::LoadCPAN::Error - Wrapper for the L module, in case it's not installed + +=head1 DESCRIPTION + +Wraps the import function for the L module. + +This module is only intended to be used for code shipping in the +C repository. Use it for anything else at your peril! + +=cut + +sub import { + shift; + my $caller = caller; + + eval { + require Error; + 1; + } or do { + my $error = $@ || "Zombie Error"; + + my $Git_Error_pm_path = $INC{"Git/LoadCPAN/Error.pm"} || die "BUG: Should have our own path from %INC!"; + + require File::Basename; + my $Git_Error_pm_root = File::Basename::dirname($Git_Error_pm_path) || die "BUG: Can't figure out lib/Git dirname from '$Git_Error_pm_path'!"; + + require File::Spec; + my $Git_pm_FromCPAN_root = File::Spec->catdir($Git_Error_pm_root, '..', 'FromCPAN'); + die "BUG: '$Git_pm_FromCPAN_root' should be a directory!" unless -d $Git_pm_FromCPAN_root; + + local @INC = ($Git_pm_FromCPAN_root, @INC); + require Error; + }; + + unshift @_, $caller; + goto &Error::import; +} + +1; diff --git a/perl/Git/LoadCPAN/Mail/Address.pm b/perl/Git/LoadCPAN/Mail/Address.pm new file mode 100644 index 0000000000..879c2f5cd1 --- /dev/null +++ b/perl/Git/LoadCPAN/Mail/Address.pm @@ -0,0 +1,24 @@ +package Git::LoadCPAN::Mail::Address; +use 5.008; +use strict; +use warnings; + +=head1 NAME + +Git::LoadCPAN::Mail::Address - Wrapper for the L module, in case it's not installed + +=head1 DESCRIPTION + +This module is only intended to be used for code shipping in the +C repository. Use it for anything else at your peril! + +=cut + +eval { + require Mail::Address; + 1; +} or do { + require Git::FromCPAN::Mail::Address; +}; + +1; diff --git a/perl/Git/Mail/Address.pm b/perl/Git/Mail/Address.pm deleted file mode 100644 index 2ce3e84670..0000000000 --- a/perl/Git/Mail/Address.pm +++ /dev/null @@ -1,24 +0,0 @@ -package Git::Mail::Address; -use 5.008; -use strict; -use warnings; - -=head1 NAME - -Git::Mail::Address - Wrapper for the L module, in case it's not installed - -=head1 DESCRIPTION - -This module is only intended to be used for code shipping in the -C repository. Use it for anything else at your peril! - -=cut - -eval { - require Mail::Address; - 1; -} or do { - require Git::FromCPAN::Mail::Address; -}; - -1; -- cgit v1.2.1