From a515ff57d059d333d62e469e2afb0fa0dbbb5178 Mon Sep 17 00:00:00 2001 From: Christopher Sean Morrison Date: Fri, 23 Aug 2013 16:14:23 -0400 Subject: [PATCH 1/3] add support for when extracting HEAD:1 times out the network connection. this streams the log back in that case (which keeps the network pipe open) and grabs the last revision. --- lib/scm/adapters/svn_chain/chain.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/scm/adapters/svn_chain/chain.rb b/lib/scm/adapters/svn_chain/chain.rb index af23523b..86c92500 100644 --- a/lib/scm/adapters/svn_chain/chain.rb +++ b/lib/scm/adapters/svn_chain/chain.rb @@ -79,7 +79,16 @@ def first_commit(after=0) # Returns the first commit with a revision number greater than the provided revision number def next_revision_xml(after=0) return "" if after.to_i >= head_token - run "svn log --trust-server-cert --non-interactive --verbose --xml --stop-on-copy -r #{after.to_i+1}:#{final_token || 'HEAD'} --limit 1 #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'" + back_to_front = "svn log --trust-server-cert --non-interactive --verbose --xml --stop-on-copy -r #{after.to_i+1}:#{final_token || 'HEAD'} --limit 1 #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'" + front_to_back = "svn log --trust-server-cert --non-interactive --verbose --xml --stop-on-copy -r #{final_token || 'HEAD'}:#{after.to_i+1} #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'" + # if the repository history is so extensive or + # the remote server so slow that the network + # connection times out before there is a + # response, use a slower and more resource + # intensive method that should always succeed: + # receive the revisions in order and extract + # the last entry. + run(back_to_front) || Scm::Parsers::SvnXmlParser.parse(run(front_to_back)).last end # If the passed diff represents the wholesale movement of the entire From e6c88ca8adf032768ffd1a41c5e5b6202a5cc794 Mon Sep 17 00:00:00 2001 From: Christopher Sean Morrison Date: Fri, 23 Aug 2013 16:45:34 -0400 Subject: [PATCH 2/3] add support for when extracting HEAD:1 times out the network connection. this streams the log back in that case (which keeps the network pipe open) and grabs the last one. --- lib/scm/adapters/svn_chain/chain.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/scm/adapters/svn_chain/chain.rb b/lib/scm/adapters/svn_chain/chain.rb index af23523b..86c92500 100644 --- a/lib/scm/adapters/svn_chain/chain.rb +++ b/lib/scm/adapters/svn_chain/chain.rb @@ -79,7 +79,16 @@ def first_commit(after=0) # Returns the first commit with a revision number greater than the provided revision number def next_revision_xml(after=0) return "" if after.to_i >= head_token - run "svn log --trust-server-cert --non-interactive --verbose --xml --stop-on-copy -r #{after.to_i+1}:#{final_token || 'HEAD'} --limit 1 #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'" + back_to_front = "svn log --trust-server-cert --non-interactive --verbose --xml --stop-on-copy -r #{after.to_i+1}:#{final_token || 'HEAD'} --limit 1 #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'" + front_to_back = "svn log --trust-server-cert --non-interactive --verbose --xml --stop-on-copy -r #{final_token || 'HEAD'}:#{after.to_i+1} #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'" + # if the repository history is so extensive or + # the remote server so slow that the network + # connection times out before there is a + # response, use a slower and more resource + # intensive method that should always succeed: + # receive the revisions in order and extract + # the last entry. + run(back_to_front) || Scm::Parsers::SvnXmlParser.parse(run(front_to_back)).last end # If the passed diff represents the wholesale movement of the entire From be678aaa738be1634efc7056de2f9b6aa7d8ce81 Mon Sep 17 00:00:00 2001 From: Christopher Sean Morrison Date: Mon, 26 Aug 2013 15:12:53 -0400 Subject: [PATCH 3/3] PeterDP noted that run() does not return a truth value; read a snippet wrong. push the conditional down into sh land and let the xml parser just always pull the last one (which will be the first one with --limit 1) --- lib/scm/adapters/svn_chain/chain.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scm/adapters/svn_chain/chain.rb b/lib/scm/adapters/svn_chain/chain.rb index 86c92500..e20ac5be 100644 --- a/lib/scm/adapters/svn_chain/chain.rb +++ b/lib/scm/adapters/svn_chain/chain.rb @@ -73,7 +73,7 @@ def first_token(after=0) def first_commit(after=0) @first_commit ||={} # Poor man's memoize - @first_commit[after] ||= Scm::Parsers::SvnXmlParser.parse(next_revision_xml(after)).first + @first_commit[after] ||= Scm::Parsers::SvnXmlParser.parse(next_revision_xml(after)).last end # Returns the first commit with a revision number greater than the provided revision number @@ -88,7 +88,7 @@ def next_revision_xml(after=0) # intensive method that should always succeed: # receive the revisions in order and extract # the last entry. - run(back_to_front) || Scm::Parsers::SvnXmlParser.parse(run(front_to_back)).last + run("#{back_to_front} || #{front_to_back}") end # If the passed diff represents the wholesale movement of the entire