1153
if ($self->ra->can_do_switch) {
1154
print STDERR "Following parent with do_switch\n";
1155
# do_switch works with svn/trunk >= r22312, but that
1156
- # is not included with SVN 1.4.2 (the latest version
1156
+ # is not included with SVN 1.4.3 (the latest version
1157
# at the moment), so we can't rely on it
1158
$self->{last_commit} = $parent;
1159
$ed = SVN::Git::Fetcher->new($self);
1621
1622
sub git_path {
1623
my ($self, $path) = @_;
1624
- $path =~ s!$self->{path_strip}!! if $self->{path_strip};
1624
+ if ($self->{path_strip}) {
1625
+ $path =~ s!$self->{path_strip}!! or
1626
+ die "Failed to strip path '$path' ($self->{path_strip})\n";
1627
+ }
1628
$path;
1629
}
1630
2252
my ($self, $rev_a, $rev_b, $path, $recurse, $editor) = @_;
2253
my $pool = SVN::Pool->new;
2254
$editor->set_path_strip($path);
2252
- my $reporter = $self->do_update($rev_b, $path, $recurse,
2253
- $editor, $pool);
2255
+ my (@pc) = split m#/#, $path;
2256
+ my $reporter = $self->do_update($rev_b, (@pc ? shift @pc : ''),
2257
+ $recurse, $editor, $pool);
2258
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
2259
+
2260
+ # Since we can't rely on svn_ra_reparent being available, we'll
2261
+ # just have to do some magic with set_path to make it so
2262
+ # we only want a partial path.
2263
+ my $sp = '';
2264
+ my $final = join('/', @pc);
2265
+ while (@pc) {
2266
+ $reporter->set_path($sp, $rev_b, 0, @lock, $pool);
2267
+ $sp .= '/' if length $sp;
2268
+ $sp .= shift @pc;
2269
+ }
2270
+ die "BUG: '$sp' != '$final'\n" if ($sp ne $final);
2271
+
2272
my $new = ($rev_a == $rev_b);
2256
- $reporter->set_path('', $rev_a, $new, @lock, $pool);
2273
+ $reporter->set_path($sp, $rev_a, $new, @lock, $pool);
2274
+
2275
$reporter->finish_report($pool);
2276
$pool->clear;
2277
$editor->{git_commit_ok};
2278
}
2279
2280
+# this requires SVN 1.4.3 or later (do_switch didn't work before 1.4.3, and
2281
+# svn_ra_reparent didn't work before 1.4)
2282
sub gs_do_switch {
2283
my ($self, $rev_a, $rev_b, $path, $recurse, $url_b, $editor) = @_;
2284
my $pool = SVN::Pool->new;
2265
- $editor->set_path_strip($path);
2266
- my $reporter = $self->do_switch($rev_b, $path, $recurse,
2267
- $url_b, $editor, $pool);
2285
+
2286
+ my $full_url = $self->{url};
2287
+ my $old_url = $full_url;
2288
+ $full_url .= "/$path" if length $path;
2289
+ SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
2290
+ $self->{url} = $full_url;
2291
+
2292
+ my $reporter = $self->do_switch($rev_b, '',
2293
+ $recurse, $url_b, $editor, $pool);
2294
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
2295
$reporter->set_path('', $rev_a, 0, @lock, $pool);
2296
$reporter->finish_report($pool);
2297
+
2298
+ SVN::_Ra::svn_ra_reparent($self->{session}, $old_url, $pool);
2299
+ $self->{url} = $old_url;
2300
+
2301
$pool->clear;
2302
$editor->{git_commit_ok};
2303
}