{"thread":{"id":"13941","subject":"[PATCH] git-svn: follow revisions of svm-mirrored repositories","startedAt":"2008-06-14T04:02:29Z","lastAt":"2008-06-18T02:58:06Z","messageCount":4,"participants":["João Abecasis","Sam Vilain"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"79802","messageId":"7bf6f1d20806132102x71422617s26260fdc348a7c04@mail.gmail.com","threadId":"13941","inReplyTo":null,"subject":"[PATCH] git-svn: follow revisions of svm-mirrored repositories","fromName":"João Abecasis","fromEmail":"joao@abecasis.name","sentAt":"2008-06-14T04:02:29Z","receivedAt":"2008-06-14T04:02:29Z","isPatch":true,"sender":{"key":"joao@abecasis.name","avatar":"https://gravatar.com/avatar/6c28d507fdac73de84e9ea793d82c718ae46c5e96ef25c9171c9b7f697131c4e?d=mp&s=160"},"body":"Hi,\n\nWhen using an svk mirror repository as the source for git-svn,\nfind-rev and rebase don't work.\n\nfind-rev takes a while, while it traverses and processes commit logs\nfor the branch, and ultimately fails with the error message: \"Unable\nto determine upstream SVN information from git-svn history\". This\nhappens because find-rev doesn't relate information in the commit\nmessages to the internal svm-source revision maps.\n\nSimilarly, rebase is faster but still exits with the message \"Unable\nto determine upstream SVN information from working tree history\".\n\nThe attached patch fixes a couple of underlying issues to get at least\nthese two commands working. AFAICT it still works well with plain svn\nrepositories.\n\nCan this be merged upstream? Any comments are welcome.\n\nCheers,\n\n\n-- João\n\n\nFrom 9e348a4a25d0ea1fe48dcf5175a2853267933860 Mon Sep 17 00:00:00 2001\nFrom: =?utf-8?q?Jo=C3=A3o=20Abecasis?= <joao@abecasis.name>\nDate: Fri, 13 Jun 2008 20:32:57 -0500\nSubject: [PATCH] git-svn: follow revisions of svm-mirrored repositories\n\nAlthough git-svn keeps track of source revisions in svm-mirrored\nrepositories, it doesn't use that information in all places.\n\nThis fixes working_head_info and Git::SVN::find_by_url to work with\nmirrored repositories when useSvmProps is set. At least the commands\nfind-rev and rebase, which didn't work for me with svm-mirrored\nrepositories, are now working.\n---\n git-svn.perl |   25 +++++++++++++++++++++----\n 1 files changed, 21 insertions(+), 4 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 47b0c37..db054d2 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -537,13 +537,13 @@ sub cmd_find_rev {\n \t\tmy $head = shift;\n \t\t$head ||= 'HEAD';\n \t\tmy @refs;\n-\t\tmy (undef, undef, undef, $gs) = working_head_info($head, \\@refs);\n+\t\tmy (undef, undef, $uuid, $gs) = working_head_info($head, \\@refs);\n \t\tunless ($gs) {\n \t\t\tdie \"Unable to determine upstream SVN information from \",\n \t\t\t    \"$head history\\n\";\n \t\t}\n \t\tmy $desired_revision = substr($revision_or_hash, 1);\n-\t\t$result = $gs->rev_map_get($desired_revision);\n+\t\t$result = $gs->rev_map_get($desired_revision, $uuid);\n \t} else {\n \t\tmy (undef, $rev, undef) = cmt_metadata($revision_or_hash);\n \t\t$result = $rev;\n@@ -1158,7 +1158,7 @@ sub working_head_info {\n \t\tif (defined $url && defined $rev) {\n \t\t\tnext if $max{$url} and $max{$url} < $rev;\n \t\t\tif (my $gs = Git::SVN->find_by_url($url)) {\n-\t\t\t\tmy $c = $gs->rev_map_get($rev);\n+\t\t\t\tmy $c = $gs->rev_map_get($rev, $uuid);\n \t\t\t\tif ($c && $c eq $hash) {\n \t\t\t\t\tclose $fh; # break the pipe\n \t\t\t\t\treturn ($url, $rev, $uuid, $gs);\n@@ -1417,6 +1417,16 @@ sub read_all_remotes {\n \t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n \t\t\t$local_ref =~ s{^/}{};\n \t\t\t$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;\n+\t\t} elsif (m!^(.+)\\.usesvmprops=\\s*(.*)\\s*$!) {\n+\t\t\tmy $svm;\n+\t\t\teval {\n+\t\t\t\tmy $section = \"svn-remote.$1\";\n+\t\t\t\t$svm = {\n+\t\t\t\t\tsource => tmp_config('--get', \"$section.svm-source\"),\n+\t\t\t\t\treplace => tmp_config('--get', \"$section.svm-replace\"),\n+\t\t\t\t}\n+\t\t\t};\n+\t\t\t$r->{$1}->{svm} = $svm;\n \t\t} elsif (m!^(.+)\\.url=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{url} = $2;\n \t\t} elsif (m!^(.+)\\.(branches|tags)=\n@@ -1566,13 +1576,20 @@ sub find_by_url { # repos_root and, path are optional\n \t\t}\n \t\tmy $p = $path;\n \t\tmy $rwr = rewrite_root({repo_id => $repo_id});\n+\t\tmy $svm = $remotes->{$repo_id}->{svm}\n+\t\t\tif defined $remotes->{$repo_id}->{svm};\n \t\tunless (defined $p) {\n \t\t\t$p = $full_url;\n \t\t\tmy $z = $u;\n+\t\t\tmy $prefix = '';\n \t\t\tif ($rwr) {\n \t\t\t\t$z = $rwr;\n+\t\t\t} elsif (defined $svm) {\n+\t\t\t\t$z = $svm->{source};\n+\t\t\t\t$prefix = $svm->{replace};\n+\t\t\t\t$prefix =~ s#^\\Q$u\\E(?=/|$)##;\n \t\t\t}\n-\t\t\t$p =~ s#^\\Q$z\\E(?:/|$)## or next;\n+\t\t\t$p =~ s#^\\Q$z\\E(?:/|$)#$prefix# or next;\n \t\t}\n \t\tforeach my $f (keys %$fetch) {\n \t\t\tnext if $f ne $p;\n-- \n1.5.5.1\n\n"},{"id":"79963","messageId":"485589F5.6020409@vilain.net","threadId":"13941","inReplyTo":"7bf6f1d20806132102x71422617s26260fdc348a7c04@mail.gmail.com","subject":"Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2008-06-15T21:30:29Z","receivedAt":"2008-06-15T21:30:29Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"João Abecasis wrote:\n> Hi,\n> \n> When using an svk mirror repository as the source for git-svn,\n> find-rev and rebase don't work.\n> \n> find-rev takes a while, while it traverses and processes commit logs\n> for the branch, and ultimately fails with the error message: \"Unable\n> to determine upstream SVN information from git-svn history\". This\n> happens because find-rev doesn't relate information in the commit\n> messages to the internal svm-source revision maps.\n> \n> Similarly, rebase is faster but still exits with the message \"Unable\n> to determine upstream SVN information from working tree history\".\n> \n> The attached patch fixes a couple of underlying issues to get at least\n> these two commands working. AFAICT it still works well with plain svn\n> repositories.\n> \n> Can this be merged upstream? Any comments are welcome.\n\nCan you give an approximate series of commands that led to this not\nworking?  Just to clarify what happened.  Ideally, it would be a test\ncase; see if you can add it to the existing SVM test case.  In fact this\nmight be a regression compared to the original support, due to lack of\ntests - in which case it would be good to fix this \"for good\".\n\nAlso, please try to send your patches inline if possible, or at least\ntry to get them to be Content-Disposition: inline, it makes review\neasier for casual list subscribers.\n\nThanks,\nSam.\n"},{"id":"80192","messageId":"7bf6f1d20806171957k29dbdd4fh52c3b515e7b573d@mail.gmail.com","threadId":"13941","inReplyTo":"485589F5.6020409@vilain.net","subject":"Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories","fromName":"João Abecasis","fromEmail":"joao@abecasis.name","sentAt":"2008-06-18T02:57:29Z","receivedAt":"2008-06-18T02:57:29Z","isPatch":true,"sender":{"key":"joao@abecasis.name","avatar":"https://gravatar.com/avatar/6c28d507fdac73de84e9ea793d82c718ae46c5e96ef25c9171c9b7f697131c4e?d=mp&s=160"},"body":"Hi Sam,\n\nThanks for your reply. I'm currently on the road so may be a little\nslow to respond. Please bear with me.\n\nSam Vilain wrote:\n>> When using an svk mirror repository as the source for git-svn,\n>> find-rev and rebase don't work.\n>>\n>> find-rev takes a while, while it traverses and processes commit logs\n>> for the branch, and ultimately fails with the error message: \"Unable\n>> to determine upstream SVN information from git-svn history\". This\n>> happens because find-rev doesn't relate information in the commit\n>> messages to the internal svm-source revision maps.\n>>\n>> Similarly, rebase is faster but still exits with the message \"Unable\n>> to determine upstream SVN information from working tree history\".\n>>\n>> The attached patch fixes a couple of underlying issues to get at least\n>> these two commands working. AFAICT it still works well with plain svn\n>> repositories.\n>>\n>> Can this be merged upstream? Any comments are welcome.\n>\n> Can you give an approximate series of commands that led to this not\n> working?  Just to clarify what happened.  Ideally, it would be a test\n> case; see if you can add it to the existing SVM test case.  In fact this\n> might be a regression compared to the original support, due to lack of\n> tests - in which case it would be good to fix this \"for good\".\n\nI haven't tried the test cases yet, but will look into it. Perhaps\nthat can also hammer out other places where svm-mirror support is\nincomplete.\n\nIn the meantime, reproducing the 2 issues my patch is supposed to fix\nis rather straightforward, but there could be something that I missed,\nso here goes:\n\n    # Preparation, skipped informational messages.\n    $ git init\n    $ git svn init --use-svm-props -s file:///path/to/svk/repository/and/mirror/\n    # Populate repository\n    $ git svn fetch\n\n    # And the missing functionality.\n    $ git svn rebase\n    Unable to determine upstream SVN information from working tree history\n\n    $ git svn find-rev r5\n    Unable to determine upstream SVN information from HEAD history\n\nAnd trying out the test case I just noticed an issue with my previous\npatch, with misplaced // -- somehow it didn't show up in my previous\ntests. I'll post an updated patch, shortly.\n\n> Also, please try to send your patches inline if possible, or at least\n> try to get them to be Content-Disposition: inline, it makes review\n> easier for casual list subscribers.\n\nI was worried that sending patches inlined would break the patch\nbecause of line lengths and such, since I'm using Gmail's web\ninterface. Anyway, I'll try that we'll see how that goes.\n\nCheers,\n\n\nJoão\n"},{"id":"80193","messageId":"7bf6f1d20806171958y4104a77cxf660d2853d391e2d@mail.gmail.com","threadId":"13941","inReplyTo":"7bf6f1d20806171957k29dbdd4fh52c3b515e7b573d@mail.gmail.com","subject":"Re: [PATCH] git-svn: follow revisions of svm-mirrored repositories","fromName":"João Abecasis","fromEmail":"joao@abecasis.name","sentAt":"2008-06-18T02:58:06Z","receivedAt":"2008-06-18T02:58:06Z","isPatch":true,"sender":{"key":"joao@abecasis.name","avatar":"https://gravatar.com/avatar/6c28d507fdac73de84e9ea793d82c718ae46c5e96ef25c9171c9b7f697131c4e?d=mp&s=160"},"body":"Although git-svn keeps track of source revisions in svm-mirrored\nrepositories, it doesn't use that information in all places.\n\nThis fixes working_head_info and Git::SVN::find_by_url to work with\nmirrored repositories when useSvmProps is set. At least the commands\nfind-rev and rebase, which didn't work for me with svm-mirrored\nrepositories, are now working.\n---\n git-svn.perl |   26 ++++++++++++++++++++++----\n 1 files changed, 22 insertions(+), 4 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 47b0c37..51325b6 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -537,13 +537,13 @@ sub cmd_find_rev {\n \t\tmy $head = shift;\n \t\t$head ||= 'HEAD';\n \t\tmy @refs;\n-\t\tmy (undef, undef, undef, $gs) = working_head_info($head, \\@refs);\n+\t\tmy (undef, undef, $uuid, $gs) = working_head_info($head, \\@refs);\n \t\tunless ($gs) {\n \t\t\tdie \"Unable to determine upstream SVN information from \",\n \t\t\t    \"$head history\\n\";\n \t\t}\n \t\tmy $desired_revision = substr($revision_or_hash, 1);\n-\t\t$result = $gs->rev_map_get($desired_revision);\n+\t\t$result = $gs->rev_map_get($desired_revision, $uuid);\n \t} else {\n \t\tmy (undef, $rev, undef) = cmt_metadata($revision_or_hash);\n \t\t$result = $rev;\n@@ -1158,7 +1158,7 @@ sub working_head_info {\n \t\tif (defined $url && defined $rev) {\n \t\t\tnext if $max{$url} and $max{$url} < $rev;\n \t\t\tif (my $gs = Git::SVN->find_by_url($url)) {\n-\t\t\t\tmy $c = $gs->rev_map_get($rev);\n+\t\t\t\tmy $c = $gs->rev_map_get($rev, $uuid);\n \t\t\t\tif ($c && $c eq $hash) {\n \t\t\t\t\tclose $fh; # break the pipe\n \t\t\t\t\treturn ($url, $rev, $uuid, $gs);\n@@ -1417,6 +1417,16 @@ sub read_all_remotes {\n \t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n \t\t\t$local_ref =~ s{^/}{};\n \t\t\t$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;\n+\t\t} elsif (m!^(.+)\\.usesvmprops=\\s*(.*)\\s*$!) {\n+\t\t\tmy $svm;\n+\t\t\teval {\n+\t\t\t\tmy $section = \"svn-remote.$1\";\n+\t\t\t\t$svm = {\n+\t\t\t\t\tsource => tmp_config('--get', \"$section.svm-source\"),\n+\t\t\t\t\treplace => tmp_config('--get', \"$section.svm-replace\"),\n+\t\t\t\t}\n+\t\t\t};\n+\t\t\t$r->{$1}->{svm} = $svm;\n \t\t} elsif (m!^(.+)\\.url=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{url} = $2;\n \t\t} elsif (m!^(.+)\\.(branches|tags)=\n@@ -1566,13 +1576,21 @@ sub find_by_url { # repos_root and, path are optional\n \t\t}\n \t\tmy $p = $path;\n \t\tmy $rwr = rewrite_root({repo_id => $repo_id});\n+\t\tmy $svm = $remotes->{$repo_id}->{svm}\n+\t\t\tif defined $remotes->{$repo_id}->{svm};\n \t\tunless (defined $p) {\n \t\t\t$p = $full_url;\n \t\t\tmy $z = $u;\n+\t\t\tmy $prefix = '';\n \t\t\tif ($rwr) {\n \t\t\t\t$z = $rwr;\n+\t\t\t} elsif (defined $svm) {\n+\t\t\t\t$z = $svm->{source};\n+\t\t\t\t$prefix = $svm->{replace};\n+\t\t\t\t$prefix =~ s#^\\Q$u\\E(?:/|$)##;\n+\t\t\t\t$prefix =~ s#(.+?)/?$#$1/#;\n \t\t\t}\n-\t\t\t$p =~ s#^\\Q$z\\E(?:/|$)## or next;\n+\t\t\t$p =~ s#^\\Q$z\\E(?:/|$)#$prefix# or next;\n \t\t}\n \t\tforeach my $f (keys %$fetch) {\n \t\t\tnext if $f ne $p;\n-- \n1.5.5.1\n"}]}