From: Junio C Hamano Date: Thu, 26 Feb 2015 22:03:57 +0000 (-0800) Subject: Merge branch 'svn-maint-fixes' into svn-fixes X-Git-Tag: v2.4.0-rc0~66^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/28ed7b02dd726bcc5c8d3fc316c965a3c0f05c04?ds=inline;hp=-c Merge branch 'svn-maint-fixes' into svn-fixes * svn-maint-fixes: Git::SVN::*: avoid premature FileHandle closure git-svn: fix localtime=true on non-glibc environments --- 28ed7b02dd726bcc5c8d3fc316c965a3c0f05c04 diff --combined perl/Git/SVN.pm index afa562c8b9,7006219c0a..152fb7e927 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@@ -9,9 -9,12 +9,10 @@@ use vars qw/$_no_metadat $_use_log_author $_add_author_from $_localtime/; use Carp qw/croak/; use File::Path qw/mkpath/; -use File::Copy qw/copy/; use IPC::Open3; use Memoize; # core since 5.8.0, Jul 2002 -use Memoize::Storable; use POSIX qw(:signal_h); + use Time::Local; use Git qw( command @@@ -30,7 -33,11 +31,7 @@@ use Git::SVN::Utils qw add_path_to_url ); -my $can_use_yaml; -BEGIN { - $can_use_yaml = eval { require Git::SVN::Memoize::YAML; 1}; -} - +my $memo_backend; our $_follow_parent = 1; our $_minimize_url = 'unset'; our $default_repo_id = 'svn'; @@@ -1326,7 -1333,7 +1327,7 @@@ sub parse_svn_date $ENV{TZ} = 'UTC'; my $epoch_in_UTC = - POSIX::strftime('%s', $S, $M, $H, $d, $m - 1, $Y - 1900); + Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y - 1900); # Determine our local timezone (including DST) at the # time of $epoch_in_UTC. $Git::SVN::Log::TZ stored the @@@ -1572,16 -1579,7 +1573,16 @@@ sub tie_for_persistent_memoization my $hash = shift; my $path = shift; - if ($can_use_yaml) { + unless ($memo_backend) { + if (eval { require Git::SVN::Memoize::YAML; 1}) { + $memo_backend = 1; + } else { + require Memoize::Storable; + $memo_backend = -1; + } + } + + if ($memo_backend > 0) { tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml"; } else { tie %$hash => 'Memoize::Storable', "$path.db", 'nstore'; @@@ -2191,9 -2189,8 +2192,9 @@@ sub rev_map_set # both of these options make our .rev_db file very, very important # and we can't afford to lose it because rebuild() won't work if ($self->use_svm_props || $self->no_metadata) { + require File::Copy; $sync = 1; - copy($db, $db_lock) or die "rev_map_set(@_): ", + File::Copy::copy($db, $db_lock) or die "rev_map_set(@_): ", "Failed to copy: ", "$db => $db_lock ($!)\n"; } else { @@@ -2369,7 -2366,7 +2370,7 @@@ sub _new # Older repos imported by us used $GIT_DIR/svn/foo instead of # $GIT_DIR/svn/refs/remotes/foo when tracking refs/remotes/foo - if ($ref_id =~ m{^refs/remotes/(.*)}) { + if ($ref_id =~ m{^refs/remotes/(.+)}) { my $old_dir = "$ENV{GIT_DIR}/svn/$1"; if (-d $old_dir && ! -d $dir) { $dir = $old_dir; diff --combined perl/Git/SVN/Fetcher.pm index 6b9c6e0138,613055a3f5..d8c21ad915 --- a/perl/Git/SVN/Fetcher.pm +++ b/perl/Git/SVN/Fetcher.pm @@@ -7,6 -7,7 +7,6 @@@ use warnings use SVN::Delta; use Carp qw/croak/; use File::Basename qw/dirname/; -use IO::File qw//; use Git qw/command command_oneline command_noisy command_output_pipe command_input_pipe command_close_pipe command_bidi_pipe command_close_bidi_pipe/; @@@ -321,6 -322,14 +321,14 @@@ sub apply_textdelta # (but $base does not,) so dup() it for reading in close_file open my $dup, '<&', $fh or croak $!; my $base = $::_repository->temp_acquire("git_blob_${$}_$suffix"); + # close_file may call temp_acquire on 'svn_hash', but because of the + # call chain, if the temp_acquire call from close_file ends up being the + # call that first creates the 'svn_hash' temp file, then the FileHandle + # that's created as a result will end up in an SVN::Pool that we clear + # in SVN::Ra::gs_fetch_loop_common. Avoid that by making sure the + # 'svn_hash' FileHandle is already created before close_file is called. + my $tmp_fh = $::_repository->temp_acquire('svn_hash'); + $::_repository->temp_release($tmp_fh, 1); if ($fb->{blob}) { my ($base_is_link, $size); @@@ -599,7 -608,7 +607,7 @@@ developing git-svn =head1 DEPENDENCIES L from the Subversion perl bindings, -the core L, L, and L modules, +the core L and L modules, and git's L helper module. C has not been tested using callers other than diff --combined perl/Git/SVN/Ra.pm index cf36b9d3cd,32e2f19ea4..4a499fcb38 --- a/perl/Git/SVN/Ra.pm +++ b/perl/Git/SVN/Ra.pm @@@ -3,6 -3,7 +3,6 @@@ use vars qw/@ISA $config_dir $_ignore_r use strict; use warnings; use Memoize; -use SVN::Client; use Git::SVN::Utils qw( canonicalize_url canonicalize_path @@@ -41,7 -42,6 +41,7 @@@ END } sub _auth_providers () { + require SVN::Client; my @rv = ( SVN::Client::get_simple_provider(), SVN::Client::get_ssl_server_trust_file_provider(), @@@ -247,10 -247,7 +247,10 @@@ sub get_log $ret; } +# uncommon, only for ancient SVN (<= 1.4.2) sub trees_match { + require IO::File; + require SVN::Client; my ($self, $url1, $rev1, $url2, $rev2) = @_; my $ctx = SVN::Client->new(auth => _auth_providers); my $out = IO::File->new_tmpfile; @@@ -394,6 -391,9 +394,9 @@@ sub longest_common_path sub gs_fetch_loop_common { my ($self, $base, $head, $gsv, $globs) = @_; return if ($base > $head); + # Make sure the cat_blob open2 FileHandle is created before calling + # SVN::Pool::new_default so that it does not incorrectly end up in the pool. + $::_repository->_open_cat_blob_if_needed; my $gpool = SVN::Pool->new_default; my $ra_url = $self->url; my $reload_ra = sub {