{"thread":{"id":"34365","subject":"[PATCH v2 0/2] allow git-svn fetching to work using serf","startedAt":"2013-07-07T03:39:55Z","lastAt":"2013-07-07T03:39:57Z","messageCount":3,"participants":["Kyle J. McKay"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"222691","messageId":"1373168397-7360-1-git-send-email-mackyle@gmail.com","threadId":"34365","inReplyTo":null,"subject":"[PATCH v2 0/2] allow git-svn fetching to work using serf","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2013-07-07T03:39:55Z","receivedAt":"2013-07-07T03:39:55Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"From: \"Kyle J. McKay\" <mackyle@gmail.com>\n\nThis patch allows git-svn to fetch successfully using the\nserf library when given an https?: url to fetch from.\n\nUnfortunately some svn servers do not seem to be configured\nwell for use with the serf library.  This can cause fetching\nto take longer compared to the neon library or actually\ncause timeouts during the fetch.  When timeouts occur\ngit-svn can be safely restarted to fetch more revisions.\n\nA new temp_is_locked function has been added to Git.pm\nto facilitate using the minimal number of temp files\npossible when using serf.\n\nThe problem that occurs when running git-svn fetch using\nthe serf library is that the previously used temp file\nis not always unlocked before the next temp file needs\nto be used.\n\nTo work around this problem, a new temp name is used\nif the temp name that would otherwise be chosen is\ncurrently locked.\n\nKyle J. McKay (2):\n  Git.pm: add new temp_is_locked function\n  git-svn: allow git-svn fetching to work using serf\n\n perl/Git.pm             | 39 +++++++++++++++++++++++++++++++++------\n perl/Git/SVN/Fetcher.pm |  6 ++++--\n 2 files changed, 37 insertions(+), 8 deletions(-)\n\n-- \n1.8.3\n"},{"id":"222693","messageId":"1373168397-7360-2-git-send-email-mackyle@gmail.com","threadId":"34365","inReplyTo":"1373168397-7360-1-git-send-email-mackyle@gmail.com","subject":"[PATCH v2 1/2] Git.pm: add new temp_is_locked function","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2013-07-07T03:39:56Z","receivedAt":"2013-07-07T03:39:56Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"From: \"Kyle J. McKay\" <mackyle@gmail.com>\n\nThe temp_is_locked function can be used to determine whether\nor not a given name previously passed to temp_acquire is\ncurrently locked.\n\nSigned-off-by: Kyle J. McKay <mackyle@gmail.com>\n---\n perl/Git.pm | 39 +++++++++++++++++++++++++++++++++------\n 1 file changed, 33 insertions(+), 6 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 7a252ef..74d9a73 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -61,7 +61,7 @@ require Exporter;\n                 remote_refs prompt\n                 get_tz_offset\n                 credential credential_read credential_write\n-                temp_acquire temp_release temp_reset temp_path);\n+                temp_acquire temp_is_locked temp_release temp_reset temp_path);\n \n \n =head1 DESCRIPTION\n@@ -1206,6 +1206,35 @@ sub temp_acquire {\n \t$temp_fd;\n }\n \n+=item temp_is_locked ( NAME )\n+\n+Returns true if the internal lock created by a previous C<temp_acquire()>\n+call with C<NAME> is still in effect.\n+\n+When temp_acquire is called on a C<NAME>, it internally locks the temporary\n+file mapped to C<NAME>.  That lock will not be released until C<temp_release()>\n+is called with either the original C<NAME> or the L<File::Handle> that was\n+returned from the original call to temp_acquire.\n+\n+Subsequent attempts to call C<temp_acquire()> with the same C<NAME> will fail\n+unless there has been an intervening C<temp_release()> call for that C<NAME>\n+(or its corresponding L<File::Handle> that was returned by the original\n+C<temp_acquire()> call).\n+\n+If true is returned by C<temp_is_locked()> for a C<NAME>, an attempt to\n+C<temp_acquire()> the same C<NAME> will cause an error unless\n+C<temp_release> is first called on that C<NAME> (or its corresponding\n+L<File::Handle> that was returned by the original C<temp_acquire()> call).\n+\n+=cut\n+\n+sub temp_is_locked {\n+\tmy ($self, $name) = _maybe_self(@_);\n+\tmy $temp_fd = \\$TEMP_FILEMAP{$name};\n+\n+\tdefined $$temp_fd && $$temp_fd->opened && $TEMP_FILES{$$temp_fd}{locked};\n+}\n+\n =item temp_release ( NAME )\n \n =item temp_release ( FILEHANDLE )\n@@ -1247,11 +1276,9 @@ sub _temp_cache {\n \t_verify_require();\n \n \tmy $temp_fd = \\$TEMP_FILEMAP{$name};\n-\tif (defined $$temp_fd and $$temp_fd->opened) {\n-\t\tif ($TEMP_FILES{$$temp_fd}{locked}) {\n-\t\t\tthrow Error::Simple(\"Temp file with moniker '\" .\n-\t\t\t\t$name . \"' already in use\");\n-\t\t}\n+\tif (temp_is_locked($name)) {\n+\t\tthrow Error::Simple(\"Temp file with moniker '\" .\n+\t\t\t$name . \"' already in use\");\n \t} else {\n \t\tif (defined $$temp_fd) {\n \t\t\t# then we're here because of a closed handle.\n-- \n1.8.3\n"},{"id":"222692","messageId":"1373168397-7360-3-git-send-email-mackyle@gmail.com","threadId":"34365","inReplyTo":"1373168397-7360-1-git-send-email-mackyle@gmail.com","subject":"[PATCH v2 2/2] git-svn: allow git-svn fetching to work using serf","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2013-07-07T03:39:57Z","receivedAt":"2013-07-07T03:39:57Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"From: \"Kyle J. McKay\" <mackyle@gmail.com>\n\nWhen attempting to git-svn fetch files from an svn https?: url using\nthe serf library (the only choice starting with svn 1.8) the following\nerrors can occur:\n\nTemp file with moniker 'svn_delta' already in use at Git.pm line 1250\nTemp file with moniker 'git_blob' already in use at Git.pm line 1250\n\nDavid Rothenberger <daveroth@acm.org> has determined the cause to\nbe that ra_serf does not drive the delta editor in a depth-first\nmanner [...]. Instead, the calls come in this order:\n\n1. open_root\n2. open_directory\n3. add_file\n4. apply_textdelta\n5. add_file\n6. apply_textdelta\n\nWhen using the ra_serf access method, git-svn can end up needing\nto create several temp files before the first one is closed.\n\nThis change causes a new temp file moniker to be generated if the\none that would otherwise have been used is currently locked.\n\nSigned-off-by: Kyle J. McKay <mackyle@gmail.com>\n---\n perl/Git/SVN/Fetcher.pm | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex bd17418..10edb27 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -315,11 +315,13 @@ sub change_file_prop {\n sub apply_textdelta {\n \tmy ($self, $fb, $exp) = @_;\n \treturn undef if $self->is_path_ignored($fb->{path});\n-\tmy $fh = $::_repository->temp_acquire('svn_delta');\n+\tmy $suffix = 0;\n+\t++$suffix while $::_repository->temp_is_locked(\"svn_delta_${$}_$suffix\");\n+\tmy $fh = $::_repository->temp_acquire(\"svn_delta_${$}_$suffix\");\n \t# $fh gets auto-closed() by SVN::TxDelta::apply(),\n \t# (but $base does not,) so dup() it for reading in close_file\n \topen my $dup, '<&', $fh or croak $!;\n-\tmy $base = $::_repository->temp_acquire('git_blob');\n+\tmy $base = $::_repository->temp_acquire(\"git_blob_${$}_$suffix\");\n \n \tif ($fb->{blob}) {\n \t\tmy ($base_is_link, $size);\n-- \n1.8.3\n"}]}