Permalink
Browse files

Automatically retry aborted SVN fetch operation shell commands if the…

…y fail with a known error condition, happens about every 2000-3000 commits with large repositories.
  • Loading branch information...
1 parent c4bdc11 commit 33468fc1b969da8b560e9aeec5aeb092588e9abc Marc Liyanage committed with Marc Liyanage Aug 16, 2010
Showing with 32 additions and 15 deletions.
  1. +32 −15 git-svn-clone-externals.rb
View
@@ -338,26 +338,43 @@ def shell(cmd, echo_stdout = false, echo_filter = [])
t1 = Time.now
output = []
- Open3.popen3(cmd) do |stdin, stdout, stderr|
- stdin.close
-
- loop do
- ready = select([stdout, stderr])
- readable = ready[0]
- break if stdout.eof?
- readable.each do |io|
- data = io.gets
- next unless data
- if io == stderr
- print data if (verbose? || !echo_filter.find { |x| data =~ x })
- else
- print data if (verbose? || (echo_stdout && ! echo_filter.find { |x| data =~ x }))
- output << data
+ done = false
+ while !done do
+ done = true
+ Open3.popen3(cmd) do |stdin, stdout, stderr|
+ stdin.close
+
+ loop do
+ ready = select([stdout, stderr])
+ readable = ready[0]
+ if stdout.eof?
+ error = stderr.readlines
+ if error.join('') =~ /SSL negotiation failed/
+ done = false
+ puts "shell command #{cmd} failed, retrying..."
+ if cmd =~ /git svn clone/
+ cmd_new = 'git svn fetch'
+ puts "replacing shell command with '#{cmd_new}'"
+ cmd = cmd_new
+ end
+ end
+ break
+ end
+ readable.each do |io|
+ data = io.gets
+ next unless data
+ if io == stderr
+ print data if (verbose? || !echo_filter.find { |x| data =~ x })
+ else
+ print data if (verbose? || (echo_stdout && ! echo_filter.find { |x| data =~ x }))
+ output << data
+ end
end
end
end
end
+
output.each { |x| x.chomp! }
dt = (Time.now - t1).to_f

0 comments on commit 33468fc

Please sign in to comment.