Merge branch 'jk/maint-http-init-not-in-result-handler'
[gitweb.git] / perl / Git / SVN.pm
index d0087b2897dcec7a21d2b8c406499ab3427bcb8a..59215fa86e2c2902ec97b12bea70736f9c7c02c6 100644 (file)
@@ -460,7 +460,6 @@ sub new {
        }
        {
                my $path = $self->path;
-               $path =~ s{/+}{/}g;
                $path =~ s{\A/}{};
                $path =~ s{/\z}{};
                $self->path($path);
@@ -1635,6 +1634,24 @@ sub tie_for_persistent_memoization {
                Memoize::unmemoize 'has_no_changes';
        }
 
+       sub clear_memoized_mergeinfo_caches {
+               die "Only call this method in non-memoized context" if ($memoized);
+
+               my $cache_path = "$ENV{GIT_DIR}/svn/.caches/";
+               return unless -d $cache_path;
+
+               for my $cache_file (("$cache_path/lookup_svn_merge",
+                                    "$cache_path/check_cherry_pick",
+                                    "$cache_path/has_no_changes")) {
+                       for my $suffix (qw(yaml db)) {
+                               my $file = "$cache_file.$suffix";
+                               next unless -e $file;
+                               unlink($file) or die "unlink($file) failed: $!\n";
+                       }
+               }
+       }
+
+
        Memoize::memoize 'Git::SVN::repos_root';
 }
 
@@ -1662,7 +1679,6 @@ sub parents_exclude {
                                if ( $commit eq $excluded ) {
                                        push @excluded, $commit;
                                        $found++;
-                                       last;
                                }
                                else {
                                        push @new, $commit;
@@ -1696,14 +1712,14 @@ sub find_extra_svn_parents {
        my @merge_tips;
        my $url = $self->url;
        my $uuid = $self->ra_uuid;
-       my %ranges;
+       my @all_ranges;
        for my $merge ( @merges ) {
                my ($tip_commit, @ranges) =
                        lookup_svn_merge( $uuid, $url, $merge );
                unless (!$tip_commit or
                                grep { $_ eq $tip_commit } @$parents ) {
                        push @merge_tips, $tip_commit;
-                       $ranges{$tip_commit} = \@ranges;
+                       push @all_ranges, @ranges;
                } else {
                        push @merge_tips, undef;
                }
@@ -1718,8 +1734,6 @@ sub find_extra_svn_parents {
                my $spec = shift @merges;
                next unless $merge_tip and $excluded{$merge_tip};
 
-               my $ranges = $ranges{$merge_tip};
-
                # check out 'new' tips
                my $merge_base;
                eval {
@@ -1741,7 +1755,7 @@ sub find_extra_svn_parents {
                my (@incomplete) = check_cherry_pick(
                        $merge_base, $merge_tip,
                        $parents,
-                       @$ranges,
+                       @all_ranges,
                       );
 
                if ( @incomplete ) {
@@ -2127,8 +2141,13 @@ sub rev_map_set {
 
        sysopen(my $fh, $db_lock, O_RDWR | O_CREAT)
             or croak "Couldn't open $db_lock: $!\n";
-       $update_ref eq 'reset' ? _rev_map_reset($fh, $rev, $commit) :
-                                _rev_map_set($fh, $rev, $commit);
+       if ($update_ref eq 'reset') {
+               clear_memoized_mergeinfo_caches();
+               _rev_map_reset($fh, $rev, $commit);
+       } else {
+               _rev_map_set($fh, $rev, $commit);
+       }
+
        if ($sync) {
                $fh->flush or die "Couldn't flush $db_lock: $!\n";
                $fh->sync or die "Couldn't sync $db_lock: $!\n";
@@ -2312,11 +2331,11 @@ sub path {
 
        if (@_) {
                my $path = shift;
-               $self->{path} = canonicalize_path($path);
+               $self->{_path} = canonicalize_path($path);
                return;
        }
 
-       return $self->{path};
+       return $self->{_path};
 }
 
 sub url {