Display svn properties in the browser, svn >= 1.5.0 only (#1581).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1627 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang committed 2008-07-05 08:59:04 +00:00
1 parent 1e6b8a482a
commit 12fbd06c02
10 files changed
+139 -5

No files matched your search

+27 -1
View File
@@ -24,6 +24,20 @@ module Redmine
end
class AbstractAdapter #:nodoc:
class << self
# Returns the version of the scm client
# Eg: [1, 5, 0]
def client_version
'Unknown version'
end
# Returns the version string of the scm client
# Eg: '1.5.0'
def client_version_string
client_version.is_a?(Array) ? client_version.join('.') : client_version.to_s
end
end
def initialize(url, root_url=nil, login=nil, password=nil)
@url = url
@login = login if login && !login.empty?
@@ -77,6 +91,10 @@ module Redmine
def entries(path=nil, identifier=nil)
return nil
end
def properties(path, identifier=nil)
return nil
end
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
return nil
@@ -131,10 +149,18 @@ module Redmine
end
def logger
RAILS_DEFAULT_LOGGER
self.class.logger
end
def shellout(cmd, &block)
self.class.shellout(cmd, &block)
end
def self.logger
RAILS_DEFAULT_LOGGER
end
def self.shellout(cmd, &block)
logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
begin
IO.popen(cmd, "r+") do |io|
+42 -1
View File
@@ -26,6 +26,25 @@ module Redmine
# SVN executable name
SVN_BIN = "svn"
class << self
def client_version
@@client_version ||= (svn_binary_version || 'Unknown version')
end
def svn_binary_version
cmd = "#{SVN_BIN} --version"
version = nil
shellout(cmd) do |io|
# Read svn version in first returned line
if m = io.gets.match(%r{((\d+\.)+\d+)})
version = m[0].scan(%r{\d+}).collect(&:to_i)
end
end
return nil if $? && $?.exitstatus != 0
version
end
end
# Get info about the svn repository
def info
cmd = "#{SVN_BIN} info --xml #{target('')}"
@@ -87,7 +106,29 @@ module Redmine
logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
entries.sort_by_name
end
def properties(path, identifier=nil)
# proplist xml output supported in svn 1.5.0 and higher
return nil if (self.class.client_version <=> [1, 5, 0]) < 0
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
cmd = "#{SVN_BIN} proplist --verbose --xml #{target(path)}@#{identifier}"
cmd << credentials_string
properties = {}
shellout(cmd) do |io|
output = io.read
begin
doc = REXML::Document.new(output)
doc.elements.each("properties/target/property") do |property|
properties[ property.attributes['name'] ] = property.text
end
rescue
end
end
return nil if $? && $?.exitstatus != 0
properties
end
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
path ||= ''
identifier_from = (identifier_from and identifier_from.to_i > 0) ? identifier_from.to_i : "HEAD"