Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 37120:a8a902d7176e
procutil: bulk-replace function calls to point to new module
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 24 Mar 2018 15:10:51 +0900 |
parents | f0b6fbea00cf |
children | 242eb5132203 |
comparison
equal
deleted
inserted
replaced
37119:d4a2e0d5d042 | 37120:a8a902d7176e |
---|---|
30 templater, | 30 templater, |
31 util, | 31 util, |
32 ) | 32 ) |
33 | 33 |
34 from .utils import ( | 34 from .utils import ( |
35 procutil, | |
35 stringutil, | 36 stringutil, |
36 ) | 37 ) |
37 | 38 |
38 def _toolstr(ui, tool, part, *args): | 39 def _toolstr(ui, tool, part, *args): |
39 return ui.config("merge-tools", tool + "." + part, *args) | 40 return ui.config("merge-tools", tool + "." + part, *args) |
120 k = _toolstr(ui, tool, kn) | 121 k = _toolstr(ui, tool, kn) |
121 if not k: | 122 if not k: |
122 continue | 123 continue |
123 p = util.lookupreg(k, _toolstr(ui, tool, "regname")) | 124 p = util.lookupreg(k, _toolstr(ui, tool, "regname")) |
124 if p: | 125 if p: |
125 p = util.findexe(p + _toolstr(ui, tool, "regappend", "")) | 126 p = procutil.findexe(p + _toolstr(ui, tool, "regappend", "")) |
126 if p: | 127 if p: |
127 return p | 128 return p |
128 exe = _toolstr(ui, tool, "executable", tool) | 129 exe = _toolstr(ui, tool, "executable", tool) |
129 return util.findexe(util.expandpath(exe)) | 130 return procutil.findexe(util.expandpath(exe)) |
130 | 131 |
131 def _picktool(repo, ui, path, binary, symlink, changedelete): | 132 def _picktool(repo, ui, path, binary, symlink, changedelete): |
132 def supportscd(tool): | 133 def supportscd(tool): |
133 return tool in internals and internals[tool].mergetype == nomerge | 134 return tool in internals and internals[tool].mergetype == nomerge |
134 | 135 |
147 ui.warn(_("tool %s can't handle binary\n") % tmsg) | 148 ui.warn(_("tool %s can't handle binary\n") % tmsg) |
148 elif changedelete and not supportscd(tool): | 149 elif changedelete and not supportscd(tool): |
149 # the nomerge tools are the only tools that support change/delete | 150 # the nomerge tools are the only tools that support change/delete |
150 # conflicts | 151 # conflicts |
151 pass | 152 pass |
152 elif not util.gui() and _toolbool(ui, tool, "gui"): | 153 elif not procutil.gui() and _toolbool(ui, tool, "gui"): |
153 ui.warn(_("tool %s requires a GUI\n") % tmsg) | 154 ui.warn(_("tool %s requires a GUI\n") % tmsg) |
154 else: | 155 else: |
155 return True | 156 return True |
156 return False | 157 return False |
157 | 158 |
162 toolpath = _findtool(ui, force) | 163 toolpath = _findtool(ui, force) |
163 if changedelete and not supportscd(toolpath): | 164 if changedelete and not supportscd(toolpath): |
164 return ":prompt", None | 165 return ":prompt", None |
165 else: | 166 else: |
166 if toolpath: | 167 if toolpath: |
167 return (force, util.shellquote(toolpath)) | 168 return (force, procutil.shellquote(toolpath)) |
168 else: | 169 else: |
169 # mimic HGMERGE if given tool not found | 170 # mimic HGMERGE if given tool not found |
170 return (force, force) | 171 return (force, force) |
171 | 172 |
172 # HGMERGE takes next precedence | 173 # HGMERGE takes next precedence |
180 # then patterns | 181 # then patterns |
181 for pat, tool in ui.configitems("merge-patterns"): | 182 for pat, tool in ui.configitems("merge-patterns"): |
182 mf = match.match(repo.root, '', [pat]) | 183 mf = match.match(repo.root, '', [pat]) |
183 if mf(path) and check(tool, pat, symlink, False, changedelete): | 184 if mf(path) and check(tool, pat, symlink, False, changedelete): |
184 toolpath = _findtool(ui, tool) | 185 toolpath = _findtool(ui, tool) |
185 return (tool, util.shellquote(toolpath)) | 186 return (tool, procutil.shellquote(toolpath)) |
186 | 187 |
187 # then merge tools | 188 # then merge tools |
188 tools = {} | 189 tools = {} |
189 disabled = set() | 190 disabled = set() |
190 for k, v in ui.configitems("merge-tools"): | 191 for k, v in ui.configitems("merge-tools"): |
205 tools.insert(0, (None, uimerge)) # highest priority | 206 tools.insert(0, (None, uimerge)) # highest priority |
206 tools.append((None, "hgmerge")) # the old default, if found | 207 tools.append((None, "hgmerge")) # the old default, if found |
207 for p, t in tools: | 208 for p, t in tools: |
208 if check(t, None, symlink, binary, changedelete): | 209 if check(t, None, symlink, binary, changedelete): |
209 toolpath = _findtool(ui, t) | 210 toolpath = _findtool(ui, t) |
210 return (t, util.shellquote(toolpath)) | 211 return (t, procutil.shellquote(toolpath)) |
211 | 212 |
212 # internal merge or prompt as last resort | 213 # internal merge or prompt as last resort |
213 if symlink or binary or changedelete: | 214 if symlink or binary or changedelete: |
214 if not changedelete and len(tools): | 215 if not changedelete and len(tools): |
215 # any tool is rejected by capability for symlink or binary | 216 # any tool is rejected by capability for symlink or binary |
545 outpath = localpath | 546 outpath = localpath |
546 localpath = localoutputpath | 547 localpath = localoutputpath |
547 replace = {'local': localpath, 'base': basepath, 'other': otherpath, | 548 replace = {'local': localpath, 'base': basepath, 'other': otherpath, |
548 'output': outpath, 'labellocal': mylabel, | 549 'output': outpath, 'labellocal': mylabel, |
549 'labelother': otherlabel, 'labelbase': baselabel} | 550 'labelother': otherlabel, 'labelbase': baselabel} |
550 args = util.interpolate(br'\$', replace, args, | 551 args = util.interpolate( |
551 lambda s: util.shellquote(util.localpath(s))) | 552 br'\$', replace, args, |
553 lambda s: procutil.shellquote(util.localpath(s))) | |
552 cmd = toolpath + ' ' + args | 554 cmd = toolpath + ' ' + args |
553 if _toolbool(ui, tool, "gui"): | 555 if _toolbool(ui, tool, "gui"): |
554 repo.ui.status(_('running merge tool %s for file %s\n') % | 556 repo.ui.status(_('running merge tool %s for file %s\n') % |
555 (tool, fcd.path())) | 557 (tool, fcd.path())) |
556 repo.ui.debug('launching merge tool: %s\n' % cmd) | 558 repo.ui.debug('launching merge tool: %s\n' % cmd) |