From: João Abecasis Date: Sat, 14 Jun 2008 04:02:29 GMT Subject: [PATCH] git-svn: follow revisions of svm-mirrored repositories Message-ID: <7bf6f1d20806132102x71422617s26260fdc348a7c04@mail.gmail.com> Hi, When using an svk mirror repository as the source for git-svn, find-rev and rebase don't work. find-rev takes a while, while it traverses and processes commit logs for the branch, and ultimately fails with the error message: "Unable to determine upstream SVN information from git-svn history". This happens because find-rev doesn't relate information in the commit messages to the internal svm-source revision maps. Similarly, rebase is faster but still exits with the message "Unable to determine upstream SVN information from working tree history". The attached patch fixes a couple of underlying issues to get at least these two commands working. AFAICT it still works well with plain svn repositories. Can this be merged upstream? Any comments are welcome. Cheers, -- João From 9e348a4a25d0ea1fe48dcf5175a2853267933860 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 13 Jun 2008 20:32:57 -0500 Subject: [PATCH] git-svn: follow revisions of svm-mirrored repositories Although git-svn keeps track of source revisions in svm-mirrored repositories, it doesn't use that information in all places. This fixes working_head_info and Git::SVN::find_by_url to work with mirrored repositories when useSvmProps is set. At least the commands find-rev and rebase, which didn't work for me with svm-mirrored repositories, are now working. --- git-svn.perl | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index 47b0c37..db054d2 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -537,13 +537,13 @@ sub cmd_find_rev { my $head = shift; $head ||= 'HEAD'; my @refs; - my (undef, undef, undef, $gs) = working_head_info($head, \@refs); + my (undef, undef, $uuid, $gs) = working_head_info($head, \@refs); unless ($gs) { die "Unable to determine upstream SVN information from ", "$head history\n"; } my $desired_revision = substr($revision_or_hash, 1); - $result = $gs->rev_map_get($desired_revision); + $result = $gs->rev_map_get($desired_revision, $uuid); } else { my (undef, $rev, undef) = cmt_metadata($revision_or_hash); $result = $rev; @@ -1158,7 +1158,7 @@ sub working_head_info { if (defined $url && defined $rev) { next if $max{$url} and $max{$url} < $rev; if (my $gs = Git::SVN->find_by_url($url)) { - my $c = $gs->rev_map_get($rev); + my $c = $gs->rev_map_get($rev, $uuid); if ($c && $c eq $hash) { close $fh; # break the pipe return ($url, $rev, $uuid, $gs); @@ -1417,6 +1417,16 @@ sub read_all_remotes { my ($remote, $local_ref, $remote_ref) = ($1, $2, $3); $local_ref =~ s{^/}{}; $r->{$remote}->{fetch}->{$local_ref} = $remote_ref; + } elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) { + my $svm; + eval { + my $section = "svn-remote.$1"; + $svm = { + source => tmp_config('--get', "$section.svm-source"), + replace => tmp_config('--get', "$section.svm-replace"), + } + }; + $r->{$1}->{svm} = $svm; } elsif (m!^(.+)\.url=\s*(.*)\s*$!) { $r->{$1}->{url} = $2; } elsif (m!^(.+)\.(branches|tags)= @@ -1566,13 +1576,20 @@ sub find_by_url { # repos_root and, path are optional } my $p = $path; my $rwr = rewrite_root({repo_id => $repo_id}); + my $svm = $remotes->{$repo_id}->{svm} + if defined $remotes->{$repo_id}->{svm}; unless (defined $p) { $p = $full_url; my $z = $u; + my $prefix = ''; if ($rwr) { $z = $rwr; + } elsif (defined $svm) { + $z = $svm->{source}; + $prefix = $svm->{replace}; + $prefix =~ s#^\Q$u\E(?=/|$)##; } - $p =~ s#^\Q$z\E(?:/|$)## or next; + $p =~ s#^\Q$z\E(?:/|$)#$prefix# or next; } foreach my $f (keys %$fetch) { next if $f ne $p; -- 1.5.5.1