{"thread":{"id":"22787","subject":"[PATCH] git svn: delay importing SVN::Base until it is needed","startedAt":"2010-02-24T03:13:50Z","lastAt":"2010-02-24T03:13:50Z","messageCount":1,"participants":["josh robb"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"135518","messageId":"13237f021002231913m77d9bc0aqd045546da3cf5a95@mail.gmail.com","threadId":"22787","inReplyTo":null,"subject":"[PATCH] git svn: delay importing SVN::Base until it is needed","fromName":"josh robb","fromEmail":"josh_robb@fastmail.fm","sentAt":"2010-02-24T03:13:50Z","receivedAt":"2010-02-24T03:13:50Z","isPatch":true,"sender":{"key":"josh_robb@fastmail.fm","avatar":null},"body":"Importing functions from a .dll into Git for Windows' perl is pretty slow,\nso let's avoid importing if it is not necessary.\n\nThis seems particularly slow in virtualized enviroments. Before this\nchange (on my machine):\n\n$ time perl /libexec/git-core/git-svn rebase\nCurrent branch master is up to date.\n\nreal 2m56.750s\nuser 0m3.129s\nsys 2m39.232s\n\nAfterwards:\n\n$ time perl /libexec/git-core/git-svn rebase\nCurrent branch master is up to date.\n\nreal 0m33.407s\nuser 0m1.409s\nsys 0m23.054s\n\ngit svn rebase -n goes from 3m7.046s to 0m10.312s.\n\nSigned-off-by: Josh Robb <josh_robb@fastmail.fm>\n---\n git-svn.perl |   16 +++++++++++-----\n 1 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 265852f..0e4572f 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -36,11 +36,13 @@ $ENV{TZ} = 'UTC';\n $| = 1; # unbuffer STDOUT\n\n sub fatal (@) { print STDERR \"@_\\n\"; exit 1 }\n-require SVN::Core; # use()-ing this causes segfaults for me... *shrug*\n-require SVN::Ra;\n-require SVN::Delta;\n-if ($SVN::Core::VERSION lt '1.1.0') {\n-\tfatal \"Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)\";\n+sub _req_svn {\n+\trequire SVN::Core; # use()-ing this causes segfaults for me... *shrug*\n+\trequire SVN::Ra;\n+\trequire SVN::Delta;\n+\tif ($SVN::Core::VERSION lt '1.1.0') {\n+\t\tfatal \"Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)\";\n+\t}\n }\n my $can_compress = eval { require Compress::Zlib; 1};\n push @Git::SVN::Ra::ISA, 'SVN::Ra';\n@@ -730,6 +732,8 @@ sub cmd_branch {\n \t\t$src=~s/^http:/https:/;\n \t}\n\n+\t::_req_svn();\n+\n \tmy $ctx = SVN::Client->new(\n \t\tauth    => Git::SVN::Ra::_auth_providers(),\n \t\tlog_msg => sub {\n@@ -4859,6 +4863,8 @@ sub new {\n \t$url =~ s!/+$!!;\n \treturn $RA if ($RA && $RA->{url} eq $url);\n\n+\t::_req_svn();\n+\n \tSVN::_Core::svn_config_ensure($config_dir, undef);\n \tmy ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);\n \tmy $config = SVN::Core::config_get_config($config_dir);\n-- \n1.7.0\n"}]}