Commit cad03563 authored by Toshi MARUYAMA's avatar Toshi MARUYAMA Committed by Eric Davis

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
parent f62cccfd
......@@ -29,6 +29,9 @@ module Redmine
TEMPLATE_NAME = "hg-template"
TEMPLATE_EXTENSION = "tmpl"
# raised if hg command exited with error, e.g. unknown revision.
class HgCommandAborted < CommandFailed; end
class << self
def client_command
@@bin ||= HG_BIN
......@@ -226,6 +229,20 @@ module Redmine
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
def hgrev(identifier, sq=false)
rev = identifier.blank? ? 'tip' : identifier.to_s
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment