git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-svn, tree moves, and --no-stop-on-copy
@ 2006-03-07 22:08 Yann Dirson
  2006-03-08  1:42 ` Eric Wong
  2006-03-08 17:02 ` git-svn, tree moves, and --no-stop-on-copy Matthias Urlichs
  0 siblings, 2 replies; 9+ messages in thread
From: Yann Dirson @ 2006-03-07 22:08 UTC (permalink / raw)
  To: Eric Wong; +Cc: GIT list

It looks that the --no-stop-on-copy flag has been dropped by error
during the "options cleanup" commit a couple of days ago.  This
trivial patch appears at first sight to address the problem:

diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 3c860e4..91a0d3b 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -36,7 +36,9 @@ my %fc_opts = ( 'no-ignore-externals' =>
                'authors-file|A=s' => \$_authors );
 my %cmd = (
        fetch => [ \&fetch, "Download new revisions from SVN",
-                       { 'revision|r=s' => \$_revision, %fc_opts } ],
+                       { 'revision|r=s' => \$_revision,
+                         'no-stop-on-copy' => \$_no_stop_copy,
+                         %fc_opts } ],
        init => [ \&init, "Initialize and fetch (import)", { } ],
        commit => [ \&commit, "Commit git revisions to SVN",
                        {       'stdin|' => \$_stdin,

But then, "git-svn fetch" fails when trying to deal with the renaming:

$ git-svn.perl init https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk/src
$ git-svn.perl fetch --no-stop-on-copy
[...]
Updated to revision 163.
r163 = 68da9a01b2d5a2372262ada33a401e03aef41e97
svn: REPORT request failed on '/svnroot/ufoai/!svn/vcc/default'
svn: Cannot replace a directory from within
256 at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 812
        main::sys('svn', 'up', '--ignore-externals', '-r166') called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 243
        main::fetch() called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 83

The impacted revision in svn is:

------------------------------------------------------------------------
r166 | ydirson | 2006-03-02 01:36:55 +0100 (Thu, 02 Mar 2006) | 1 line
Changed paths:
   D /trunk
   A /ufoai/trunk (from /trunk:165)

Adding an ufoai toplevel module
------------------------------------------------------------------------

Obviously "svn update" does not like it at all.

"svn switch --relocate" does not seem to be of any help.  Switching
manually .git/git-svn/tree/ to the new repository location does not
help either, since I must obviously update to r166 in that case, and
then a further "git-svn fetch" fails because it does not find
.git/git-svn/revs/166 aleady imported.

Any idea as to how to get the work done ?
I could surely import in another branch not using --no-stop-on-copy,
and then use a graft, but if we could make it work in a more
streamlined manner, it would surely be useful.


Before I find out in the doc about --no-stop-on-copy, I did a coupld
of experimentation.  Among them, was using a peg-revision in the URL
passed to "git-svn init":

$ GIT_SVN_ID=git-oldsvn git-svn init https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165

That succeeds, but then "git-svn fetch" will fail with:

svn: REPORT request failed on '/svnroot/ufoai/!svn/bc/190/trunk/src@165'
svn: '/svnroot/ufoai/!svn/bc/190/trunk/src@165' path not found
256 at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 783
        main::svn_log_raw('https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165', '-r0:HEAD', '--stop-on-copy') called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 219
        main::fetch() called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 81


Maybe git-svn could also be guarded against peg-revisions on init
command-line, since that appears to confuse it quite a bit :)


Additionally, it may be worth poiting out in the doc at least one
valid use of the --no-stop-on-copy flag that is friendly to the user's
sanity: when the svn repository has undergone a reorg, such that the
URL passed to "init" indeed moved - at least, when/if it is made to
work :)

-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

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

* Re: git-svn, tree moves, and --no-stop-on-copy
  2006-03-07 22:08 git-svn, tree moves, and --no-stop-on-copy Yann Dirson
@ 2006-03-08  1:42 ` Eric Wong
  2006-03-08  1:57   ` [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args Eric Wong
                     ` (2 more replies)
  2006-03-08 17:02 ` git-svn, tree moves, and --no-stop-on-copy Matthias Urlichs
  1 sibling, 3 replies; 9+ messages in thread
From: Eric Wong @ 2006-03-08  1:42 UTC (permalink / raw)
  To: Yann Dirson; +Cc: GIT list

Yann Dirson <ydirson@altern.org> wrote:
> It looks that the --no-stop-on-copy flag has been dropped by error
> during the "options cleanup" commit a couple of days ago.  This
> trivial patch appears at first sight to address the problem:

Thanks for the patch, but on second thought...

I'm tempted to drop it as an option...  IIRC, the only reason
--no-stop-on-copy exists in git-svn is in case ancient versions of svn
did not support --stop-on-copy.  I haven't bothered looking deeply into
SVN history to see if it was always supported or not.
 
> Before I find out in the doc about --no-stop-on-copy, I did a coupld
> of experimentation.  Among them, was using a peg-revision in the URL
> passed to "git-svn init":
> 
> $ GIT_SVN_ID=git-oldsvn git-svn init https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165
> 
> That succeeds, but then "git-svn fetch" will fail with:
> 
> svn: REPORT request failed on '/svnroot/ufoai/!svn/bc/190/trunk/src@165'
> svn: '/svnroot/ufoai/!svn/bc/190/trunk/src@165' path not found
> 256 at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 783
>         man::svn_log_raw('https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165', '-r0:HEAD', '--stop-on-copy') called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 219
>         main::fetch() called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 81

If you want full repository history for reorganized repositories,
easiest way is to pay the price for full repository and all of its
history.

	git-svn init https://svn.sourceforge.net/svnroot/ufoai
	git-svn fetch
	# this puts all your branches and tags into one single big git tree.

However, the following should always work: (after the following patch,

	GIT_SVN_ID=git-oldsvn git-svn init \
		https://svn.sourceforge.net/svnroot/ufoai/trunk
	GIT_SVN_ID=git-oldsvn git-svn fetch -r1:165

	GIT_SVN_ID=git-newsvn git-svn init
		https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk
	GIT_SVN_ID=git-newsvn git-svn fetch \
		166=`git-rev-parse refs/remotes/git-oldsvn`

Unfortunately, it does not, at least with svn 1.2.3...  I have a patch
coming that should fix things for 1.1.1 (and give better 1.1.x support
in general).  I'm not sure, but it feels like something is screwed up
with svn 1.2.3dfsg1-3:

This works:	svn log -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk

This doesn't:	svn  co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk

But this:	svn  co -r1 https://svn.sourceforge.net/svnroot/ufoai
will create the following structure:
	ufoai/{trunk,branches,tags}

I'm quite puzzled about it, as I swear I've seen it work on a different
project recently (of course I cannot remember which :<)

> Maybe git-svn could also be guarded against peg-revisions on init
> command-line, since that appears to confuse it quite a bit :)

Possibly, but having '@' in URLs is valid in some cases outside of
peg-revisions.

> Additionally, it may be worth poiting out in the doc at least one
> valid use of the --no-stop-on-copy flag that is friendly to the user's
> sanity: when the svn repository has undergone a reorg, such that the
> URL passed to "init" indeed moved - at least, when/if it is made to
> work :)

In the face of repository reorgs, git-svn is happiest tracking partial
history.  Or tracking the entire repository from the root.

Hopefully I've been reasonably coherent, having insomnia lately.

-- 
Eric Wong

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

* [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args
  2006-03-08  1:42 ` Eric Wong
@ 2006-03-08  1:57   ` Eric Wong
  2006-03-09 10:08     ` Junio C Hamano
  2006-03-08 22:15   ` git-svn, tree moves, and --no-stop-on-copy Yann Dirson
  2006-03-09 11:50   ` [PATCH] contrib/git-svn: remove the --no-stop-on-copy flag Eric Wong
  2 siblings, 1 reply; 9+ messages in thread
From: Eric Wong @ 2006-03-08  1:57 UTC (permalink / raw)
  To: Yann Dirson; +Cc: GIT list

Junio: please don't apply this patch to git.git just yet.  It seems fine
to me, but I haven't tested it heavily yet (Yann can help me, I hope :)
I hardly slept the past few days and I may have broken something badly
(it pasts all the tests, though).

---

As a side effect, this should also work better for 'init' off
directories that are no longer in the latest revision of the
repository.

Fix 'fetch' args (<rev>=<commit> options) on brand-new heads

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.perl |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

9f59596bde5bdd68d1a0a116f7383df74966de44
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index c575883..b8d2b3e 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -162,7 +162,8 @@ sub rebuild {
 				croak "SVN repository location required: $url\n";
 			}
 			$SVN_URL ||= $url;
-			$SVN_UUID ||= setup_git_svn();
+			$SVN_UUID ||= $uuid;
+			setup_git_svn();
 			$latest = $rev;
 		}
 		assert_revision_eq_or_unknown($rev, $c);
@@ -226,10 +227,12 @@ sub fetch {
 		push @svn_co,'--ignore-externals' unless $_no_ignore_ext;
 		sys(@svn_co, $SVN_URL, $SVN_WC);
 		chdir $SVN_WC or croak $!;
+		read_uuid();
 		$last_commit = git_commit($base, @parents);
 		assert_svn_wc_clean($base->{revision}, $last_commit);
 	} else {
 		chdir $SVN_WC or croak $!;
+		read_uuid();
 		$last_commit = file_to_s("$REV_DIR/$base->{revision}");
 	}
 	my @svn_up = qw(svn up);
@@ -275,7 +278,9 @@ sub commit {
 
 	fetch();
 	chdir $SVN_WC or croak $!;
-	my $svn_current_rev =  svn_info('.')->{'Last Changed Rev'};
+	my $info = svn_info('.');
+	read_uuid($info);
+	my $svn_current_rev =  $info->{'Last Changed Rev'};
 	foreach my $c (@revs) {
 		my $mods = svn_checkout_tree($svn_current_rev, $c);
 		if (scalar @$mods == 0) {
@@ -314,6 +319,14 @@ sub show_ignore {
 
 ########################### utility functions #########################
 
+sub read_uuid {
+	return if $SVN_UUID;
+	my $info = shift || svn_info('.');
+	$SVN_UUID = $info->{'Repository UUID'} or
+					croak "Repository UUID unreadable\n";
+	s_to_file($SVN_UUID,"$GIT_DIR/$GIT_SVN/info/uuid");
+}
+
 sub setup_git_svn {
 	defined $SVN_URL or croak "SVN repository location required\n";
 	unless (-d $GIT_DIR) {
@@ -323,14 +336,10 @@ sub setup_git_svn {
 	mkpath(["$GIT_DIR/$GIT_SVN/info"]);
 	mkpath([$REV_DIR]);
 	s_to_file($SVN_URL,"$GIT_DIR/$GIT_SVN/info/url");
-	$SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or
-					croak "Repository UUID unreadable\n";
-	s_to_file($SVN_UUID,"$GIT_DIR/$GIT_SVN/info/uuid");
 
 	open my $fd, '>>', "$GIT_DIR/$GIT_SVN/info/exclude" or croak $!;
 	print $fd '.svn',"\n";
 	close $fd or croak $!;
-	return $SVN_UUID;
 }
 
 sub assert_svn_wc_clean {
@@ -860,7 +869,6 @@ sub git_commit {
 	my ($log_msg, @parents) = @_;
 	assert_revision_unknown($log_msg->{revision});
 	my $out_fh = IO::File->new_tmpfile or croak $!;
-	$SVN_UUID ||= svn_info('.')->{'Repository UUID'};
 
 	map_tree_joins() if (@_branch_from && !%tree_map);
 
@@ -922,7 +930,9 @@ sub git_commit {
 	}
 	my @update_ref = ('git-update-ref',"refs/remotes/$GIT_SVN",$commit);
 	if (my $primary_parent = shift @exec_parents) {
-		push @update_ref, $primary_parent;
+		if (!system('git-rev-parse',"refs/remotes/$GIT_SVN")){
+			push @update_ref, $primary_parent;
+		}
 	}
 	sys(@update_ref);
 	sys('git-update-ref',"$GIT_SVN/revs/$log_msg->{revision}",$commit);
-- 
1.2.4.g198d

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

* Re: git-svn, tree moves, and --no-stop-on-copy
  2006-03-07 22:08 git-svn, tree moves, and --no-stop-on-copy Yann Dirson
  2006-03-08  1:42 ` Eric Wong
@ 2006-03-08 17:02 ` Matthias Urlichs
  1 sibling, 0 replies; 9+ messages in thread
From: Matthias Urlichs @ 2006-03-08 17:02 UTC (permalink / raw)
  To: git

Hi, Yann Dirson wrote:

> "svn switch --relocate" does not seem to be of any help.  Switching
> manually .git/git-svn/tree/ to the new repository location does not
> help either, since I must obviously update to r166 in that case, and
> then a further "git-svn fetch" fails because it does not find
> .git/git-svn/revs/166 aleady imported.
> 
> Any idea as to how to get the work done ?

You can manually edit the .git/corr file. Simply add an entry for #166
that has your reorganized (if necessary) head's SHA1.
-- 
Matthias Urlichs

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

* Re: git-svn, tree moves, and --no-stop-on-copy
  2006-03-08  1:42 ` Eric Wong
  2006-03-08  1:57   ` [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args Eric Wong
@ 2006-03-08 22:15   ` Yann Dirson
  2006-03-08 22:41     ` Yann Dirson
  2006-03-09 11:50   ` [PATCH] contrib/git-svn: remove the --no-stop-on-copy flag Eric Wong
  2 siblings, 1 reply; 9+ messages in thread
From: Yann Dirson @ 2006-03-08 22:15 UTC (permalink / raw)
  To: Eric Wong; +Cc: GIT list

On Tue, Mar 07, 2006 at 05:42:07PM -0800, Eric Wong wrote:
> If you want full repository history for reorganized repositories,
> easiest way is to pay the price for full repository and all of its
> history.
> 
> 	git-svn init https://svn.sourceforge.net/svnroot/ufoai
> 	git-svn fetch
> 	# this puts all your branches and tags into one single big git tree.
> 
> However, the following should always work: (after the following patch,
> 
> 	GIT_SVN_ID=git-oldsvn git-svn init \
> 		https://svn.sourceforge.net/svnroot/ufoai/trunk
> 	GIT_SVN_ID=git-oldsvn git-svn fetch -r1:165
> 
> 	GIT_SVN_ID=git-newsvn git-svn init
> 		https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk
> 	GIT_SVN_ID=git-newsvn git-svn fetch \
> 		166=`git-rev-parse refs/remotes/git-oldsvn`

Thanks much for the hint - it should definitively be a good example
for the doc.

> Unfortunately, it does not, at least with svn 1.2.3...  I have a patch
> coming that should fix things for 1.1.1 (and give better 1.1.x support
> in general).  I'm not sure, but it feels like something is screwed up
> with svn 1.2.3dfsg1-3:
> 
> This works:	svn log -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk

> This doesn't:	svn  co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk
> 
> But this:	svn  co -r1 https://svn.sourceforge.net/svnroot/ufoai
> will create the following structure:
> 	ufoai/{trunk,branches,tags}
> 
> I'm quite puzzled about it, as I swear I've seen it work on a different
> project recently (of course I cannot remember which :<)

Looks like svn may be looking at the current revision to find out
which path you are requesting, and that path does not exist any more.
Could look like something normal, if "svn log" complained - but the
problem may just be with "svn log".

OTOH, this does work:

 svn co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk@1


> In the face of repository reorgs, git-svn is happiest tracking partial
> history.  Or tracking the entire repository from the root.

Well, that could be a solution, if I could 1) filter out parts of the
tree I do not care about, and 2) strip the leading /whatever/trunk.
Not sure it's worth it :)


> Hopefully I've been reasonably coherent, having insomnia lately.

At least, my state of insomnia makes it look perferctly coherent :)

Best regards,
-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

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

* Re: git-svn, tree moves, and --no-stop-on-copy
  2006-03-08 22:15   ` git-svn, tree moves, and --no-stop-on-copy Yann Dirson
@ 2006-03-08 22:41     ` Yann Dirson
  0 siblings, 0 replies; 9+ messages in thread
From: Yann Dirson @ 2006-03-08 22:41 UTC (permalink / raw)
  To: Eric Wong; +Cc: GIT list

On Wed, Mar 08, 2006 at 11:15:24PM +0100, Yann Dirson wrote:
> OTOH, this does work:
> 
>  svn co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk@1

Let's go further:

@@ -224,12 +227,14 @@ sub fetch {
        unless (-d $SVN_WC) {
                my @svn_co = ('svn','co',"-r$base->{revision}");
                push @svn_co,'--ignore-externals' unless $_no_ignore_ext;
-               sys(@svn_co, $SVN_URL, $SVN_WC);
+               sys(@svn_co, $SVN_URL . "\@$base->{revision}", $SVN_WC);
                chdir $SVN_WC or croak $!;


That allows git-svn not to fail at r1 (or at r3 when checking out
trunk/src only), and the 1st fetch runs OK.

The second fetch runs OK as well, but it shows the following somewhat
scary stuff before starting the import:

Checked out revision 166.
refs/remotes/git-newsvn
fatal: 'refs/remotes/git-newsvn': No such file or directory
r166 = 38a6ba0e3db486c65a611c54c53f838210ce7551


The results looks fine.  I don't know if it is expected to have the
master head stuck at remotes/git-oldsvn, though.

Thanks much for your help!
-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

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

* Re: [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args
  2006-03-08  1:57   ` [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args Eric Wong
@ 2006-03-09 10:08     ` Junio C Hamano
  2006-03-09 11:48       ` [PATCH] contrib/git-svn: fix svn compat and " Eric Wong
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2006-03-09 10:08 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

Eric Wong <normalperson@yhbt.net> writes:

> Junio: please don't apply this patch to git.git just yet.  It seems fine
> to me, but I haven't tested it heavily yet (Yann can help me, I hope :)
> I hardly slept the past few days and I may have broken something badly
> (it pasts all the tests, though).

I won't be applying it then.

I think this part is wrong.

> @@ -922,7 +930,9 @@ sub git_commit {
>  	}
>  	my @update_ref = ('git-update-ref',"refs/remotes/$GIT_SVN",$commit);
>  	if (my $primary_parent = shift @exec_parents) {
> -		push @update_ref, $primary_parent;
> +		if (!system('git-rev-parse',"refs/remotes/$GIT_SVN")){
> +			push @update_ref, $primary_parent;
> +		}

I think you are trying to see if you have .git/refs/remotes/foo,
and I think you actually have tried it to determine that is the
case.

But "git-rev-parse refs/remotes/foo" dies not because there is
no valid file .git/refs/remotes/foo that records SHA1 of an
existing commit.  If there is refs/remotes/foo file, it thinks
you have asked for it and gives it back happily.

A demonstration:

	$ cd /var/tmp/ && rm -fr junk && mkdir junk && cd junk
        $ git init-db
	defaulting to local storage area
        $ git-rev-parse refs/remotes/foo ; echo $?
        refs/remotes/foo
        fatal: 'refs/remotes/foo': No such file or directory
        128
        $ mkdir -p refs/remotes/foo
        $ ls -a
        ./  ../  .git/	refs/
        $ git-rev-parse refs/remotes/foo; echo $?
        refs/remotes/foo
        0

If you are trying to see if there is such a ref, I would do
this:

	$ git-rev-parse --verify refs/remotes/foo^0
        git-rev-parse --verify refs/remotes/foo^0
        fatal: Needed a single revision
	128

The --verify flag makes sure that the argument resolves to a
valid 40-hexadigit string (note that it does not verify if that
object actually exists), so asking for zeroth parent makes sure
you are dealing with a ref that actually points at a commit
object that exists.

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

* [PATCH] contrib/git-svn: fix svn compat and fetch args
  2006-03-09 10:08     ` Junio C Hamano
@ 2006-03-09 11:48       ` Eric Wong
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Wong @ 2006-03-09 11:48 UTC (permalink / raw)
  To: Junio C Hamano, Yann Dirson; +Cc: git

'svn info' doesn't work with URLs in svn <= 1.1.  Now we
only run svn info in local directories.

As a side effect, this should also work better for 'init' off
directories that are no longer in the latest revision of the
repository.

svn checkout -r<revision> arguments are fixed.
Newer versions of svn (1.2.x) seem to need URL@REV as well as
-rREV to checkout a particular revision...

Add an example in the manpage of how to track directory that has
been moved since its initial revision.

A huge thanks to Yann Dirson for the bug reporting and testing
my original patch.  Thanks also to Junio C Hamano for suggesting
a safer way to use git-rev-parse.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

  Junio C Hamano <junkio@cox.net> wrote:
  > Eric Wong <normalperson@yhbt.net> writes:
  > 
  > > Junio: please don't apply this patch to git.git just yet.  It seems fine
  > > to me, but I haven't tested it heavily yet (Yann can help me, I hope :)
  > > I hardly slept the past few days and I may have broken something badly
  > > (it pasts all the tests, though).
  > 
  > I won't be applying it then.

  You can apply this one :)

  > I think this part is wrong.

  Cool, thanks for the example.

 contrib/git-svn/git-svn.perl |   63 ++++++++++++++++++++++++++++++------------
 contrib/git-svn/git-svn.txt  |   32 ++++++++++++++++++++-
 2 files changed, 75 insertions(+), 20 deletions(-)

1e07c915bbc3ff06967a85a71c0cbad82fa40cf6
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 3c860e4..dca4e5c 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -30,6 +30,7 @@ my $sha1_short = qr/[a-f\d]{4,40}/;
 my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
 	$_find_copies_harder, $_l, $_version, $_upgrade, $_authors);
 my (@_branch_from, %tree_map, %users);
+my $_svn_co_url_revs;
 
 my %fc_opts = ( 'no-ignore-externals' => \$_no_ignore_ext,
 		'branch|b=s' => \@_branch_from,
@@ -77,7 +78,7 @@ usage(0) if $_help;
 version() if $_version;
 usage(1) unless defined $cmd;
 load_authors() if $_authors;
-svn_check_ignore_externals();
+svn_compat_check();
 $cmd{$cmd}->[0]->(@ARGV);
 exit 0;
 
@@ -162,7 +163,8 @@ sub rebuild {
 				croak "SVN repository location required: $url\n";
 			}
 			$SVN_URL ||= $url;
-			$SVN_UUID ||= setup_git_svn();
+			$SVN_UUID ||= $uuid;
+			setup_git_svn();
 			$latest = $rev;
 		}
 		assert_revision_eq_or_unknown($rev, $c);
@@ -171,9 +173,7 @@ sub rebuild {
 	}
 	close $rev_list or croak $?;
 	if (!chdir $SVN_WC) {
-		my @svn_co = ('svn','co',"-r$latest");
-		push @svn_co, '--ignore-externals' unless $_no_ignore_ext;
-		sys(@svn_co, $SVN_URL, $SVN_WC);
+		svn_cmd_checkout($SVN_URL, $latest, $SVN_WC);
 		chdir $SVN_WC or croak $!;
 	}
 
@@ -222,14 +222,14 @@ sub fetch {
 	my $base = shift @$svn_log or croak "No base revision!\n";
 	my $last_commit = undef;
 	unless (-d $SVN_WC) {
-		my @svn_co = ('svn','co',"-r$base->{revision}");
-		push @svn_co,'--ignore-externals' unless $_no_ignore_ext;
-		sys(@svn_co, $SVN_URL, $SVN_WC);
+		svn_cmd_checkout($SVN_URL,$base->{revision},$SVN_WC);
 		chdir $SVN_WC or croak $!;
+		read_uuid();
 		$last_commit = git_commit($base, @parents);
 		assert_svn_wc_clean($base->{revision}, $last_commit);
 	} else {
 		chdir $SVN_WC or croak $!;
+		read_uuid();
 		$last_commit = file_to_s("$REV_DIR/$base->{revision}");
 	}
 	my @svn_up = qw(svn up);
@@ -275,7 +275,9 @@ sub commit {
 
 	fetch();
 	chdir $SVN_WC or croak $!;
-	my $svn_current_rev =  svn_info('.')->{'Last Changed Rev'};
+	my $info = svn_info('.');
+	read_uuid($info);
+	my $svn_current_rev =  $info->{'Last Changed Rev'};
 	foreach my $c (@revs) {
 		my $mods = svn_checkout_tree($svn_current_rev, $c);
 		if (scalar @$mods == 0) {
@@ -314,6 +316,14 @@ sub show_ignore {
 
 ########################### utility functions #########################
 
+sub read_uuid {
+	return if $SVN_UUID;
+	my $info = shift || svn_info('.');
+	$SVN_UUID = $info->{'Repository UUID'} or
+					croak "Repository UUID unreadable\n";
+	s_to_file($SVN_UUID,"$GIT_DIR/$GIT_SVN/info/uuid");
+}
+
 sub setup_git_svn {
 	defined $SVN_URL or croak "SVN repository location required\n";
 	unless (-d $GIT_DIR) {
@@ -323,14 +333,10 @@ sub setup_git_svn {
 	mkpath(["$GIT_DIR/$GIT_SVN/info"]);
 	mkpath([$REV_DIR]);
 	s_to_file($SVN_URL,"$GIT_DIR/$GIT_SVN/info/url");
-	$SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or
-					croak "Repository UUID unreadable\n";
-	s_to_file($SVN_UUID,"$GIT_DIR/$GIT_SVN/info/uuid");
 
 	open my $fd, '>>', "$GIT_DIR/$GIT_SVN/info/exclude" or croak $!;
 	print $fd '.svn',"\n";
 	close $fd or croak $!;
-	return $SVN_UUID;
 }
 
 sub assert_svn_wc_clean {
@@ -860,7 +866,6 @@ sub git_commit {
 	my ($log_msg, @parents) = @_;
 	assert_revision_unknown($log_msg->{revision});
 	my $out_fh = IO::File->new_tmpfile or croak $!;
-	$SVN_UUID ||= svn_info('.')->{'Repository UUID'};
 
 	map_tree_joins() if (@_branch_from && !%tree_map);
 
@@ -922,7 +927,16 @@ sub git_commit {
 	}
 	my @update_ref = ('git-update-ref',"refs/remotes/$GIT_SVN",$commit);
 	if (my $primary_parent = shift @exec_parents) {
-		push @update_ref, $primary_parent;
+		$pid = fork;
+		defined $pid or croak $!;
+		if (!$pid) {
+			close STDERR;
+			close STDOUT;
+			exec 'git-rev-parse','--verify',
+						"refs/remotes/$GIT_SVN^0";
+		}
+		waitpid $pid, 0;
+		push @update_ref, $primary_parent unless $?;
 	}
 	sys(@update_ref);
 	sys('git-update-ref',"$GIT_SVN/revs/$log_msg->{revision}",$commit);
@@ -995,13 +1009,26 @@ sub safe_qx {
 	return wantarray ? @ret : join('',@ret);
 }
 
-sub svn_check_ignore_externals {
-	return if $_no_ignore_ext;
-	unless (grep /ignore-externals/,(safe_qx(qw(svn co -h)))) {
+sub svn_compat_check {
+	my @co_help = safe_qx(qw(svn co -h));
+	unless (grep /ignore-externals/,@co_help) {
 		print STDERR "W: Installed svn version does not support ",
 				"--ignore-externals\n";
 		$_no_ignore_ext = 1;
 	}
+	if (grep /usage: checkout URL\[\@REV\]/,@co_help) {
+		$_svn_co_url_revs = 1;
+	}
+}
+
+# *sigh*, new versions of svn won't honor -r<rev> without URL@<rev>,
+# (and they won't honor URL@<rev> without -r<rev>, too!)
+sub svn_cmd_checkout {
+	my ($url, $rev, $dir) = @_;
+	my @cmd = ('svn','co', "-r$rev");
+	push @cmd, '--ignore-externals' unless $_no_ignore_ext;
+	$url .= "\@$rev" if $_svn_co_url_revs;
+	sys(@cmd, $url, $dir);
 }
 
 sub check_upgrade_needed {
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 8e9a971..5fb5b7c 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -175,8 +175,8 @@ COMPATIBILITY OPTIONS
 	Do not use this flag unless you know exactly what you're getting
 	yourself into.  You have been warned.
 
-Examples
-~~~~~~~~
+Basic Examples
+~~~~~~~~~~~~~~
 
 Tracking and contributing to an Subversion managed-project:
 
@@ -234,6 +234,34 @@ This allows you to tie unfetched SVN rev
 
 	git-svn fetch 375=$(git-rev-parse HEAD)
 
+Advanced Example: Tracking a Reorganized Repository
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If you're tracking a directory that has moved, or otherwise been
+branched or tagged off of another directory in the repository and you
+care about the full history of the project, then you can read this
+section.
+
+This is how Yann Dirson tracked the trunk of the ufoai directory when
+the /trunk directory of his repository was moved to /ufoai/trunk and
+he needed to continue tracking /ufoai/trunk where /trunk left off.
+
+	# This log message shows when the repository was reorganized::
+	r166 | ydirson | 2006-03-02 01:36:55 +0100 (Thu, 02 Mar 2006) | 1 line
+	Changed paths:
+	   D /trunk
+	   A /ufoai/trunk (from /trunk:165)
+
+	# First we start tracking the old revisions::
+	GIT_SVN_ID=git-oldsvn git-svn init \
+	      https://svn.sourceforge.net/svnroot/ufoai/trunk
+	GIT_SVN_ID=git-oldsvn git-svn fetch -r1:165
+
+	# And now, we continue tracking the new revisions::
+	GIT_SVN_ID=git-newsvn git-svn init \
+	      https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk
+	GIT_SVN_ID=git-newsvn git-svn fetch \
+	      166=`git-rev-parse refs/remotes/git-oldsvn`
+
 BUGS
 ----
 If somebody commits a conflicting changeset to SVN at a bad moment
-- 
1.2.4.ga2910

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

* [PATCH] contrib/git-svn: remove the --no-stop-on-copy flag
  2006-03-08  1:42 ` Eric Wong
  2006-03-08  1:57   ` [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args Eric Wong
  2006-03-08 22:15   ` git-svn, tree moves, and --no-stop-on-copy Yann Dirson
@ 2006-03-09 11:50   ` Eric Wong
  2 siblings, 0 replies; 9+ messages in thread
From: Eric Wong @ 2006-03-09 11:50 UTC (permalink / raw)
  To: Yann Dirson, Junio C Hamano; +Cc: GIT list

Output a big warning if somebody actually has a pre-1.0 version
of svn that doesn't support it.

Thanks to Yann Dirson for reminding me it still existed
and attempting to re-enable it :)

I think I subconciously removed support for it earlier...

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.perl |   11 +++++++++++
 contrib/git-svn/git-svn.txt  |   13 -------------
 2 files changed, 11 insertions(+), 13 deletions(-)

0ec45e489232fad4f1aa3d2c648fa53295efd7ec
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index dca4e5c..43b50ec 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -1019,6 +1019,17 @@ sub svn_compat_check {
 	if (grep /usage: checkout URL\[\@REV\]/,@co_help) {
 		$_svn_co_url_revs = 1;
 	}
+
+	# I really, really hope nobody hits this...
+	unless (grep /stop-on-copy/, (safe_qx(qw(svn log -h)))) {
+		print STDERR <<'';
+W: The installed svn version does not support the --stop-on-copy flag in
+   the log command.
+   Lets hope the directory you're tracking is not a branch or tag
+   and was never moved within the repository...
+
+		$_no_stop_copy = 1;
+	}
 }
 
 # *sigh*, new versions of svn won't honor -r<rev> without URL@<rev>,
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 5fb5b7c..7a6e0c4 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -162,19 +162,6 @@ COMPATIBILITY OPTIONS
 	Otherwise, do not enable this flag unless you know what you're
 	doing.
 
---no-stop-on-copy::
-	Only used with the 'fetch' command.
-
-	By default, git-svn passes --stop-on-copy to avoid dealing with
-	the copied/renamed branch directory problem entirely.  A
-	copied/renamed branch is the result of a <SVN_URL> being created
-	in the past from a different source.  These are problematic to
-	deal with even when working purely with svn if you work inside
-	subdirectories.
-
-	Do not use this flag unless you know exactly what you're getting
-	yourself into.  You have been warned.
-
 Basic Examples
 ~~~~~~~~~~~~~~
 
-- 
1.2.4.ga2910

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

end of thread, other threads:[~2006-03-09 11:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-07 22:08 git-svn, tree moves, and --no-stop-on-copy Yann Dirson
2006-03-08  1:42 ` Eric Wong
2006-03-08  1:57   ` [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args Eric Wong
2006-03-09 10:08     ` Junio C Hamano
2006-03-09 11:48       ` [PATCH] contrib/git-svn: fix svn compat and " Eric Wong
2006-03-08 22:15   ` git-svn, tree moves, and --no-stop-on-copy Yann Dirson
2006-03-08 22:41     ` Yann Dirson
2006-03-09 11:50   ` [PATCH] contrib/git-svn: remove the --no-stop-on-copy flag Eric Wong
2006-03-08 17:02 ` git-svn, tree moves, and --no-stop-on-copy Matthias Urlichs

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