git svn: delay importing SVN::Base until it is needed
Importing functions from a .dll into Git for Windows' perl is pretty slow, so let's avoid importing if it is not necessary. This seems particularly slow in virtualized enviroments. Before this change (on my machine): $ time perl /libexec/git-core/git-svn rebase Current branch master is up to date. real 2m56.750s user 0m3.129s sys 2m39.232s Afterwards: $ time perl /libexec/git-core/git-svn rebase Current branch master is up to date. real 0m33.407s user 0m1.409s sys 0m23.054s git svn rebase -n goes from 3m7.046s to 0m10.312s. Signed-off-by: Josh Robb <josh_robb@fastmail.fm> Acked-by: Eric Wong <normalperson@yhbt.net>
josh robb committed
Feb 24, 2010 at 16:13 UTC
d32fad2b89c81ca29128722e0e2f5985426e5e7a
1 file changed
+11
-5
git-svn.perl
+11
-5
@@ -36,11 +36,13 @@ $ENV{TZ} = 'UTC';
36
$| = 1; # unbuffer STDOUT
37
38
sub fatal (@) { print STDERR "@_\n"; exit 1 }
39
-require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
40
-require SVN::Ra;
41
-require SVN::Delta;
42
-if ($SVN::Core::VERSION lt '1.1.0') {
43
- fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
39
+sub _req_svn {
40
+ require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
41
+ require SVN::Ra;
42
+ require SVN::Delta;
43
+ if ($SVN::Core::VERSION lt '1.1.0') {
44
+ fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
45
+ }
46
}
47
my $can_compress = eval { require Compress::Zlib; 1};
48
push @Git::SVN::Ra::ISA, 'SVN::Ra';
@@ -730,6 +732,8 @@ sub cmd_branch {
732
$src=~s/^http:/https:/;
733
}
734
735
+ ::_req_svn();
736
+
737
my $ctx = SVN::Client->new(
738
auth => Git::SVN::Ra::_auth_providers(),
739
log_msg => sub {
@@ -4859,6 +4863,8 @@ sub new {
4863
$url =~ s!/+$!!;
4864
return $RA if ($RA && $RA->{url} eq $url);
4865
4866
+ ::_req_svn();
4867
+
4868
SVN::_Core::svn_config_ensure($config_dir, undef);
4869
my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
4870
my $config = SVN::Core::config_get_config($config_dir);