git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "João Abecasis" <joao@abecasis.name>
To: "Sam Vilain" <sam@vilain.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories
Date: Tue, 17 Jun 2008 21:58:06 -0500	[thread overview]
Message-ID: <7bf6f1d20806171958y4104a77cxf660d2853d391e2d@mail.gmail.com> (raw)
In-Reply-To: <7bf6f1d20806171957k29dbdd4fh52c3b515e7b573d@mail.gmail.com>

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 |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 47b0c37..51325b6 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,21 @@ 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(?:/|$)##;
+				$prefix =~ s#(.+?)/?$#$1/#;
 			}
-			$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

  reply	other threads:[~2008-06-18  2:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-14  4:02 [PATCH] git-svn: follow revisions of svm-mirrored repositories João Abecasis
2008-06-15 21:30 ` Sam Vilain
2008-06-18  2:57   ` João Abecasis
2008-06-18  2:58     ` João Abecasis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-06-26 16:24 João Abecasis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bf6f1d20806171958y4104a77cxf660d2853d391e2d@mail.gmail.com \
    --to=joao@abecasis.name \
    --cc=git@vger.kernel.org \
    --cc=sam@vilain.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).