Skip to content

Commit

Permalink
More efficient "svn log" usage (closes #5620)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@4828 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Aug 27, 2006
1 parent 4a75323 commit 0571441
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
2 changes: 2 additions & 0 deletions 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]
Expand Down
22 changes: 7 additions & 15 deletions lib/capistrano/scm/subversion.rb
Expand Up @@ -16,22 +16,14 @@ module SCM
# 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.
Expand Down Expand Up @@ -87,7 +79,7 @@ def svn
end

def svn_log(path)
`svn log -q -rhead #{path}`
`svn log -q --limit 1 #{path}`
end

def svn_password
Expand Down
6 changes: 0 additions & 6 deletions test/scm/subversion_test.rb
Expand Up @@ -74,12 +74,6 @@ def test_latest_revision
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) }
Expand Down

0 comments on commit 0571441

Please sign in to comment.