Skip to content

Commit fcf04ee

Browse files
committed
Merge branch 'ew/svn-fixes'
* ew/svn-fixes: git-svn: lazy load some modules
2 parents a6f9dec + 28ed7b0 commit fcf04ee

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

git-svn.perl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
$VERSION = '@@GIT_VERSION@@';
1212

1313
use Carp qw/croak/;
14-
use Digest::MD5;
15-
use IO::File qw//;
1614
use File::Basename qw/dirname basename/;
1715
use File::Path qw/mkpath/;
1816
use File::Spec;
19-
use File::Find;
2017
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
21-
use IPC::Open3;
2218
use Memoize;
2319

2420
use Git::SVN;
@@ -298,7 +294,6 @@ sub _req_svn {
298294
{} ],
299295
);
300296

301-
use Term::ReadLine;
302297
package FakeTerm;
303298
sub new {
304299
my ($class, $reason) = @_;
@@ -313,6 +308,7 @@ package main;
313308
my $term;
314309
sub term_init {
315310
$term = eval {
311+
require Term::ReadLine;
316312
$ENV{"GIT_SVN_NOTTY"}
317313
? new Term::ReadLine 'git-svn', \*STDIN, \*STDOUT
318314
: new Term::ReadLine 'git-svn';
@@ -1173,6 +1169,7 @@ sub cmd_branch {
11731169
}
11741170

11751171
::_req_svn();
1172+
require SVN::Client;
11761173

11771174
my $ctx = SVN::Client->new(
11781175
config => SVN::Core::config_get_config(
@@ -1693,11 +1690,13 @@ sub cmd_reset {
16931690
}
16941691

16951692
sub cmd_gc {
1693+
require File::Find;
16961694
if (!can_compress()) {
16971695
warn "Compress::Zlib could not be found; unhandled.log " .
16981696
"files will not be compressed.\n";
16991697
}
1700-
find({ wanted => \&gc_directory, no_chdir => 1}, "$ENV{GIT_DIR}/svn");
1698+
File::Find::find({ wanted => \&gc_directory, no_chdir => 1},
1699+
"$ENV{GIT_DIR}/svn");
17011700
}
17021701

17031702
########################### utility functions #########################
@@ -2122,6 +2121,7 @@ sub find_file_type_and_diff_status {
21222121
sub md5sum {
21232122
my $arg = shift;
21242123
my $ref = ref $arg;
2124+
require Digest::MD5;
21252125
my $md5 = Digest::MD5->new();
21262126
if ($ref eq 'GLOB' || $ref eq 'IO::File' || $ref eq 'File::Temp') {
21272127
$md5->addfile($arg) or croak $!;
@@ -2148,6 +2148,7 @@ sub gc_directory {
21482148
$gz->gzwrite($str) or
21492149
die "Unable to write: ".$gz->gzerror()."!\n";
21502150
}
2151+
no warnings 'once'; # $File::Find::name would warn
21512152
unlink $_ or die "unlink $File::Find::name: $!\n";
21522153
} elsif (-f $_ && basename($_) eq "index") {
21532154
unlink $_ or die "unlink $_: $!\n";

perl/Git/SVN.pm

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use vars qw/$_no_metadata
99
$_use_log_author $_add_author_from $_localtime/;
1010
use Carp qw/croak/;
1111
use File::Path qw/mkpath/;
12-
use File::Copy qw/copy/;
1312
use IPC::Open3;
1413
use Memoize; # core since 5.8.0, Jul 2002
15-
use Memoize::Storable;
1614
use POSIX qw(:signal_h);
1715
use Time::Local;
1816

@@ -33,11 +31,7 @@ use Git::SVN::Utils qw(
3331
add_path_to_url
3432
);
3533

36-
my $can_use_yaml;
37-
BEGIN {
38-
$can_use_yaml = eval { require Git::SVN::Memoize::YAML; 1};
39-
}
40-
34+
my $memo_backend;
4135
our $_follow_parent = 1;
4236
our $_minimize_url = 'unset';
4337
our $default_repo_id = 'svn';
@@ -1579,7 +1573,16 @@ sub tie_for_persistent_memoization {
15791573
my $hash = shift;
15801574
my $path = shift;
15811575

1582-
if ($can_use_yaml) {
1576+
unless ($memo_backend) {
1577+
if (eval { require Git::SVN::Memoize::YAML; 1}) {
1578+
$memo_backend = 1;
1579+
} else {
1580+
require Memoize::Storable;
1581+
$memo_backend = -1;
1582+
}
1583+
}
1584+
1585+
if ($memo_backend > 0) {
15831586
tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml";
15841587
} else {
15851588
tie %$hash => 'Memoize::Storable', "$path.db", 'nstore';
@@ -2189,8 +2192,9 @@ sub rev_map_set {
21892192
# both of these options make our .rev_db file very, very important
21902193
# and we can't afford to lose it because rebuild() won't work
21912194
if ($self->use_svm_props || $self->no_metadata) {
2195+
require File::Copy;
21922196
$sync = 1;
2193-
copy($db, $db_lock) or die "rev_map_set(@_): ",
2197+
File::Copy::copy($db, $db_lock) or die "rev_map_set(@_): ",
21942198
"Failed to copy: ",
21952199
"$db => $db_lock ($!)\n";
21962200
} else {

perl/Git/SVN/Editor.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use warnings;
55
use SVN::Core;
66
use SVN::Delta;
77
use Carp qw/croak/;
8-
use IO::File;
98
use Git qw/command command_oneline command_noisy command_output_pipe
109
command_input_pipe command_close_pipe
1110
command_bidi_pipe command_close_bidi_pipe/;
@@ -586,7 +585,7 @@ The interface will change as git-svn evolves.
586585
=head1 DEPENDENCIES
587586
588587
Subversion perl bindings,
589-
the core L<Carp> and L<IO::File> modules,
588+
the core L<Carp> module,
590589
and git's L<Git> helper module.
591590
592591
C<Git::SVN::Editor> has not been tested using callers other than

perl/Git/SVN/Fetcher.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use warnings;
77
use SVN::Delta;
88
use Carp qw/croak/;
99
use File::Basename qw/dirname/;
10-
use IO::File qw//;
1110
use Git qw/command command_oneline command_noisy command_output_pipe
1211
command_input_pipe command_close_pipe
1312
command_bidi_pipe command_close_bidi_pipe/;
@@ -608,7 +607,7 @@ developing git-svn.
608607
=head1 DEPENDENCIES
609608
610609
L<SVN::Delta> from the Subversion perl bindings,
611-
the core L<Carp>, L<File::Basename>, and L<IO::File> modules,
610+
the core L<Carp> and L<File::Basename> modules,
612611
and git's L<Git> helper module.
613612
614613
C<Git::SVN::Fetcher> has not been tested using callers other than

perl/Git/SVN/Ra.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use vars qw/@ISA $config_dir $_ignore_refs_regex $_log_window_size/;
33
use strict;
44
use warnings;
55
use Memoize;
6-
use SVN::Client;
76
use Git::SVN::Utils qw(
87
canonicalize_url
98
canonicalize_path
@@ -42,6 +41,7 @@ END {
4241
}
4342

4443
sub _auth_providers () {
44+
require SVN::Client;
4545
my @rv = (
4646
SVN::Client::get_simple_provider(),
4747
SVN::Client::get_ssl_server_trust_file_provider(),
@@ -247,7 +247,10 @@ sub get_log {
247247
$ret;
248248
}
249249

250+
# uncommon, only for ancient SVN (<= 1.4.2)
250251
sub trees_match {
252+
require IO::File;
253+
require SVN::Client;
251254
my ($self, $url1, $rev1, $url2, $rev2) = @_;
252255
my $ctx = SVN::Client->new(auth => _auth_providers);
253256
my $out = IO::File->new_tmpfile;

0 commit comments

Comments
 (0)