1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-17 14:38:13 +00:00

Merged r17061 from trunk to 3.4-stable (#27516)

mercurial: separate command options and positional arguments with "--"

We don't have much problems here thanks to hgtarget(path) and CGI.escape(),
which prepends a repository path and encodes "=" character respectively, but
it's better to not rely on the side effect of these functions.

Contributed by Yuya Nishihara.

git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@17067 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2017-12-07 12:15:56 +00:00
parent 76dd10bd78
commit ea070df5cd

View File

@ -141,7 +141,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
parse_xml(output)['rhmanifest']['repository']['manifest'] parse_xml(output)['rhmanifest']['repository']['manifest']
@ -184,7 +184,7 @@ module Redmine
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')
begin begin
@ -240,7 +240,7 @@ module Redmine
end end
unless path.blank? unless path.blank?
p = scm_iconv(@path_encoding, 'UTF-8', path) p = scm_iconv(@path_encoding, 'UTF-8', path)
hg_args << CGI.escape(hgtarget(p)) hg_args << '--' << CGI.escape(hgtarget(p))
end end
diff = [] diff = []
hg *hg_args do |io| hg *hg_args do |io|
@ -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(.*)$}