git-svn: prepare SVN::Ra config pieces once
Memoizing these initialization functions saves some memory for long fetches which require scanning many unwanted revisions before any wanted revisions happen. Signed-off-by: Eric Wong <normalperson@yhbt.net>maint
parent
822aaf0f08
commit
835e3ddeff
|
@ -2,6 +2,7 @@ package Git::SVN::Ra;
|
||||||
use vars qw/@ISA $config_dir $_ignore_refs_regex $_log_window_size/;
|
use vars qw/@ISA $config_dir $_ignore_refs_regex $_log_window_size/;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use Memoize;
|
||||||
use SVN::Client;
|
use SVN::Client;
|
||||||
use Git::SVN::Utils qw(
|
use Git::SVN::Utils qw(
|
||||||
canonicalize_url
|
canonicalize_url
|
||||||
|
@ -76,21 +77,13 @@ sub _auth_providers () {
|
||||||
\@rv;
|
\@rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prepare_config_once {
|
||||||
sub new {
|
|
||||||
my ($class, $url) = @_;
|
|
||||||
$url = canonicalize_url($url);
|
|
||||||
return $RA if ($RA && $RA->url eq $url);
|
|
||||||
|
|
||||||
::_req_svn();
|
|
||||||
|
|
||||||
SVN::_Core::svn_config_ensure($config_dir, undef);
|
SVN::_Core::svn_config_ensure($config_dir, undef);
|
||||||
my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
|
my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
|
||||||
my $config = SVN::Core::config_get_config($config_dir);
|
my $config = SVN::Core::config_get_config($config_dir);
|
||||||
$RA = undef;
|
|
||||||
my $dont_store_passwords = 1;
|
my $dont_store_passwords = 1;
|
||||||
my $conf_t = ${$config}{'config'};
|
my $conf_t = $config->{'config'};
|
||||||
{
|
|
||||||
no warnings 'once';
|
no warnings 'once';
|
||||||
# The usage of $SVN::_Core::SVN_CONFIG_* variables
|
# The usage of $SVN::_Core::SVN_CONFIG_* variables
|
||||||
# produces warnings that variables are used only once.
|
# produces warnings that variables are used only once.
|
||||||
|
@ -110,8 +103,24 @@ sub new {
|
||||||
1) == 0) {
|
1) == 0) {
|
||||||
$Git::SVN::Prompt::_no_auth_cache = 1;
|
$Git::SVN::Prompt::_no_auth_cache = 1;
|
||||||
}
|
}
|
||||||
} # no warnings 'once'
|
|
||||||
|
|
||||||
|
return ($config, $baton, $callbacks);
|
||||||
|
} # no warnings 'once'
|
||||||
|
|
||||||
|
INIT {
|
||||||
|
Memoize::memoize '_auth_providers';
|
||||||
|
Memoize::memoize 'prepare_config_once';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, $url) = @_;
|
||||||
|
$url = canonicalize_url($url);
|
||||||
|
return $RA if ($RA && $RA->url eq $url);
|
||||||
|
|
||||||
|
::_req_svn();
|
||||||
|
|
||||||
|
$RA = undef;
|
||||||
|
my ($config, $baton, $callbacks) = prepare_config_once();
|
||||||
my $self = SVN::Ra->new(url => $url, auth => $baton,
|
my $self = SVN::Ra->new(url => $url, auth => $baton,
|
||||||
config => $config,
|
config => $config,
|
||||||
pool => SVN::Pool->new,
|
pool => SVN::Pool->new,
|
||||||
|
|
Loading…
Reference in New Issue