git-svn: reuse open SVN::Ra connections by URL
Note: this can cause problems with Perl's reference counting GC, so I'm disabling Git::SVN::Ra::DESTROY. If we notice more problems down the line, we can disable this enhancement. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Jan 18, 2007 at 18:22 UTC
f6f0987646069bff3a7674aca257fd84f939d960
1 file changed
+6
-4
git-svn.perl
+6
-4
@@ -2015,6 +2015,7 @@ use vars qw/@ISA $config_dir/;
2015
use strict;
2016
use warnings;
2017
my ($can_do_switch);
2018
+my %RA;
2019
2020
BEGIN {
2021
# enforce temporary pool usage for some simple functions
@@ -2033,6 +2034,9 @@ BEGIN {
2034
2035
sub new {
2036
my ($class, $url) = @_;
2037
+ $url =~ s!/+$!!;
2038
+ return $RA{$url} if $RA{$url};
2039
+
2040
SVN::_Core::svn_config_ensure($config_dir, undef);
2041
my ($baton, $callbacks) = SVN::Core::auth_open_helper([
2042
SVN::Client::get_simple_provider(),
@@ -2057,13 +2061,11 @@ sub new {
2061
$self->{svn_path} = $url;
2062
$self->{repos_root} = $self->get_repos_root;
2063
$self->{svn_path} =~ s#^\Q$self->{repos_root}\E/*##;
2060
- bless $self, $class;
2064
+ $RA{$url} = bless $self, $class;
2065
}
2066
2067
sub DESTROY {
2064
- my $self = shift;
2065
- $self->{pool}->clear if $self->{pool};
2066
- $self->SUPER::DESTROY(@_);
2068
+ # do not call the real DESTROY since we store ourselves in %RA
2069
}
2070
2071
sub dup {