git-svn: avoid tracking change-less revisions
They simply aren't interesting to track, and this will allow us to avoid get_log(). Since r0 is covered by this, we need to update the tests to not rely on r0 (which is always empty). Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Jan 25, 2007 at 11:53 UTC
97f6987afaae239f7e3ae3944e0b29343b43a894
3 files changed
+42
-35
git-svn.perl
+33
-28
@@ -315,7 +315,7 @@ sub cmd_set_tree {
315
my $gs = Git::SVN->new;
316
my ($r_last, $cmt_last) = $gs->last_rev_commit;
317
$gs->fetch;
318
- if ($r_last != $gs->{last_rev}) {
318
+ if (defined $gs->{last_rev} && $r_last != $gs->{last_rev}) {
319
fatal "There are new revisions that were fetched ",
320
"and need to be merged (or acknowledged) ",
321
"before committing.\nlast rev: $r_last\n",
@@ -1214,50 +1214,46 @@ sub do_fetch {
1214
$self->make_log_entry($rev, \@parents, $ed);
1215
}
1216
1217
-sub write_untracked {
1218
- my ($self, $rev, $fh, $untracked) = @_;
1219
- my $h;
1220
- print $fh "r$rev\n" or croak $!;
1221
- $h = $untracked->{empty};
1217
+sub get_untracked {
1218
+ my ($self, $ed) = @_;
1219
+ my @out;
1220
+ my $h = $ed->{empty};
1221
foreach (sort keys %$h) {
1222
my $act = $h->{$_} ? '+empty_dir' : '-empty_dir';
1224
- print $fh " $act: ", uri_encode($_), "\n" or croak $!;
1223
+ push @out, " $act: " . uri_encode($_);
1224
warn "W: $act: $_\n";
1225
}
1226
foreach my $t (qw/dir_prop file_prop/) {
1228
- $h = $untracked->{$t} or next;
1227
+ $h = $ed->{$t} or next;
1228
foreach my $path (sort keys %$h) {
1229
my $ppath = $path eq '' ? '.' : $path;
1230
foreach my $prop (sort keys %{$h->{$path}}) {
1231
next if $SKIP_PROP{$prop};
1232
my $v = $h->{$path}->{$prop};
1233
+ my $t_ppath_prop = "$t: " .
1234
+ uri_encode($ppath) . ' ' .
1235
+ uri_encode($prop);
1236
if (defined $v) {
1235
- print $fh " +$t: ",
1236
- uri_encode($ppath), ' ',
1237
- uri_encode($prop), ' ',
1238
- uri_encode($v), "\n"
1239
- or croak $!;
1237
+ push @out, " +$t_ppath_prop " .
1238
+ uri_encode($v);
1239
} else {
1241
- print $fh " -$t: ",
1242
- uri_encode($ppath), ' ',
1243
- uri_encode($prop), "\n"
1244
- or croak $!;
1240
+ push @out, " -$t_ppath_prop";
1241
}
1242
}
1243
}
1244
}
1245
foreach my $t (qw/absent_file absent_directory/) {
1250
- $h = $untracked->{$t} or next;
1246
+ $h = $ed->{$t} or next;
1247
foreach my $parent (sort keys %$h) {
1248
foreach my $path (sort @{$h->{$parent}}) {
1253
- print $fh " $t: ",
1254
- uri_encode("$parent/$path"), "\n"
1255
- or croak $!;
1249
+ push @out, " $t: " .
1250
+ uri_encode("$parent/$path");
1251
warn "W: $t: $parent/$path ",
1252
"Insufficient permissions?\n";
1253
}
1254
}
1255
}
1256
+ \@out;
1257
}
1258
1259
sub parse_svn_date {
@@ -1280,12 +1276,15 @@ sub check_author {
1276
}
1277
1278
sub make_log_entry {
1283
- my ($self, $rev, $parents, $untracked) = @_;
1284
- my $rp = $self->ra->rev_proplist($rev);
1285
- my %log_entry = ( parents => $parents || [], revision => $rev,
1286
- revprops => $rp, log => '');
1279
+ my ($self, $rev, $parents, $ed) = @_;
1280
+ my $untracked = $self->get_untracked($ed);
1281
+
1282
open my $un, '>>', "$self->{dir}/unhandled.log" or croak $!;
1288
- $self->write_untracked($rev, $un, $untracked);
1283
+ print $un "r$rev\n" or croak $!;
1284
+ print $un $_, "\n" foreach @$untracked;
1285
+ my %log_entry = ( parents => $parents || [], revision => $rev,
1286
+ log => '');
1287
+ my $rp = $self->ra->rev_proplist($rev);
1288
foreach (sort keys %$rp) {
1289
my $v = $rp->{$_};
1290
if (/^svn:(author|date|log)$/) {
@@ -1296,6 +1295,11 @@ sub make_log_entry {
1295
}
1296
}
1297
close $un or croak $!;
1298
+
1299
+ delete $rp->{'svn:date'}; # this is the only revprop for r0
1300
+ return undef if ($ed->{nr} == 0 && scalar @$untracked == 0 &&
1301
+ scalar keys %$rp == 0);
1302
+
1303
$log_entry{date} = parse_svn_date($log_entry{date});
1304
$log_entry{author} = check_author($log_entry{author});
1305
$log_entry{log} .= "\n";
@@ -1320,8 +1324,9 @@ sub fetch {
1324
my ($paths, $rev, $author, $date, $log) = @_;
1325
push @revs, [ $paths, $rev ] });
1326
foreach (@revs) {
1323
- my $log_entry = $self->do_fetch(@$_);
1324
- $self->do_git_commit($log_entry, @parents);
1327
+ if (my $log_entry = $self->do_fetch(@$_)) {
1328
+ $self->do_git_commit($log_entry, @parents);
1329
+ }
1330
}
1331
last if $max >= $head;
1332
$min = $max + 1;
t/t9100-git-svn-basic.sh
-2
@@ -211,8 +211,6 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
211
tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
212
EOF
213
214
-echo tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 >> expected
215
-
214
test_expect_success "$name" "diff -u a expected"
215
216
test_expect_failure 'exit if remote refs are ambigious' "
t/t9107-git-svn-migrate.sh
+9
-5
@@ -5,13 +5,17 @@ test_description='git-svn metadata migrations from previous versions'
5
6
test_expect_success 'setup old-looking metadata' "
7
cp $GIT_DIR/config $GIT_DIR/config-old-git-svn &&
8
+ mkdir import &&
9
+ cd import
10
+ for i in trunk branches/a branches/b \
11
+ tags/0.1 tags/0.2 tags/0.3; do
12
+ mkdir -p \$i && \
13
+ echo hello >> \$i/README || exit 1
14
+ done && \
15
+ svn import -m test . $svnrepo
16
+ cd .. &&
17
git-svn init $svnrepo &&
18
git-svn fetch &&
10
- for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3; do
11
- mkdir -p \$i && echo hello >> \$i/README || exit 1; done &&
12
- git ls-files -o trunk branches tags | git update-index --add --stdin &&
13
- git commit -m 'test' &&
14
- git-svn dcommit &&
19
mv $GIT_DIR/svn/* $GIT_DIR/ &&
20
rmdir $GIT_DIR/svn &&
21
git-update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn &&