Skip to content

Commit 58ed865

Browse files
author
Toshi MARUYAMA
committed
mercurial: separate command options and positional arguments with "--" (#27516)
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/trunk@17061 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent ca87bf7 commit 58ed865

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: lib/redmine/scm/adapters/mercurial_adapter.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def summary
141141
def entries(path=nil, identifier=nil, options={})
142142
p1 = scm_iconv(@path_encoding, 'UTF-8', path)
143143
manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)),
144-
CGI.escape(without_leading_slash(p1.to_s))) do |io|
144+
'--', CGI.escape(without_leading_slash(p1.to_s))) do |io|
145145
output = io.read.force_encoding('UTF-8')
146146
begin
147147
parse_xml(output)['rhmanifest']['repository']['manifest']
@@ -184,7 +184,7 @@ def each_revision(path=nil, identifier_from=nil, identifier_to=nil, options={})
184184
hg_args = ['log', '--debug', '-C', '--style', self.class.template_path]
185185
hg_args << '-r' << "#{hgrev(identifier_from)}:#{hgrev(identifier_to)}"
186186
hg_args << '--limit' << options[:limit] if options[:limit]
187-
hg_args << hgtarget(path) unless path.blank?
187+
hg_args << '--' << hgtarget(path) unless path.blank?
188188
log = hg(*hg_args) do |io|
189189
output = io.read.force_encoding('UTF-8')
190190
begin
@@ -240,7 +240,7 @@ def diff(path, identifier_from, identifier_to=nil)
240240
end
241241
unless path.blank?
242242
p = scm_iconv(@path_encoding, 'UTF-8', path)
243-
hg_args << CGI.escape(hgtarget(p))
243+
hg_args << '--' << CGI.escape(hgtarget(p))
244244
end
245245
diff = []
246246
hg *hg_args do |io|
@@ -255,7 +255,7 @@ def diff(path, identifier_from, identifier_to=nil)
255255

256256
def cat(path, identifier=nil)
257257
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
258-
hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io|
258+
hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io|
259259
io.binmode
260260
io.read
261261
end
@@ -266,7 +266,7 @@ def cat(path, identifier=nil)
266266
def annotate(path, identifier=nil)
267267
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
268268
blame = Annotate.new
269-
hg 'rhannotate', '-ncu', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io|
269+
hg 'rhannotate', '-ncu', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io|
270270
io.each_line do |line|
271271
line.force_encoding('ASCII-8BIT')
272272
next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}

0 commit comments

Comments
 (0)