comparison lib/redmine/scm/adapters/cvs_adapter.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents cbce1fd3b1b7
children 5e80956cc792 433d4f72a19b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
23 class CvsAdapter < AbstractAdapter 23 class CvsAdapter < AbstractAdapter
24 24
25 # CVS executable name 25 # CVS executable name
26 CVS_BIN = Redmine::Configuration['scm_cvs_command'] || "cvs" 26 CVS_BIN = Redmine::Configuration['scm_cvs_command'] || "cvs"
27 27
28 # raised if scm command exited with error, e.g. unknown revision.
29 class ScmCommandAborted < CommandFailed; end
30
31 class << self 28 class << self
32 def client_command 29 def client_command
33 @@bin ||= CVS_BIN 30 @@bin ||= CVS_BIN
34 end 31 end
35 32
36 def sq_bin 33 def sq_bin
37 @@sq_bin ||= shell_quote(CVS_BIN) 34 @@sq_bin ||= shell_quote_command
38 end 35 end
39 36
40 def client_version 37 def client_version
41 @@client_version ||= (scm_command_version || []) 38 @@client_version ||= (scm_command_version || [])
42 end 39 end
377 revision.to_s 374 revision.to_s
378 end 375 end
379 end 376 end
380 377
381 def scm_cmd(*args, &block) 378 def scm_cmd(*args, &block)
382 full_args = [CVS_BIN, '-d', root_url] 379 full_args = ['-d', root_url]
383 full_args += args 380 full_args += args
384 full_args_locale = [] 381 full_args_locale = []
385 full_args.map do |e| 382 full_args.map do |e|
386 full_args_locale << scm_iconv(@path_encoding, 'UTF-8', e) 383 full_args_locale << scm_iconv(@path_encoding, 'UTF-8', e)
387 end 384 end
388 ret = shellout(full_args_locale.map { |e| shell_quote e.to_s }.join(' '), &block) 385 ret = shellout(
386 self.class.sq_bin + ' ' + full_args_locale.map { |e| shell_quote e.to_s }.join(' '),
387 &block
388 )
389 if $? && $?.exitstatus != 0 389 if $? && $?.exitstatus != 0
390 raise ScmCommandAborted, "cvs exited with non-zero status: #{$?.exitstatus}" 390 raise ScmCommandAborted, "cvs exited with non-zero status: #{$?.exitstatus}"
391 end 391 end
392 ret 392 ret
393 end 393 end