diff --git a/lib/scm/adapters/svn_chain/chain.rb b/lib/scm/adapters/svn_chain/chain.rb index af23523b..e20ac5be 100644 --- a/lib/scm/adapters/svn_chain/chain.rb +++ b/lib/scm/adapters/svn_chain/chain.rb @@ -73,13 +73,22 @@ 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 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} || #{front_to_back}") end # If the passed diff represents the wholesale movement of the entire