From 71ffb5dc1a23b51f646811196eb88ad1d228e8cc Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Sun, 27 Aug 2006 06:47:25 +0000 Subject: [PATCH] More efficient "svn log" usage (closes #5620) git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@4828 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- CHANGELOG | 2 ++ lib/capistrano/scm/subversion.rb | 22 +++++++--------------- test/scm/subversion_test.rb | 6 ------ 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 084c2896..879d1cc8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* More efficient "svn log" usage (closes #5620) [Anatol Pomozov] + * Better support for key passphrases in the SVN module (closes #5920) [llasram@gmail.com] * Fix missing default for :local in cvs.rb (closes #3645) [jeremy@hinegardner.org] diff --git a/lib/capistrano/scm/subversion.rb b/lib/capistrano/scm/subversion.rb index 59b6d9cd..f2064298 100644 --- a/lib/capistrano/scm/subversion.rb +++ b/lib/capistrano/scm/subversion.rb @@ -16,22 +16,14 @@ module Capistrano # set :svn, "/opt/local/bin/svn" class Subversion < Base # Return an integer identifying the last known revision in the svn - # repository. (This integer is currently the revision number.) If latest - # revision does not exist in the given repository, this routine will - # walk up the directory tree until it finds it. + # repository. (This integer is currently the revision number.) def latest_revision - configuration.logger.debug "querying latest revision..." unless @latest_revision - repo = configuration.repository - until @latest_revision - match = svn_log(repo).scan(/r(\d+)/).first - @latest_revision = match ? match.first : nil - if @latest_revision.nil? - # if a revision number was not reported, move up a level in the path - # and try again. - repo = File.dirname(repo) + @latest_revision ||= begin + configuration.logger.debug "querying latest revision..." + match = svn_log(configuration.repository).scan(/r(\d+)/).first or + raise "Could not determine latest revision" + match.first end - end - @latest_revision end # Return the number of the revision currently deployed. @@ -87,7 +79,7 @@ module Capistrano end def svn_log(path) - `svn log -q -rhead #{path}` + `svn log -q --limit 1 #{path}` end def svn_password diff --git a/test/scm/subversion_test.rb b/test/scm/subversion_test.rb index cd74edba..a6a60e56 100644 --- a/test/scm/subversion_test.rb +++ b/test/scm/subversion_test.rb @@ -74,12 +74,6 @@ MSG assert_equal "/hello/world", @scm.last_path end - def test_latest_revision_searching_upwards - @scm.story = [ "-----------------------------\n", @log_msg ] - assert_equal "1967", @scm.latest_revision - assert_equal "/hello", @scm.last_path - end - def test_checkout @actor.story = [] assert_nothing_raised { @scm.checkout(@actor) }