Mercurial > hg
comparison hgext/extdiff.py @ 23138:72a89cf86fcd stable
extdiff: quote user-supplied options passed to shell
$ hg extdiff -p cmd -o "name <user@example.com>"
resulted in a shell redirection error (due to the less-than sign),
rather than passing the single option to cmd. This was due to options
not being quoted for passing to the shell, via util.system(). Apply
util.shellquote() to each of the user-specified options (-o) to the
comparison program before they are concatenated and passed to
util.system(). The requested external diff command (-p) and the
files/directories being compared are already quoted correctly.
The discussion at the time of changeset be98c5ce4022 correctly noted
that this course of action breaks whitespace-separated options specified
for external diff commands in the configuration. The lower part of the
patch corrects this by lexing options read from the configuration file
into separate options rather than reading them all into the first
option.
Update test to cover these conditions.
Related changesets (reverse-chronological):
- be98c5ce4022 (fix reverted to make configuration file options work)
- 453097750fbf (issue fixed but without fix for configuration file)
author | Michael Fyles <mf@vorston.net> |
---|---|
date | Thu, 26 Jul 2012 11:38:13 +0100 |
parents | 684bad8c4265 |
children | b8f6d840d3ec |
comparison
equal
deleted
inserted
replaced
23137:7867f15b4a38 | 23138:72a89cf86fcd |
---|---|
119 - just invoke the diff for a single file in the working dir | 119 - just invoke the diff for a single file in the working dir |
120 ''' | 120 ''' |
121 | 121 |
122 revs = opts.get('rev') | 122 revs = opts.get('rev') |
123 change = opts.get('change') | 123 change = opts.get('change') |
124 args = ' '.join(diffopts) | 124 args = ' '.join(map(util.shellquote, diffopts)) |
125 do3way = '$parent2' in args | 125 do3way = '$parent2' in args |
126 | 126 |
127 if revs and change: | 127 if revs and change: |
128 msg = _('cannot specify --rev and --change at the same time') | 128 msg = _('cannot specify --rev and --change at the same time') |
129 raise util.Abort(msg) | 129 raise util.Abort(msg) |
278 for cmd, path in ui.configitems('extdiff'): | 278 for cmd, path in ui.configitems('extdiff'): |
279 if cmd.startswith('cmd.'): | 279 if cmd.startswith('cmd.'): |
280 cmd = cmd[4:] | 280 cmd = cmd[4:] |
281 if not path: | 281 if not path: |
282 path = cmd | 282 path = cmd |
283 diffopts = ui.config('extdiff', 'opts.' + cmd, '') | 283 diffopts = shlex.split(ui.config('extdiff', 'opts.' + cmd, '')) |
284 diffopts = diffopts and [diffopts] or [] | |
285 elif cmd.startswith('opts.'): | 284 elif cmd.startswith('opts.'): |
286 continue | 285 continue |
287 else: | 286 else: |
288 # command = path opts | 287 # command = path opts |
289 if path: | 288 if path: |