Merge git://git.bogomips.org/git-svn
* git://git.bogomips.org/git-svn: Move initialization of Git::SVN variables into Git::SVN. Extract Git::SVN from git-svn into its own .pm file. Prepare Git::SVN for extraction into its own file. Extract some utilities from git-svn to allow extracting Git::SVN. perl: detect new files in MakeMaker builds The Makefile.PL will now find .pm files itself. Don't lose Error.pm if $@ gets clobbered. Quiet warning if Makefile.PL is run with -w and no --localedir
This commit is contained in:
commit
646e417535
7
Makefile
7
Makefile
@ -2090,6 +2090,13 @@ $(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
|
||||
ifndef NO_PERL
|
||||
$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
|
||||
|
||||
perl/perl.mak: perl/PM.stamp
|
||||
|
||||
perl/PM.stamp: FORCE
|
||||
$(QUIET_GEN)find perl -type f -name '*.pm' | sort >$@+ && \
|
||||
{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \
|
||||
$(RM) $@+
|
||||
|
||||
perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
|
||||
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
|
||||
|
||||
|
2340
git-svn.perl
2340
git-svn.perl
File diff suppressed because it is too large
Load Diff
1
perl/.gitignore
vendored
1
perl/.gitignore
vendored
@ -5,3 +5,4 @@ MYMETA.yml
|
||||
blib
|
||||
blibdirs
|
||||
pm_to_blib
|
||||
PM.stamp
|
||||
|
2324
perl/Git/SVN.pm
Normal file
2324
perl/Git/SVN.pm
Normal file
File diff suppressed because it is too large
Load Diff
59
perl/Git/SVN/Utils.pm
Normal file
59
perl/Git/SVN/Utils.pm
Normal file
@ -0,0 +1,59 @@
|
||||
package Git::SVN::Utils;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base qw(Exporter);
|
||||
|
||||
our @EXPORT_OK = qw(fatal can_compress);
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Git::SVN::Utils - utility functions used across Git::SVN
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Git::SVN::Utils qw(functions to import);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module contains functions which are useful across many different
|
||||
parts of Git::SVN. Mostly it's a place to put utility functions
|
||||
rather than duplicate the code or have classes grabbing at other
|
||||
classes.
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
All functions can be imported only on request.
|
||||
|
||||
=head3 fatal
|
||||
|
||||
fatal(@message);
|
||||
|
||||
Display a message and exit with a fatal error code.
|
||||
|
||||
=cut
|
||||
|
||||
# Note: not certain why this is in use instead of die. Probably because
|
||||
# the exit code of die is 255? Doesn't appear to be used consistently.
|
||||
sub fatal (@) { print STDERR "@_\n"; exit 1 }
|
||||
|
||||
|
||||
=head3 can_compress
|
||||
|
||||
my $can_compress = can_compress;
|
||||
|
||||
Returns true if Compress::Zlib is available, false otherwise.
|
||||
|
||||
=cut
|
||||
|
||||
my $can_compress;
|
||||
sub can_compress {
|
||||
return $can_compress if defined $can_compress;
|
||||
|
||||
return $can_compress = eval { require Compress::Zlib; };
|
||||
}
|
||||
|
||||
|
||||
1;
|
@ -20,17 +20,22 @@ clean:
|
||||
$(RM) ppport.h
|
||||
$(RM) $(makfile)
|
||||
$(RM) $(makfile).old
|
||||
$(RM) PM.stamp
|
||||
|
||||
$(makfile): PM.stamp
|
||||
|
||||
ifdef NO_PERL_MAKEMAKER
|
||||
instdir_SQ = $(subst ','\'',$(prefix)/lib)
|
||||
|
||||
modules += Git
|
||||
modules += Git/I18N
|
||||
modules += Git/SVN
|
||||
modules += Git/SVN/Memoize/YAML
|
||||
modules += Git/SVN/Fetcher
|
||||
modules += Git/SVN/Editor
|
||||
modules += Git/SVN/Prompt
|
||||
modules += Git/SVN/Ra
|
||||
modules += Git/SVN/Utils
|
||||
|
||||
$(makfile): ../GIT-CFLAGS Makefile
|
||||
echo all: private-Error.pm Git.pm Git/I18N.pm > $@
|
||||
|
@ -2,11 +2,16 @@ use strict;
|
||||
use warnings;
|
||||
use ExtUtils::MakeMaker;
|
||||
use Getopt::Long;
|
||||
use File::Find;
|
||||
|
||||
# Don't forget to update the perl/Makefile, too.
|
||||
# Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
|
||||
|
||||
# Sanity: die at first unknown option
|
||||
Getopt::Long::Configure qw/ pass_through /;
|
||||
|
||||
GetOptions("localedir=s" => \my $localedir);
|
||||
my $localedir = '';
|
||||
GetOptions("localedir=s" => \$localedir);
|
||||
|
||||
sub MY::postamble {
|
||||
return <<'MAKE_FRAG';
|
||||
@ -24,24 +29,22 @@ endif
|
||||
MAKE_FRAG
|
||||
}
|
||||
|
||||
# XXX. When editing this list:
|
||||
#
|
||||
# * Please update perl/Makefile, too.
|
||||
# * Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
|
||||
my %pm = (
|
||||
'Git.pm' => '$(INST_LIBDIR)/Git.pm',
|
||||
'Git/I18N.pm' => '$(INST_LIBDIR)/Git/I18N.pm',
|
||||
'Git/SVN/Memoize/YAML.pm' => '$(INST_LIBDIR)/Git/SVN/Memoize/YAML.pm',
|
||||
'Git/SVN/Fetcher.pm' => '$(INST_LIBDIR)/Git/SVN/Fetcher.pm',
|
||||
'Git/SVN/Editor.pm' => '$(INST_LIBDIR)/Git/SVN/Editor.pm',
|
||||
'Git/SVN/Prompt.pm' => '$(INST_LIBDIR)/Git/SVN/Prompt.pm',
|
||||
'Git/SVN/Ra.pm' => '$(INST_LIBDIR)/Git/SVN/Ra.pm',
|
||||
);
|
||||
# Find all the .pm files in "Git/" and Git.pm
|
||||
my %pm;
|
||||
find sub {
|
||||
return unless /\.pm$/;
|
||||
|
||||
# sometimes File::Find prepends a ./ Strip it.
|
||||
my $pm_path = $File::Find::name;
|
||||
$pm_path =~ s{^\./}{};
|
||||
|
||||
$pm{$pm_path} = '$(INST_LIBDIR)/'.$pm_path;
|
||||
}, "Git", "Git.pm";
|
||||
|
||||
|
||||
# We come with our own bundled Error.pm. It's not in the set of default
|
||||
# Perl modules so install it if it's not available on the system yet.
|
||||
eval { require Error };
|
||||
if ($@ || $Error::VERSION < 0.15009) {
|
||||
if ( !eval { require Error } || $Error::VERSION < 0.15009) {
|
||||
$pm{'private-Error.pm'} = '$(INST_LIBDIR)/Error.pm';
|
||||
}
|
||||
|
||||
|
9
t/Git-SVN/00compile.t
Normal file
9
t/Git-SVN/00compile.t
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 2;
|
||||
|
||||
require_ok 'Git::SVN::Utils';
|
||||
require_ok 'Git::SVN';
|
11
t/Git-SVN/Utils/can_compress.t
Normal file
11
t/Git-SVN/Utils/can_compress.t
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More 'no_plan';
|
||||
|
||||
use Git::SVN::Utils qw(can_compress);
|
||||
|
||||
# !! is the "convert this to boolean" operator.
|
||||
is !!can_compress(), !!eval { require Compress::Zlib };
|
34
t/Git-SVN/Utils/fatal.t
Normal file
34
t/Git-SVN/Utils/fatal.t
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More 'no_plan';
|
||||
|
||||
BEGIN {
|
||||
# Override exit at BEGIN time before Git::SVN::Utils is loaded
|
||||
# so it will see our local exit later.
|
||||
*CORE::GLOBAL::exit = sub(;$) {
|
||||
return @_ ? CORE::exit($_[0]) : CORE::exit();
|
||||
};
|
||||
}
|
||||
|
||||
use Git::SVN::Utils qw(fatal);
|
||||
|
||||
# fatal()
|
||||
{
|
||||
# Capture the exit code and prevent exit.
|
||||
my $exit_status;
|
||||
no warnings 'redefine';
|
||||
local *CORE::GLOBAL::exit = sub { $exit_status = $_[0] || 0 };
|
||||
|
||||
# Trap fatal's message to STDERR
|
||||
my $stderr;
|
||||
close STDERR;
|
||||
ok open STDERR, ">", \$stderr;
|
||||
|
||||
fatal "Some", "Stuff", "Happened";
|
||||
|
||||
is $stderr, "Some Stuff Happened\n";
|
||||
is $exit_status, 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user