@matheusbsbs / matheus-bagliano / commits / 289370578c
Fork 0

git-svn: fetch tracks initial change with --follow-parent

We were still skipping path information from get_log if we are tracking /r9270/drunk/subversion/bindings/..., but got something like this in the log: A /r9270/drunk (from /r9270/trunk:14) Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Jan 30, 2007 at 00:35 UTC 289370578ca5833641fbb59813173ac6db1986d1
2 files changed +27 -4
git-svn.perl
+14 -3
@@ -1090,6 +1090,19 @@ sub revisions_eq {
1090 return 1;
1091 }
1092
1093 +sub match_paths {
1094 + my ($self, $paths) = @_;
1095 + return 1 if $paths->{'/'};
1096 + $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\/?/;
1097 + grep /$self->{path_regex}/, keys %$paths and return 1;
1098 + my $c = '';
1099 + foreach (split m#/#, $self->rel_path) {
1100 + $c .= "/$_";
1101 + return 1 if $paths->{$c};
1102 + }
1103 + return 0;
1104 +}
1105 +
1106 sub find_parent_branch {
1107 my ($self, $paths, $rev) = @_;
1108 return undef unless $::_follow_parent;
@@ -2313,7 +2326,6 @@ sub gs_fetch_loop_common {
2326 if (my $last_commit = $gs->last_commit) {
2327 $gs->assert_index_clean($last_commit);
2328 }
2316 - $gs->{path_regex} = qr/^\/\Q$gs->{path}\E\/?/;
2329 }
2330 while (1) {
2331 my @revs;
@@ -2339,8 +2351,7 @@ sub gs_fetch_loop_common {
2351 my ($paths, $r) = @$_;
2352 foreach my $gs (@gs) {
2353 if ($paths) {
2342 - grep /$gs->{path_regex}/, keys %$paths
2343 - or next;
2354 + $gs->match_paths($paths) or next;
2355 }
2356 next if defined $gs->rev_db_get($r);
2357 if (my $log_entry = $gs->do_fetch($paths, $r)) {
t/t9104-git-svn-follow-parent.sh
+13 -1
@@ -105,7 +105,7 @@ test_expect_success 'follow deleted directory' "
105
106 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
107 # in trunk/subversion/bindings/swig/perl
108 -test_expect_success '' "
108 +test_expect_success 'follow-parent avoids deleting relevant info' "
109 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
110 for i in a b c ; do \
111 echo \$i > import/trunk/subversion/bindings/swig/perl/\$i.pm &&
@@ -134,6 +134,18 @@ test_expect_success '' "
134 \"\`git ls-tree --name-only r9270-t\`\"
135 "
136
137 +test_expect_success "track initial change if it was only made to parent" "
138 + svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk &&
139 + git-svn init -i r9270-d \
140 + $svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t &&
141 + git-svn fetch -i r9270-d --follow-parent &&
142 + test \`git rev-list r9270-d | wc -l\` -eq 3 &&
143 + test \"\`git ls-tree --name-only r9270-t\`\" = \
144 + \"\`git ls-tree --name-only r9270-d\`\" &&
145 + test \"\`git rev-parse r9270-t\`\" = \
146 + \"\`git rev-parse r9270-d~1\`\"
147 + "
148 +
149 test_debug 'gitk --all &'
150
151 test_done