Skip to content

Commit d32fad2

Browse files
joshrobbEric Wong
authored andcommitted
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>
1 parent 6a2009e commit d32fad2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

git-svn.perl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
$| = 1; # unbuffer STDOUT
3737

3838
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+
}
4446
}
4547
my $can_compress = eval { require Compress::Zlib; 1};
4648
push @Git::SVN::Ra::ISA, 'SVN::Ra';
@@ -730,6 +732,8 @@ sub cmd_branch {
730732
$src=~s/^http:/https:/;
731733
}
732734

735+
::_req_svn();
736+
733737
my $ctx = SVN::Client->new(
734738
auth => Git::SVN::Ra::_auth_providers(),
735739
log_msg => sub {
@@ -4859,6 +4863,8 @@ sub new {
48594863
$url =~ s!/+$!!;
48604864
return $RA if ($RA && $RA->{url} eq $url);
48614865

4866+
::_req_svn();
4867+
48624868
SVN::_Core::svn_config_ensure($config_dir, undef);
48634869
my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
48644870
my $config = SVN::Core::config_get_config($config_dir);

0 commit comments

Comments
 (0)