{"thread":{"id":"11783","subject":"[PATCH] git-svn: improve repository URL matching when following parents","startedAt":"2008-01-29T09:18:58Z","lastAt":"2008-02-05T08:53:42Z","messageCount":2,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"66831","messageId":"20080129091858.GA4569@soma","threadId":"11783","inReplyTo":null,"subject":"[PATCH] git-svn: improve repository URL matching when following parents","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-01-29T09:18:58Z","receivedAt":"2008-01-29T09:18:58Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Warning!  This patch isn't heavily-tested against remote\nservers, it only helped me limp by on a server I was having\ntrouble with tonight.  I was barely awake when working on this\nand have been living in a different timezone for more than a\nweek, so don't trust it too much unless you're already having\ndifficulty with some servers.\n\nThis way we can avoid the spawning of a new SVN::Ra session by\nreusing the existing one.\n\nThe most problematic issue is that some svn servers disallow\ntoo many connections from a single IP, so this will allow\ngit-svn to fetch from those repositories with a higher success\nrate by using fewer connections.\n\nThis sometimes showed up as a new (and redundant)\n[svn-remote \"$parent_refname\"] entry in $GIT_DIR/svn/.metadata.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n\n Note: there are still cases where git-svn can open more than\n one connection to the SVN server, which can make some SVN\n setups/administrators unhappy.  Unfortunately, I'm pretty sure\n I won't have time to properly fix all of these in the next few\n days.\n\n For now, if you get \"connection closed unexpectedly\" messages\n while fetching (and following parents), just restart git-svn\n and it'll pick up where it left off.\n\n git-svn.perl |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 75e97cc..7ba8c8f 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2226,7 +2226,12 @@ sub find_parent_branch {\n \t\t# just grow a tail if we're not unique enough :x\n \t\t$ref_id .= '-' while find_ref($ref_id);\n \t\tprint STDERR \"Initializing parent: $ref_id\\n\";\n-\t\t$gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);\n+\t\tmy ($u, $p) = ($new_url, '');\n+\t\tif ($u =~ s#^\\Q$url\\E(/|$)##) {\n+\t\t\t$p = $u;\n+\t\t\t$u = $url;\n+\t\t}\n+\t\t$gs = Git::SVN->init($u, $p, $self->{repo_id}, $ref_id, 1);\n \t}\n \tmy ($r0, $parent) = $gs->find_rev_before($r, 1);\n \tif (!defined $r0 || !defined $parent) {\n-- \nEric Wong\n"},{"id":"67490","messageId":"20080205085342.GD15141@hand.yhbt.net","threadId":"11783","inReplyTo":"20080129091858.GA4569@soma","subject":"Re: [PATCH] git-svn: improve repository URL matching when following parents","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-02-05T08:53:42Z","receivedAt":"2008-02-05T08:53:42Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> Warning!  This patch isn't heavily-tested against remote\n> servers, it only helped me limp by on a server I was having\n> trouble with tonight.  I was barely awake when working on this\n> and have been living in a different timezone for more than a\n> week, so don't trust it too much unless you're already having\n> difficulty with some servers.\n\nWarning lifted, please apply to master.\n\n> This way we can avoid the spawning of a new SVN::Ra session by\n> reusing the existing one.\n> \n> The most problematic issue is that some svn servers disallow\n> too many connections from a single IP, so this will allow\n> git-svn to fetch from those repositories with a higher success\n> rate by using fewer connections.\n> \n> This sometimes showed up as a new (and redundant)\n> [svn-remote \"$parent_refname\"] entry in $GIT_DIR/svn/.metadata.\n> \n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> ---\n> \n>  Note: there are still cases where git-svn can open more than\n>  one connection to the SVN server, which can make some SVN\n>  setups/administrators unhappy.  Unfortunately, I'm pretty sure\n>  I won't have time to properly fix all of these in the next few\n>  days.\n\nIt may be a while before I have time to fix this.  If anybody else is\nwilling to step up, please do.\n\nSome notes:\n\nMost of this is related to svn:// (and possibly svn+ssh://) sessions,\nand definitely doesn't apply to file:// servers.\n\nI couldn't find an explicit way to close the socket using the SVN API.\nHowever, the socket does seem to get closed when the refcount of the\nSVN::Ra object hits zero.\n\nIt seems only one SVN::Ra can be active at a time.  Even though it's\npossible to hold multiple sockets open to an SVN server within the same\nprocess (with svn://), the SVN library code doesn't work well with\nmultiple sessions active.\n\n>  For now, if you get \"connection closed unexpectedly\" messages\n>  while fetching (and following parents), just restart git-svn\n>  and it'll pick up where it left off.\n> \n>  git-svn.perl |    7 ++++++-\n>  1 files changed, 6 insertions(+), 1 deletions(-)\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index 75e97cc..7ba8c8f 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -2226,7 +2226,12 @@ sub find_parent_branch {\n>  \t\t# just grow a tail if we're not unique enough :x\n>  \t\t$ref_id .= '-' while find_ref($ref_id);\n>  \t\tprint STDERR \"Initializing parent: $ref_id\\n\";\n> -\t\t$gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);\n> +\t\tmy ($u, $p) = ($new_url, '');\n> +\t\tif ($u =~ s#^\\Q$url\\E(/|$)##) {\n> +\t\t\t$p = $u;\n> +\t\t\t$u = $url;\n> +\t\t}\n> +\t\t$gs = Git::SVN->init($u, $p, $self->{repo_id}, $ref_id, 1);\n>  \t}\n>  \tmy ($r0, $parent) = $gs->find_rev_before($r, 1);\n>  \tif (!defined $r0 || !defined $parent) {\n\n-- \nEric Wong\n"}]}