* [PATCH v2] git-svn: make rebuild respect rewriteRoot option
@ 2008-06-24 0:17 Jan Krüger
2008-06-24 2:11 ` Joey Hess
0 siblings, 1 reply; 2+ messages in thread
From: Jan Krüger @ 2008-06-24 0:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git mailing list, Eric Wong
Suppose someone fetches git-svn-ified commits from another repo and then
attempts to use 'git-svn init --rewrite-root=foo bar'. Using git svn rebase
after that will fail badly:
* For each commit tried by working_head_info, rebuild is called indirectly.
* rebuild will iterate over all commits and skip all of them because the
URL does not match. Because of that no rev_map file is generated at all.
* Thus, rebuild will run once for every commit. This takes ages.
* In the end there still isn't any rev_map file and thus working_head_info
fails.
Addressing this behaviour fixes an apparently not too uncommon problem with
providing git-svn mirrors of Subversion repositories. Some repositories are
accessed using different URLs depending on whether the user has push
privileges or not. In the latter case, an anonymous URL is often used that
differs from the push URL. Providing a mirror that is usable in both cases
becomes a lot more possible with this change.
Signed-off-by: Jan Krüger <jk@jk.gs>
---
For reference, the previous version of this patch at
<http://thread.gmane.org/gmane.comp.version-control.git/85551> was
acked by Eric Wong (see that thread); the only change here is the added
test case as suggested by Eric.
The test doesn't exactly reproduce the original situation but it does
trigger the rebuild process to ensure it works correctly despite
'rewriteRoot' being set to something not equal to 'url', which is what
we are after in the first place.
git-svn.perl | 6 ++--
t/t9123-git-svn-rebuild-with-rewriteroot.sh | 32 +++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 3 deletions(-)
create mode 100755 t/t9123-git-svn-rebuild-with-rewriteroot.sh
diff --git a/git-svn.perl b/git-svn.perl
index a54979d..4c9c59b 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2577,8 +2577,8 @@ sub rebuild {
my ($log, $ctx) =
command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/,
$self->refname, '--');
- my $full_url = $self->full_url;
- remove_username($full_url);
+ my $metadata_url = $self->metadata_url;
+ remove_username($metadata_url);
my $svn_uuid = $self->ra_uuid;
my $c;
while (<$log>) {
@@ -2596,7 +2596,7 @@ sub rebuild {
# if we merged or otherwise started elsewhere, this is
# how we break out of it
if (($uuid ne $svn_uuid) ||
- ($full_url && $url && ($url ne $full_url))) {
+ ($metadata_url && $url && ($url ne $metadata_url))) {
next;
}
diff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh
new file mode 100755
index 0000000..cf3f64d
--- /dev/null
+++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Jan Krüger
+#
+
+test_description='git-svn respects rewriteRoot during rebuild'
+
+. ./lib-git-svn.sh
+
+mkdir import
+cd import
+ touch foo
+ svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
+cd ..
+rm -rf import
+
+test_expect_success 'init, fetch and checkout repository' '
+ git svn init --rewrite-root=http://invalid.invalid/ "$svnrepo" &&
+ git svn fetch
+ git checkout -b mybranch remotes/git-svn
+ '
+
+test_expect_success 'remove rev_map' '
+ rm "$GIT_SVN_DIR"/.rev_map.*
+ '
+
+test_expect_success 'rebuild rev_map' '
+ git svn rebase >/dev/null
+ '
+
+test_done
+
--
1.5.6.2.g4316
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] git-svn: make rebuild respect rewriteRoot option
2008-06-24 0:17 [PATCH v2] git-svn: make rebuild respect rewriteRoot option Jan Krüger
@ 2008-06-24 2:11 ` Joey Hess
0 siblings, 0 replies; 2+ messages in thread
From: Joey Hess @ 2008-06-24 2:11 UTC (permalink / raw)
To: Git mailing list
[-- Attachment #1: Type: text/plain, Size: 727 bytes --]
Jan Krüger wrote:
> Suppose someone fetches git-svn-ified commits from another repo and then
> attempts to use 'git-svn init --rewrite-root=foo bar'. Using git svn rebase
> after that will fail badly:
>
> * For each commit tried by working_head_info, rebuild is called indirectly.
> * rebuild will iterate over all commits and skip all of them because the
> URL does not match. Because of that no rev_map file is generated at all.
> * Thus, rebuild will run once for every commit. This takes ages.
> * In the end there still isn't any rev_map file and thus working_head_info
> fails.
Very timely, I had just been beating my head against this problem.
Your patch works great for me.
--
see shy jo
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-24 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24 0:17 [PATCH v2] git-svn: make rebuild respect rewriteRoot option Jan Krüger
2008-06-24 2:11 ` Joey Hess
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 NNTP newsgroup(s).