Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filemerge.py @ 17885:9a2cf955db84 stable
filemerge: use util.shellquote when calling merge (issue3581)
author | Keegan Carruthers-Smith <keegancsmith@fb.com> |
---|---|
date | Fri, 26 Oct 2012 12:02:58 -0700 |
parents | c655e4acaa82 |
children | d084df89d948 |
comparison
equal
deleted
inserted
replaced
17884:0188ddfa844e | 17885:9a2cf955db84 |
---|---|
70 # forcemerge comes from command line arguments, highest priority | 70 # forcemerge comes from command line arguments, highest priority |
71 force = ui.config('ui', 'forcemerge') | 71 force = ui.config('ui', 'forcemerge') |
72 if force: | 72 if force: |
73 toolpath = _findtool(ui, force) | 73 toolpath = _findtool(ui, force) |
74 if toolpath: | 74 if toolpath: |
75 return (force, '"' + toolpath + '"') | 75 return (force, util.shellquote(toolpath)) |
76 else: | 76 else: |
77 # mimic HGMERGE if given tool not found | 77 # mimic HGMERGE if given tool not found |
78 return (force, force) | 78 return (force, force) |
79 | 79 |
80 # HGMERGE takes next precedence | 80 # HGMERGE takes next precedence |
85 # then patterns | 85 # then patterns |
86 for pat, tool in ui.configitems("merge-patterns"): | 86 for pat, tool in ui.configitems("merge-patterns"): |
87 mf = match.match(repo.root, '', [pat]) | 87 mf = match.match(repo.root, '', [pat]) |
88 if mf(path) and check(tool, pat, symlink, False): | 88 if mf(path) and check(tool, pat, symlink, False): |
89 toolpath = _findtool(ui, tool) | 89 toolpath = _findtool(ui, tool) |
90 return (tool, '"' + toolpath + '"') | 90 return (tool, util.shellquote(toolpath)) |
91 | 91 |
92 # then merge tools | 92 # then merge tools |
93 tools = {} | 93 tools = {} |
94 for k, v in ui.configitems("merge-tools"): | 94 for k, v in ui.configitems("merge-tools"): |
95 t = k.split('.')[0] | 95 t = k.split('.')[0] |
104 tools.insert(0, (None, uimerge)) # highest priority | 104 tools.insert(0, (None, uimerge)) # highest priority |
105 tools.append((None, "hgmerge")) # the old default, if found | 105 tools.append((None, "hgmerge")) # the old default, if found |
106 for p, t in tools: | 106 for p, t in tools: |
107 if check(t, None, symlink, binary): | 107 if check(t, None, symlink, binary): |
108 toolpath = _findtool(ui, t) | 108 toolpath = _findtool(ui, t) |
109 return (t, '"' + toolpath + '"') | 109 return (t, util.shellquote(toolpath)) |
110 | 110 |
111 # internal merge or prompt as last resort | 111 # internal merge or prompt as last resort |
112 if symlink or binary: | 112 if symlink or binary: |
113 return "internal:prompt", None | 113 return "internal:prompt", None |
114 return "internal:merge", None | 114 return "internal:merge", None |
253 args = _toolstr(ui, tool, "args", '$local $base $other') | 253 args = _toolstr(ui, tool, "args", '$local $base $other') |
254 if "$output" in args: | 254 if "$output" in args: |
255 out, a = a, back # read input from backup, write to original | 255 out, a = a, back # read input from backup, write to original |
256 replace = dict(local=a, base=b, other=c, output=out) | 256 replace = dict(local=a, base=b, other=c, output=out) |
257 args = util.interpolate(r'\$', replace, args, | 257 args = util.interpolate(r'\$', replace, args, |
258 lambda s: '"%s"' % util.localpath(s)) | 258 lambda s: util.shellquote(util.localpath(s))) |
259 r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, | 259 r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, |
260 out=ui.fout) | 260 out=ui.fout) |
261 return True, r | 261 return True, r |
262 return False, 0 | 262 return False, 0 |
263 | 263 |