mirror of
https://github.com/redmine/redmine.git
synced 2025-11-10 15:26:03 +01:00
mercurial: work around faulty parsing of early command options (#27516)
Use -sVALUE and --long=VALUE instead of "-s VALUE" and "--long VALUE" respectively. Contributed by Yuya Nishihara. git-svn-id: http://svn.redmine.org/redmine/trunk@17062 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -140,7 +140,7 @@ module Redmine
|
|||||||
|
|
||||||
def entries(path=nil, identifier=nil, options={})
|
def entries(path=nil, identifier=nil, options={})
|
||||||
p1 = scm_iconv(@path_encoding, 'UTF-8', path)
|
p1 = scm_iconv(@path_encoding, 'UTF-8', path)
|
||||||
manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)),
|
manifest = hg('rhmanifest', "-r#{CGI.escape(hgrev(identifier))}",
|
||||||
'--', CGI.escape(without_leading_slash(p1.to_s))) do |io|
|
'--', CGI.escape(without_leading_slash(p1.to_s))) do |io|
|
||||||
output = io.read.force_encoding('UTF-8')
|
output = io.read.force_encoding('UTF-8')
|
||||||
begin
|
begin
|
||||||
@@ -181,9 +181,9 @@ module Redmine
|
|||||||
# Iterates the revisions by using a template file that
|
# Iterates the revisions by using a template file that
|
||||||
# makes Mercurial produce a xml output.
|
# makes Mercurial produce a xml output.
|
||||||
def each_revision(path=nil, identifier_from=nil, identifier_to=nil, options={})
|
def each_revision(path=nil, identifier_from=nil, identifier_to=nil, options={})
|
||||||
hg_args = ['log', '--debug', '-C', '--style', self.class.template_path]
|
hg_args = ['log', '--debug', '-C', "--style=#{self.class.template_path}"]
|
||||||
hg_args << '-r' << "#{hgrev(identifier_from)}:#{hgrev(identifier_to)}"
|
hg_args << "-r#{hgrev(identifier_from)}:#{hgrev(identifier_to)}"
|
||||||
hg_args << '--limit' << options[:limit] if options[:limit]
|
hg_args << "--limit=#{options[:limit]}" if options[:limit]
|
||||||
hg_args << '--' << hgtarget(path) unless path.blank?
|
hg_args << '--' << hgtarget(path) unless path.blank?
|
||||||
log = hg(*hg_args) do |io|
|
log = hg(*hg_args) do |io|
|
||||||
output = io.read.force_encoding('UTF-8')
|
output = io.read.force_encoding('UTF-8')
|
||||||
@@ -224,19 +224,19 @@ module Redmine
|
|||||||
|
|
||||||
# Returns list of nodes in the specified branch
|
# Returns list of nodes in the specified branch
|
||||||
def nodes_in_branch(branch, options={})
|
def nodes_in_branch(branch, options={})
|
||||||
hg_args = ['rhlog', '--template', '{node}\n', '--rhbranch', CGI.escape(branch)]
|
hg_args = ['rhlog', '--template={node}\n', "--rhbranch=#{CGI.escape(branch)}"]
|
||||||
hg_args << '--from' << CGI.escape(branch)
|
hg_args << "--from=#{CGI.escape(branch)}"
|
||||||
hg_args << '--to' << '0'
|
hg_args << '--to=0'
|
||||||
hg_args << '--limit' << options[:limit] if options[:limit]
|
hg_args << "--limit=#{options[:limit]}" if options[:limit]
|
||||||
hg(*hg_args) { |io| io.readlines.map { |e| e.chomp } }
|
hg(*hg_args) { |io| io.readlines.map { |e| e.chomp } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff(path, identifier_from, identifier_to=nil)
|
def diff(path, identifier_from, identifier_to=nil)
|
||||||
hg_args = %w|rhdiff|
|
hg_args = %w|rhdiff|
|
||||||
if identifier_to
|
if identifier_to
|
||||||
hg_args << '-r' << hgrev(identifier_to) << '-r' << hgrev(identifier_from)
|
hg_args << "-r#{hgrev(identifier_to)}" << "-r#{hgrev(identifier_from)}"
|
||||||
else
|
else
|
||||||
hg_args << '-c' << hgrev(identifier_from)
|
hg_args << "-c#{hgrev(identifier_from)}"
|
||||||
end
|
end
|
||||||
unless path.blank?
|
unless path.blank?
|
||||||
p = scm_iconv(@path_encoding, 'UTF-8', path)
|
p = scm_iconv(@path_encoding, 'UTF-8', path)
|
||||||
@@ -255,7 +255,7 @@ module Redmine
|
|||||||
|
|
||||||
def cat(path, identifier=nil)
|
def cat(path, identifier=nil)
|
||||||
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
|
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
|
||||||
hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io|
|
hg 'rhcat', "-r#{CGI.escape(hgrev(identifier))}", '--', hgtarget(p) do |io|
|
||||||
io.binmode
|
io.binmode
|
||||||
io.read
|
io.read
|
||||||
end
|
end
|
||||||
@@ -266,7 +266,7 @@ module Redmine
|
|||||||
def annotate(path, identifier=nil)
|
def annotate(path, identifier=nil)
|
||||||
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
|
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
|
||||||
blame = Annotate.new
|
blame = Annotate.new
|
||||||
hg 'rhannotate', '-ncu', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io|
|
hg 'rhannotate', '-ncu', "-r#{CGI.escape(hgrev(identifier))}", '--', hgtarget(p) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
line.force_encoding('ASCII-8BIT')
|
line.force_encoding('ASCII-8BIT')
|
||||||
next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
|
next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
|
||||||
@@ -304,7 +304,8 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
repo_path = root_url || url
|
repo_path = root_url || url
|
||||||
full_args = ['-R', repo_path, '--encoding', 'utf-8']
|
full_args = ["-R#{repo_path}", '--encoding=utf-8']
|
||||||
|
# don't use "--config=<value>" form for compatibility with ancient Mercurial
|
||||||
full_args << '--config' << "extensions.redminehelper=#{HG_HELPER_EXT}"
|
full_args << '--config' << "extensions.redminehelper=#{HG_HELPER_EXT}"
|
||||||
full_args << '--config' << 'diff.git=false'
|
full_args << '--config' << 'diff.git=false'
|
||||||
full_args += args
|
full_args += args
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class MercurialAdapterTest < ActiveSupport::TestCase
|
|||||||
HELPERS_DIR = Redmine::Scm::Adapters::MercurialAdapter::HELPERS_DIR
|
HELPERS_DIR = Redmine::Scm::Adapters::MercurialAdapter::HELPERS_DIR
|
||||||
TEMPLATE_NAME = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_NAME
|
TEMPLATE_NAME = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_NAME
|
||||||
TEMPLATE_EXTENSION = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_EXTENSION
|
TEMPLATE_EXTENSION = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_EXTENSION
|
||||||
|
HgCommandAborted = Redmine::Scm::Adapters::MercurialAdapter::HgCommandAborted
|
||||||
HgCommandArgumentError = Redmine::Scm::Adapters::MercurialAdapter::HgCommandArgumentError
|
HgCommandArgumentError = Redmine::Scm::Adapters::MercurialAdapter::HgCommandArgumentError
|
||||||
|
|
||||||
REPOSITORY_PATH = repository_path('mercurial')
|
REPOSITORY_PATH = repository_path('mercurial')
|
||||||
@@ -445,19 +446,18 @@ class MercurialAdapterTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_bad_early_options
|
def test_bad_early_options
|
||||||
assert_raise HgCommandArgumentError do
|
assert_nil @adapter.diff('sources/welcome_controller.rb',
|
||||||
@adapter.diff('sources/welcome_controller.rb', '--config=alias.rhdiff=!xterm')
|
'--config=alias.rhdiff=!xterm')
|
||||||
end
|
|
||||||
assert_raise HgCommandArgumentError do
|
assert_raise HgCommandArgumentError do
|
||||||
@adapter.entries('--debugger')
|
@adapter.entries('--debugger')
|
||||||
end
|
end
|
||||||
assert_raise HgCommandArgumentError do
|
assert_raise HgCommandAborted do
|
||||||
@adapter.revisions(nil, nil, nil, limit: '--repo=otherrepo')
|
@adapter.revisions(nil, nil, nil, limit: '--repo=otherrepo')
|
||||||
end
|
end
|
||||||
assert_raise HgCommandArgumentError do
|
assert_raise HgCommandAborted do
|
||||||
@adapter.nodes_in_branch('default', limit: '--repository=otherrepo')
|
@adapter.nodes_in_branch('default', limit: '--repository=otherrepo')
|
||||||
end
|
end
|
||||||
assert_raise HgCommandArgumentError do
|
assert_raise HgCommandAborted do
|
||||||
@adapter.nodes_in_branch('-Rotherrepo')
|
@adapter.nodes_in_branch('-Rotherrepo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user