69
$_limit, $_verbose, $_incremental, $_oneline, $_l_fmt, $_show_commit,
70
$_version, $_upgrade, $_authors, $_branch_all_refs, @_opt_m,
71
$_merge, $_strategy, $_dry_run, $_ignore_nodate, $_non_recursive,
72
- $_username, $_config_dir, $_no_auth_cache, $_xfer_delta,
72
+ $_username, $_config_dir, $_no_auth_cache,
73
$_pager, $_color);
74
my (@_branch_from, %tree_map, %users, %rusers, %equiv);
75
my ($_svn_can_do_switch);
2044
config => $config,
2045
pool => SVN::Pool->new,
2046
auth_provider_callbacks => $callbacks);
2047
-
2048
- my $df = $ENV{GIT_SVN_DELTA_FETCH};
2049
- if (defined $df) {
2050
- $_xfer_delta = $df;
2051
- } else {
2052
- $_xfer_delta = ($url =~ m#^file://#) ? undef : 1;
2053
- }
2047
$ra->{svn_path} = $url;
2048
$ra->{repos_root} = $ra->get_repos_root;
2049
$ra->{svn_path} =~ s#^\Q$ra->{repos_root}\E/*##;
2075
auth auth_provider_callbacks repos_root svn_path/);
2076
}
2077
2085
-sub libsvn_get_file {
2086
- my ($gui, $f, $rev, $chg, $untracked) = @_;
2087
- $f =~ s#^/##;
2088
- print "\t$chg\t$f\n" unless $_q;
2089
-
2090
- my ($hash, $pid, $in, $out);
2091
- my $pool = SVN::Pool->new;
2092
- defined($pid = open3($in, $out, '>&STDERR',
2093
- qw/git-hash-object -w --stdin/)) or croak $!;
2094
- # redirect STDOUT for SVN 1.1.x compatibility
2095
- open my $stdout, '>&', \*STDOUT or croak $!;
2096
- open STDOUT, '>&', $in or croak $!;
2097
- my ($r, $props) = $SVN->get_file($f, $rev, \*STDOUT, $pool);
2098
- $in->flush == 0 or croak $!;
2099
- open STDOUT, '>&', $stdout or croak $!;
2100
- close $in or croak $!;
2101
- close $stdout or croak $!;
2102
- $pool->clear;
2103
- chomp($hash = do { local $/; <$out> });
2104
- close $out or croak $!;
2105
- waitpid $pid, 0;
2106
- $hash =~ /^$sha1$/o or die "not a sha1: $hash\n";
2107
-
2108
- my $mode = exists $props->{'svn:executable'} ? '100755' : '100644';
2109
- if (exists $props->{'svn:special'}) {
2110
- $mode = '120000';
2111
- my $link = `git-cat-file blob $hash`; # no chomping symlinks
2112
- $link =~ s/^link // or die "svn:special file with contents: <",
2113
- $link, "> is not understood\n";
2114
- defined($pid = open3($in, $out, '>&STDERR',
2115
- qw/git-hash-object -w --stdin/)) or croak $!;
2116
- print $in $link;
2117
- $in->flush == 0 or croak $!;
2118
- close $in or croak $!;
2119
- chomp($hash = do { local $/; <$out> });
2120
- close $out or croak $!;
2121
- waitpid $pid, 0;
2122
- $hash =~ /^$sha1$/o or die "not a sha1: $hash\n";
2123
- }
2124
- %{$untracked->{file_prop}->{$f}} = %$props;
2125
- print $gui $mode,' ',$hash,"\t",$f,"\0" or croak $!;
2126
-}
2127
-
2078
sub uri_encode {
2079
my ($f) = @_;
2080
$f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#uc sprintf("%%%02x",ord($1))#eg;
2182
}
2183
2184
sub libsvn_fetch {
2235
- $_xfer_delta ? libsvn_fetch_delta(@_) : libsvn_fetch_full(@_);
2236
-}
2237
-
2238
-sub libsvn_fetch_delta {
2185
my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
2186
my $pool = SVN::Pool->new;
2187
my $ed = SVN::Git::Fetcher->new({ c => $last_commit, q => $_q });
2197
libsvn_log_entry($rev, $author, $date, $msg, [$last_commit], $ed);
2198
}
2199
2254
-sub libsvn_fetch_full {
2255
- my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
2256
- my ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/);
2257
- my %amr;
2258
- my $ut = { empty => {}, dir_prop => {}, file_prop => {} };
2259
- my $p = $SVN->{svn_path};
2260
- foreach my $f (keys %$paths) {
2261
- my $m = $paths->{$f}->action();
2262
- if (length $p) {
2263
- $f =~ s#^/\Q$p\E/##;
2264
- next if $f =~ m#^/#;
2265
- } else {
2266
- $f =~ s#^/##;
2267
- }
2268
- if ($m =~ /^[DR]$/) {
2269
- my $t = process_rm($gui, $last_commit, $f, $_q);
2270
- if ($m eq 'D') {
2271
- $ut->{empty}->{$f} = 0 if $t == $SVN::Node::dir;
2272
- next;
2273
- }
2274
- # 'R' can be file replacements, too, right?
2275
- }
2276
- my $pool = SVN::Pool->new;
2277
- my $t = $SVN->check_path($f, $rev, $pool);
2278
- if ($t == $SVN::Node::file) {
2279
- if ($m =~ /^[AMR]$/) {
2280
- $amr{$f} = $m;
2281
- } else {
2282
- die "Unrecognized action: $m, ($f r$rev)\n";
2283
- }
2284
- } elsif ($t == $SVN::Node::dir && $m =~ /^[AR]$/) {
2285
- my @traversed = ();
2286
- libsvn_traverse($gui, '', $f, $rev, \@traversed, $ut);
2287
- if (@traversed) {
2288
- foreach (@traversed) {
2289
- $amr{$_} = $m;
2290
- }
2291
- } else {
2292
- my ($dir, $file) = ($f =~ m#^(.*?)/?([^/]+)$#);
2293
- delete $ut->{empty}->{$dir};
2294
- $ut->{empty}->{$f} = 1;
2295
- }
2296
- }
2297
- $pool->clear;
2298
- }
2299
- foreach (keys %amr) {
2300
- libsvn_get_file($gui, $_, $rev, $amr{$_}, $ut);
2301
- my ($d) = ($_ =~ m#^(.*?)/?(?:[^/]+)$#);
2302
- delete $ut->{empty}->{$d};
2303
- }
2304
- unless (exists $ut->{dir_prop}->{''}) {
2305
- my $pool = SVN::Pool->new;
2306
- my (undef, undef, $props) = $SVN->get_dir('', $rev, $pool);
2307
- %{$ut->{dir_prop}->{''}} = %$props;
2308
- $pool->clear;
2309
- }
2310
- command_close_pipe($gui, $ctx);
2311
- libsvn_log_entry($rev, $author, $date, $msg, [$last_commit], $ut);
2312
-}
2313
-
2200
sub svn_grab_base_rev {
2201
my $c = eval { command_oneline([qw/rev-parse --verify/,
2202
"refs/remotes/$GIT_SVN^0"],
2248
"Try using the command-line svn client instead\n";
2249
}
2250
2365
-sub libsvn_traverse {
2366
- my ($gui, $pfx, $path, $rev, $files, $untracked) = @_;
2367
- my $cwd = length $pfx ? "$pfx/$path" : $path;
2368
- my $pool = SVN::Pool->new;
2369
- $cwd =~ s#^\Q$SVN->{svn_path}\E##;
2370
- my $nr = 0;
2371
- my ($dirent, $r, $props) = $SVN->get_dir($cwd, $rev, $pool);
2372
- %{$untracked->{dir_prop}->{$cwd}} = %$props;
2373
- foreach my $d (keys %$dirent) {
2374
- my $t = $dirent->{$d}->kind;
2375
- if ($t == $SVN::Node::dir) {
2376
- my $i = libsvn_traverse($gui, $cwd, $d, $rev,
2377
- $files, $untracked);
2378
- if ($i) {
2379
- $nr += $i;
2380
- } else {
2381
- $untracked->{empty}->{"$cwd/$d"} = 1;
2382
- }
2383
- } elsif ($t == $SVN::Node::file) {
2384
- $nr++;
2385
- my $file = "$cwd/$d";
2386
- if (defined $files) {
2387
- push @$files, $file;
2388
- } else {
2389
- libsvn_get_file($gui, $file, $rev, 'A',
2390
- $untracked);
2391
- my ($dir) = ($file =~ m#^(.*?)/?(?:[^/]+)$#);
2392
- delete $untracked->{empty}->{$dir};
2393
- }
2394
- }
2395
- }
2396
- $pool->clear;
2397
- $nr;
2398
-}
2399
-
2251
sub libsvn_traverse_ignore {
2252
my ($fh, $path, $r) = @_;
2253
$path =~ s#^/+##g;
2339
print STDERR "Found branch parent: ($GIT_SVN) $parent\n";
2340
command_noisy('read-tree', $parent);
2341
unless (libsvn_can_do_switch()) {
2491
- return libsvn_fetch_full($parent, $paths, $rev,
2492
- $author, $date, $msg);
2342
+ return _libsvn_new_tree($paths, $rev, $author, $date,
2343
+ $msg, [$parent]);
2344
}
2345
# do_switch works with svn/trunk >= r22312, but that is not
2346
# included with SVN 1.4.2 (the latest version at the moment),
2365
2366
sub libsvn_get_log {
2367
my ($ra, @args) = @_;
2517
- $args[4]-- if $args[4] && $_xfer_delta && ! $_follow_parent;
2368
+ $args[4]-- if $args[4] && ! $_follow_parent;
2369
if ($SVN::Core::VERSION le '1.2.0') {
2370
splice(@args, 3, 1);
2371
}
2376
if (my $log_entry = libsvn_find_parent_branch(@_)) {
2377
return $log_entry;
2378
}
2528
- my ($paths, $rev, $author, $date, $msg) = @_;
2529
- my $ut;
2530
- if ($_xfer_delta) {
2531
- my $pool = SVN::Pool->new;
2532
- my $ed = SVN::Git::Fetcher->new({q => $_q});
2533
- my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool);
2534
- my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
2535
- $reporter->set_path('', $rev, 1, @lock, $pool);
2536
- $reporter->finish_report($pool);
2537
- $pool->clear;
2538
- unless ($ed->{git_commit_ok}) {
2539
- die "SVN connection failed somewhere...\n";
2540
- }
2541
- $ut = $ed;
2542
- } else {
2543
- $ut = { empty => {}, dir_prop => {}, file_prop => {} };
2544
- my ($gui, $ctx) = command_input_pipe(qw/update-index
2545
- -z --index-info/);
2546
- libsvn_traverse($gui, '', $SVN->{svn_path}, $rev, undef, $ut);
2547
- command_close_pipe($gui, $ctx);
2379
+ my ($paths, $rev, $author, $date, $msg) = @_; # $pool is last
2380
+ _libsvn_new_tree($paths, $rev, $author, $date, $msg, []);
2381
+}
2382
+
2383
+sub _libsvn_new_tree {
2384
+ my ($paths, $rev, $author, $date, $msg, $parents) = @_;
2385
+ my $pool = SVN::Pool->new;
2386
+ my $ed = SVN::Git::Fetcher->new({q => $_q});
2387
+ my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool);
2388
+ my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
2389
+ $reporter->set_path('', $rev, 1, @lock, $pool);
2390
+ $reporter->finish_report($pool);
2391
+ $pool->clear;
2392
+ unless ($ed->{git_commit_ok}) {
2393
+ die "SVN connection failed somewhere...\n";
2394
}
2549
- libsvn_log_entry($rev, $author, $date, $msg, [], $ut);
2395
+ libsvn_log_entry($rev, $author, $date, $msg, $parents, $ed);
2396
}
2397
2398
sub find_graft_path_commit {