summaryrefslogtreecommitdiffstats
path: root/lib/redmine/scm/adapters/darcs_adapter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/redmine/scm/adapters/darcs_adapter.rb')
-rw-r--r--lib/redmine/scm/adapters/darcs_adapter.rb38
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/redmine/scm/adapters/darcs_adapter.rb b/lib/redmine/scm/adapters/darcs_adapter.rb
index 4eaf4fffe..4eed61e96 100644
--- a/lib/redmine/scm/adapters/darcs_adapter.rb
+++ b/lib/redmine/scm/adapters/darcs_adapter.rb
@@ -20,16 +20,24 @@ require 'rexml/document'
module Redmine
module Scm
- module Adapters
+ module Adapters
class DarcsAdapter < AbstractAdapter
# Darcs executable name
DARCS_BIN = Redmine::Configuration['scm_darcs_command'] || "darcs"
-
+
class << self
+ def client_command
+ @@bin ||= DARCS_BIN
+ end
+
+ def sq_bin
+ @@sq_bin ||= shell_quote(DARCS_BIN)
+ end
+
def client_version
@@client_version ||= (darcs_binary_version || [])
end
-
+
def darcs_binary_version
darcsversion = darcs_binary_version_from_command_line
if m = darcsversion.match(%r{\A(.*?)((\d+\.)+\d+)})
@@ -38,7 +46,7 @@ module Redmine
end
def darcs_binary_version_from_command_line
- shellout("#{DARCS_BIN} --version") { |io| io.read }.to_s
+ shellout("#{sq_bin} --version") { |io| io.read }.to_s
end
end
@@ -57,7 +65,7 @@ module Redmine
rev = revisions(nil,nil,nil,{:limit => 1})
rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
end
-
+
# Returns an Entries collection
# or nil if the given path doesn't exist in the repository
def entries(path=nil, identifier=nil)
@@ -66,7 +74,7 @@ module Redmine
path = ( self.class.client_version_above?([2, 2, 0]) ? @url : '.' )
end
entries = Entries.new
- cmd = "#{DARCS_BIN} annotate --repodir #{shell_quote @url} --xml-output"
+ cmd = "#{self.class.sq_bin} annotate --repodir #{shell_quote @url} --xml-output"
cmd << " --match #{shell_quote("hash #{identifier}")}" if identifier
cmd << " #{shell_quote path}"
shellout(cmd) do |io|
@@ -86,11 +94,11 @@ module Redmine
return nil if $? && $?.exitstatus != 0
entries.compact.sort_by_name
end
-
+
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
path = '.' if path.blank?
revisions = Revisions.new
- cmd = "#{DARCS_BIN} changes --repodir #{shell_quote @url} --xml-output"
+ cmd = "#{self.class.sq_bin} changes --repodir #{shell_quote @url} --xml-output"
cmd << " --from-match #{shell_quote("hash #{identifier_from}")}" if identifier_from
cmd << " --last #{options[:limit].to_i}" if options[:limit]
shellout(cmd) do |io|
@@ -113,10 +121,10 @@ module Redmine
return nil if $? && $?.exitstatus != 0
revisions
end
-
+
def diff(path, identifier_from, identifier_to=nil)
path = '*' if path.blank?
- cmd = "#{DARCS_BIN} diff --repodir #{shell_quote @url}"
+ cmd = "#{self.class.sq_bin} diff --repodir #{shell_quote @url}"
if identifier_to.nil?
cmd << " --match #{shell_quote("hash #{identifier_from}")}"
else
@@ -133,9 +141,9 @@ module Redmine
return nil if $? && $?.exitstatus != 0
diff
end
-
+
def cat(path, identifier=nil)
- cmd = "#{DARCS_BIN} show content --repodir #{shell_quote @url}"
+ cmd = "#{self.class.sq_bin} show content --repodir #{shell_quote @url}"
cmd << " --match #{shell_quote("hash #{identifier}")}" if identifier
cmd << " #{shell_quote path}"
cat = nil
@@ -148,7 +156,7 @@ module Redmine
end
private
-
+
# Returns an Entry from the given XML element
# or nil if the entry was deleted
def entry_from_xml(element, path_prefix)
@@ -196,10 +204,10 @@ module Redmine
end
paths
end
-
+
# Retrieve changed paths for a single patch
def get_paths_for_patch_raw(hash)
- cmd = "#{DARCS_BIN} annotate --repodir #{shell_quote @url} --summary --xml-output"
+ cmd = "#{self.class.sq_bin} annotate --repodir #{shell_quote @url} --summary --xml-output"
cmd << " --match #{shell_quote("hash #{hash}")} "
paths = []
shellout(cmd) do |io|