Mercurial > hg > soundsoftware-site
diff lib/redmine/scm/adapters/darcs_adapter.rb @ 210:0579821a129a
Update to Redmine trunk rev 4802
author | Chris Cannam |
---|---|
date | Tue, 08 Feb 2011 13:51:46 +0000 |
parents | 8661b858af72 |
children | 051f544170fe |
line wrap: on
line diff
--- a/lib/redmine/scm/adapters/darcs_adapter.rb Wed Jan 19 15:04:22 2011 +0000 +++ b/lib/redmine/scm/adapters/darcs_adapter.rb Tue Feb 08 13:51:46 2011 +0000 @@ -23,7 +23,7 @@ module Adapters class DarcsAdapter < AbstractAdapter # Darcs executable name - DARCS_BIN = "darcs" + DARCS_BIN = Redmine::Configuration['scm_darcs_command'] || "darcs" class << self def client_version @@ -31,16 +31,14 @@ end def darcs_binary_version - cmd = "#{DARCS_BIN} --version" - version = nil - shellout(cmd) do |io| - # Read darcs version in first returned line - if m = io.gets.match(%r{((\d+\.)+\d+)}) - version = m[0].scan(%r{\d+}).collect(&:to_i) - end + darcsversion = darcs_binary_version_from_command_line + if m = darcsversion.match(%r{\A(.*?)((\d+\.)+\d+)}) + m[2].scan(%r{\d+}).collect(&:to_i) end - return nil if $? && $?.exitstatus != 0 - version + end + + def darcs_binary_version_from_command_line + shellout("#{DARCS_BIN} --version") { |io| io.read }.to_s end end @@ -64,7 +62,9 @@ # or nil if the given path doesn't exist in the repository def entries(path=nil, identifier=nil) path_prefix = (path.blank? ? '' : "#{path}/") - path = '.' if path.blank? + if path.blank? + 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 << " --match #{shell_quote("hash #{identifier}")}" if identifier @@ -167,9 +167,38 @@ }) }) end + + def get_paths_for_patch(hash) + paths = get_paths_for_patch_raw(hash) + if self.class.client_version_above?([2, 4]) + orig_paths = paths + paths = [] + add_paths = [] + add_paths_name = [] + mod_paths = [] + other_paths = [] + orig_paths.each do |path| + if path[:action] == 'A' + add_paths << path + add_paths_name << path[:path] + elsif path[:action] == 'M' + mod_paths << path + else + other_paths << path + end + end + add_paths_name.each do |add_path| + mod_paths.delete_if { |m| m[:path] == add_path } + end + paths.concat add_paths + paths.concat mod_paths + paths.concat other_paths + end + paths + end # Retrieve changed paths for a single patch - def get_paths_for_patch(hash) + def get_paths_for_patch_raw(hash) cmd = "#{DARCS_BIN} annotate --repodir #{shell_quote @url} --summary --xml-output" cmd << " --match #{shell_quote("hash #{hash}")} " paths = []