git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-svn: follow revisions of svm-mirrored repositories
@ 2008-06-14  4:02 João Abecasis
  2008-06-15 21:30 ` Sam Vilain
  0 siblings, 1 reply; 5+ messages in thread
From: João Abecasis @ 2008-06-14  4:02 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

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

[-- Attachment #2: 0001-git-svn-follow-revisions-of-svm-mirrored-repositori.patch --]
[-- Type: application/octet-stream, Size: 2992 bytes --]

From 9e348a4a25d0ea1fe48dcf5175a2853267933860 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Jo=C3=A3o=20Abecasis?= <joao@abecasis.name>
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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Vilain @ 2008-06-15 21:30 UTC (permalink / raw)
  To: João Abecasis; +Cc: git

João Abecasis wrote:
> 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.

Can you give an approximate series of commands that led to this not
working?  Just to clarify what happened.  Ideally, it would be a test
case; see if you can add it to the existing SVM test case.  In fact this
might be a regression compared to the original support, due to lack of
tests - in which case it would be good to fix this "for good".

Also, please try to send your patches inline if possible, or at least
try to get them to be Content-Disposition: inline, it makes review
easier for casual list subscribers.

Thanks,
Sam.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories
  2008-06-15 21:30 ` Sam Vilain
@ 2008-06-18  2:57   ` João Abecasis
  2008-06-18  2:58     ` João Abecasis
  0 siblings, 1 reply; 5+ messages in thread
From: João Abecasis @ 2008-06-18  2:57 UTC (permalink / raw)
  To: Sam Vilain; +Cc: git

Hi Sam,

Thanks for your reply. I'm currently on the road so may be a little
slow to respond. Please bear with me.

Sam Vilain wrote:
>> 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.
>
> Can you give an approximate series of commands that led to this not
> working?  Just to clarify what happened.  Ideally, it would be a test
> case; see if you can add it to the existing SVM test case.  In fact this
> might be a regression compared to the original support, due to lack of
> tests - in which case it would be good to fix this "for good".

I haven't tried the test cases yet, but will look into it. Perhaps
that can also hammer out other places where svm-mirror support is
incomplete.

In the meantime, reproducing the 2 issues my patch is supposed to fix
is rather straightforward, but there could be something that I missed,
so here goes:

    # Preparation, skipped informational messages.
    $ git init
    $ git svn init --use-svm-props -s file:///path/to/svk/repository/and/mirror/
    # Populate repository
    $ git svn fetch

    # And the missing functionality.
    $ git svn rebase
    Unable to determine upstream SVN information from working tree history

    $ git svn find-rev r5
    Unable to determine upstream SVN information from HEAD history

And trying out the test case I just noticed an issue with my previous
patch, with misplaced // -- somehow it didn't show up in my previous
tests. I'll post an updated patch, shortly.

> Also, please try to send your patches inline if possible, or at least
> try to get them to be Content-Disposition: inline, it makes review
> easier for casual list subscribers.

I was worried that sending patches inlined would break the patch
because of line lengths and such, since I'm using Gmail's web
interface. Anyway, I'll try that we'll see how that goes.

Cheers,


João

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories
  2008-06-18  2:57   ` João Abecasis
@ 2008-06-18  2:58     ` João Abecasis
  0 siblings, 0 replies; 5+ messages in thread
From: João Abecasis @ 2008-06-18  2:58 UTC (permalink / raw)
  To: Sam Vilain; +Cc: git

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] git-svn: follow revisions of svm-mirrored repositories
@ 2008-06-26 16:24 João Abecasis
  0 siblings, 0 replies; 5+ messages in thread
From: João Abecasis @ 2008-06-26 16:24 UTC (permalink / raw)
  To: git

From a4cd092cd1aeae954378038d24f93af930610cc8 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Jo=C3=A3o=20Abecasis?= <joao@abecasis.name>
Date: Fri, 13 Jun 2008 20:32:57 -0500
Subject: [PATCH] git-svn: follow revisions of svm-mirrored repositories
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

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.

Signed-off-by: João Abecasis <joao@abecasis.name>
---
 git-svn.perl                     |   36 ++++++++++++++++++++++++++++++++----
 t/t9110-git-svn-use-svm-props.sh |    9 +++++++++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 4c9c59b..4df6c71 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;
@@ -1160,7 +1160,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);
@@ -1414,11 +1414,16 @@ sub fetch_all {

 sub read_all_remotes {
 	my $r = {};
+        my $usesvmprops = eval {
+		command_oneline(qw/config --bool svn.useSvmProps/) } eq 'true';
 	foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) {
 		if (m!^(.+)\.fetch=\s*(.*)\s*:\s*refs/remotes/(.+)\s*$!) {
 			my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);
 			$local_ref =~ s{^/}{};
 			$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
+			$r->{$remote}->{svm} = {} if $usesvmprops;
+		} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
+			$r->{$1}->{svm} = {};
 		} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
 			$r->{$1}->{url} = $2;
 		} elsif (m!^(.+)\.(branches|tags)=
@@ -1435,6 +1440,21 @@ sub read_all_remotes {
 			}
 		}
 	}
+
+	map {
+		if (defined $r->{$_}->{svm}) {
+			my $svm;
+			eval {
+				my $section = "svn-remote.$_";
+				$svm = {
+					source => tmp_config('--get', "$section.svm-source"),
+					replace => tmp_config('--get', "$section.svm-replace"),
+				}
+			};
+			$r->{$_}->{svm} = $svm;
+		}
+	} keys %$r;
+
 	$r;
 }

@@ -1568,13 +1588,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#/$##;
 			}
-			$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;
diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh
index 047659f..04d2a65 100755
--- a/t/t9110-git-svn-use-svm-props.sh
+++ b/t/t9110-git-svn-use-svm-props.sh
@@ -49,4 +49,13 @@ test_expect_success 'verify metadata for /dir' "
 	   grep '^git-svn-id: $dir_url@1 $uuid$'
 	"

+test_expect_success 'find commit based on SVN revision number' "
+        git-svn find-rev r12 |
+	    grep `git rev-parse HEAD`
+        "
+
+test_expect_success 'empty rebase' "
+	git-svn rebase
+	"
+
 test_done
-- 
1.5.5.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-26 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2008-06-26 16:24 João Abecasis

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).