scm: mercurial: add new method 'hg' to wrap shellout (#4455).
Contributed by Yuya Nishihara. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4830 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4f1b1d9242
commit
a9429df880
|
@ -29,6 +29,9 @@ module Redmine
|
||||||
TEMPLATE_NAME = "hg-template"
|
TEMPLATE_NAME = "hg-template"
|
||||||
TEMPLATE_EXTENSION = "tmpl"
|
TEMPLATE_EXTENSION = "tmpl"
|
||||||
|
|
||||||
|
# raised if hg command exited with error, e.g. unknown revision.
|
||||||
|
class HgCommandAborted < CommandFailed; end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def client_command
|
def client_command
|
||||||
@@bin ||= HG_BIN
|
@@bin ||= HG_BIN
|
||||||
|
@ -226,6 +229,20 @@ module Redmine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Runs 'hg' command with the given args
|
||||||
|
def hg(*args, &block)
|
||||||
|
full_args = [HG_BIN, '--cwd', url, '--encoding', 'utf-8']
|
||||||
|
full_args << '--config' << "extensions.redminehelper=#{HG_HELPER_EXT}"
|
||||||
|
full_args << '--config' << 'diff.git=false'
|
||||||
|
full_args += args
|
||||||
|
ret = shellout(full_args.map { |e| shell_quote e.to_s }.join(' '), &block)
|
||||||
|
if $? && $?.exitstatus != 0
|
||||||
|
raise HgCommandAborted, "hg exited with non-zero status: #{$?.exitstatus}"
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
private :hg
|
||||||
|
|
||||||
# Returns correct revision identifier
|
# Returns correct revision identifier
|
||||||
def hgrev(identifier, sq=false)
|
def hgrev(identifier, sq=false)
|
||||||
rev = identifier.blank? ? 'tip' : identifier.to_s
|
rev = identifier.blank? ? 'tip' : identifier.to_s
|
||||||
|
|
Loading…
Reference in New Issue