threads / patch / 14363

patchgit-svn: find-rev and rebase for SVN::Mirror repositories

Subject: [PATCH] git-svn: find-rev and rebase for SVN::Mirror repositories

## tl;dr

5 messages between Jul 9, 2008 and Jul 15, 2008. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

João Abecasis· Jul 9, 2008, 02:08 UTC · lore

find-rev and rebase error out on svm because git-svn doesn't trace the original svn revision numbers back to git commits. The updated test case, included in the patch, shows the issue and passes with the rest of the patch applied.

This fixes Git::SVN::find_by_url to find branches based on the svm:source URL, where useSvmProps is set. Also makes sure cmd_find_rev and working_head_info use the information they have to correctly track the source repository. This is enough to get find-rev and rebase working.

Signed-off-by: João Abecasis <joao@abecasis.name>
---
Incidentally, I've tried submitting these fixes before, but failed to
get much attention, so I could be doing something wrong... Any input
on the patch or my approach to this list is appreciated. This time I
reworded the commit message and added Eric Wong to the CC list, since
he seems to be Ack'ing git-svn patches.
Anyway, the patch does get things working for me.
Cheers,
João
 git-svn.perl                     |   37 +++++++++++++++++++++++++++++++++----
 t/t9110-git-svn-use-svm-props.sh |    9 +++++++++
 2 files changed, 42 insertions(+), 4 deletions(-)
Show changes to 2 files +42 −4

git-svn.perl, t/t9110-git-svn-use-svm-props.sh

diff --git a/git-svn.perl b/git-svn.perl
index a366c89..f5baec1 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;
@@ -1162,7 +1162,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);
@@ -1416,11 +1416,17 @@ sub fetch_all {

 sub read_all_remotes {
 	my $r = {};
+        my $usesvmprops = eval { command_oneline(qw/config --bool
+            svn.useSvmProps/) };
+        $usesvmprops = $usesvmprops eq 'true' if $usesvmprops;
 	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)=
@@ -1437,6 +1443,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;
 }

@@ -1563,13 +1584,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.6
Eric Wong· Jul 14, 2008, 09:12 UTC · re: João Abecasis · lore

Re: [PATCH] git-svn: find-rev and rebase for SVN::Mirror repositories

João Abecasis <joao@abecasis.name> wrote:
Show 16 quoted lines
> find-rev and rebase error out on svm because git-svn doesn't trace the original
> svn revision numbers back to git commits. The updated test case, included in the
> patch, shows the issue and passes with the rest of the patch applied.
> 
> This fixes Git::SVN::find_by_url to find branches based on the svm:source URL,
> where useSvmProps is set. Also makes sure cmd_find_rev and working_head_info use
> the information they have to correctly track the source repository. This is
> enough to get find-rev and rebase working.
> 
> Signed-off-by: João Abecasis <joao@abecasis.name>
> ---
> Incidentally, I've tried submitting these fixes before, but failed to
> get much attention, so I could be doing something wrong... Any input
> on the patch or my approach to this list is appreciated. This time I
> reworded the commit message and added Eric Wong to the CC list, since
> he seems to be Ack'ing git-svn patches.
Hi João,

Sorry, I haven't been following the mailing list much lately, and even keeping up with my inbox is getting to be a chore :(

The commit message should be wrapped at 72 characters or less. Some further notes below (mostly whitespace issues, but one regression).

Show 5 quoted lines
>  sub read_all_remotes {
>  	my $r = {};
> +        my $usesvmprops = eval { command_oneline(qw/config --bool
> +            svn.useSvmProps/) };
> +        $usesvmprops = $usesvmprops eq 'true' if $usesvmprops;
Always use tabs for indentation (but spaces for alignment is alright).

I'd also rather not propagate the crazy alllowercasewithoutunderscores convention of git-config into code, either. $uses_svm_props is much easier to parse when I'm half-awake :)

Show 30 quoted lines
>  	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)=
> @@ -1437,6 +1443,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;
> +
Please wrap all code at 80-columns.
Show 20 quoted lines
> @@ -1563,13 +1584,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;

This broke t9100 for me at: 'able to dcommit to a subdirectory' Changing the ?= back to ?: works.

Thanks for the patch, please let us know if that change is OK.
-- 
Eric Wong
João Abecasis· Jul 14, 2008, 15:27 UTC · re: Eric Wong · lore

Re: [PATCH] git-svn: find-rev and rebase for SVN::Mirror repositories

Hi Eric,
Thanks for your reply and comments.
Eric Wong <normalperson@yhbt.net> wrote:
Show 22 quoted lines
> João Abecasis <joao@abecasis.name> wrote:
>> find-rev and rebase error out on svm because git-svn doesn't trace the original
>> svn revision numbers back to git commits. The updated test case, included in the
>> patch, shows the issue and passes with the rest of the patch applied.
>>
>> This fixes Git::SVN::find_by_url to find branches based on the svm:source URL,
>> where useSvmProps is set. Also makes sure cmd_find_rev and working_head_info use
>> the information they have to correctly track the source repository. This is
>> enough to get find-rev and rebase working.
>>
>> Signed-off-by: João Abecasis <joao@abecasis.name>
>> ---
>> Incidentally, I've tried submitting these fixes before, but failed to
>> get much attention, so I could be doing something wrong... Any input
>> on the patch or my approach to this list is appreciated. This time I
>> reworded the commit message and added Eric Wong to the CC list, since
>> he seems to be Ack'ing git-svn patches.
>
> Hi João,
>
> Sorry, I haven't been following the mailing list much lately, and
> even keeping up with my inbox is getting to be a chore :(
I can relate to that ;-)
> The commit message should be wrapped at 72 characters or less.
> Some further notes below (mostly whitespace issues, but one
> regression).
Noted.
Show 11 quoted lines
>>  sub read_all_remotes {
>>       my $r = {};
>> +        my $usesvmprops = eval { command_oneline(qw/config --bool
>> +            svn.useSvmProps/) };
>> +        $usesvmprops = $usesvmprops eq 'true' if $usesvmprops;
>
> Always use tabs for indentation (but spaces for alignment is alright).
>
> I'd also rather not propagate the crazy alllowercasewithoutunderscores
> convention of git-config into code, either.  $uses_svm_props is much
> easier to parse when I'm half-awake :)
Done!
Show 32 quoted lines
>>       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)=
>> @@ -1437,6 +1443,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;
>> +
>
> Please wrap all code at 80-columns.
Okidoki. I just wasn't sure how wide was a tab ;-)
Show 23 quoted lines
>> @@ -1563,13 +1584,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;
>
> This broke t9100 for me at: 'able to dcommit to a subdirectory'
> Changing the ?= back to ?: works.

Duh! Missed that. I had to make a couple of tweaks after the tests were working, because I had some another test case that was breaking somewhere. Anyway, my other test case (which is the one where I need it to work) works without that change after all.

> Thanks for the patch, please let us know if that change is OK.

Let's go with that, since it works. If I do find a test case where it breaks we'll fix it later.

Updated patch coming up.
Cheers,
João
João Abecasis· Jul 14, 2008, 15:28 UTC · re: João Abecasis · lore

Re: [PATCH] git-svn: find-rev and rebase for SVN::Mirror repositories

find-rev and rebase error out on svm because git-svn doesn't trace the original svn revision numbers back to git commits. The updated test case, included in the patch, shows the issue and passes with the rest of the patch applied.

This fixes Git::SVN::find_by_url to find branches based on the svm:source URL, where useSvmProps is set. Also makes sure cmd_find_rev and working_head_info use the information they have to correctly track the source repository. This is enough to get find-rev and rebase working.

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

git-svn.perl, t/t9110-git-svn-use-svm-props.sh

diff --git a/git-svn.perl b/git-svn.perl
index a366c89..0aa994a 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;
@@ -1162,7 +1162,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);
@@ -1416,11 +1416,17 @@ sub fetch_all {

 sub read_all_remotes {
 	my $r = {};
+	my $use_svm_props = eval { command_oneline(qw/config --bool
+	    svn.useSvmProps/) };
+	$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;
 	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 $use_svm_props;
+		} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
+			$r->{$1}->{svm} = {};
 		} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
 			$r->{$1}->{url} = $2;
 		} elsif (m!^(.+)\.(branches|tags)=
@@ -1437,6 +1443,23 @@ 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;
 }

@@ -1563,13 +1586,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.6
Eric Wong· Jul 15, 2008, 04:25 UTC · re: João Abecasis · lore

Re: [PATCH] git-svn: find-rev and rebase for SVN::Mirror repositories

João Abecasis <joao@abecasis.name> wrote:
Show 12 quoted lines
> find-rev and rebase error out on svm because git-svn doesn't trace the
> original svn revision numbers back to git commits. The updated test
> case, included in the patch, shows the issue and passes with the rest of
> the patch applied.
> 
> This fixes Git::SVN::find_by_url to find branches based on the
> svm:source URL, where useSvmProps is set. Also makes sure cmd_find_rev
> and working_head_info use the information they have to correctly track
> the source repository. This is enough to get find-rev and rebase
> working.
> 
> Signed-off-by: João Abecasis <joao@abecasis.name>
Thanks João,
Acked-by: Eric Wong <normalperson@yhbt.net>
Show 119 quoted lines
> ---
>  git-svn.perl                     |   39 ++++++++++++++++++++++++++++++++++---
>  t/t9110-git-svn-use-svm-props.sh |    9 ++++++++
>  2 files changed, 44 insertions(+), 4 deletions(-)
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index a366c89..0aa994a 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;
> @@ -1162,7 +1162,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);
> @@ -1416,11 +1416,17 @@ sub fetch_all {
> 
>  sub read_all_remotes {
>  	my $r = {};
> +	my $use_svm_props = eval { command_oneline(qw/config --bool
> +	    svn.useSvmProps/) };
> +	$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;
>  	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 $use_svm_props;
> +		} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
> +			$r->{$1}->{svm} = {};
>  		} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
>  			$r->{$1}->{url} = $2;
>  		} elsif (m!^(.+)\.(branches|tags)=
> @@ -1437,6 +1443,23 @@ 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;
>  }
> 
> @@ -1563,13 +1586,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.6

← back to recent threads