Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 39125:cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
For historical reason, Mercurial assumes capabilities of internal
merge tools as below while examining rules to decide merge tool,
regardless of actual capabilities of them.
=============== ====== ========
specified via binary symlinks
=============== ====== ========
--tool o o
HGMERGE o o
merge-patterns o (*) x (*)
ui.merge x (*) x (*)
=============== ====== ========
This causes:
- unintentional internal merge tool is chosen for binary files via
merge-patterns section of configuration file
- explicit configuration of internal merge tool for symlinks is
ignored unintentionally
But on the other hand, simple "check capability strictly" might break
backward compatibility (e.g. existing merge automations), because it
changes the result of merge tool selection.
Therefore, this patch adds config knob "merge.strict-capability-check"
to control whether capabilities of internal merge tools should be
checked strictly or not.
If this configuration is true, capabilities of internal merge tools
are checked strictly in (*) cases above.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 15 Aug 2018 22:24:50 +0900 |
parents | 6618634e3325 |
children | e09fad982ef5 |
comparison
equal
deleted
inserted
replaced
39124:6618634e3325 | 39125:cded904f7acc |
---|---|
135 return p | 135 return p |
136 exe = _toolstr(ui, tool, "executable", tool) | 136 exe = _toolstr(ui, tool, "executable", tool) |
137 return procutil.findexe(util.expandpath(exe)) | 137 return procutil.findexe(util.expandpath(exe)) |
138 | 138 |
139 def _picktool(repo, ui, path, binary, symlink, changedelete): | 139 def _picktool(repo, ui, path, binary, symlink, changedelete): |
140 strictcheck = ui.configbool('merge', 'strict-capability-check') | |
141 | |
140 def hascapability(tool, capability, strict=False): | 142 def hascapability(tool, capability, strict=False): |
141 if strict and tool in internals: | 143 if strict and tool in internals: |
142 if internals[tool].capabilities.get(capability): | 144 if internals[tool].capabilities.get(capability): |
143 return True | 145 return True |
144 return _toolbool(ui, tool, capability) | 146 return _toolbool(ui, tool, capability) |
153 if not _findtool(ui, tool): | 155 if not _findtool(ui, tool): |
154 if pat: # explicitly requested tool deserves a warning | 156 if pat: # explicitly requested tool deserves a warning |
155 ui.warn(_("couldn't find merge tool %s\n") % tmsg) | 157 ui.warn(_("couldn't find merge tool %s\n") % tmsg) |
156 else: # configured but non-existing tools are more silent | 158 else: # configured but non-existing tools are more silent |
157 ui.note(_("couldn't find merge tool %s\n") % tmsg) | 159 ui.note(_("couldn't find merge tool %s\n") % tmsg) |
158 elif symlink and not hascapability(tool, "symlink"): | 160 elif symlink and not hascapability(tool, "symlink", strictcheck): |
159 ui.warn(_("tool %s can't handle symlinks\n") % tmsg) | 161 ui.warn(_("tool %s can't handle symlinks\n") % tmsg) |
160 elif binary and not hascapability(tool, "binary"): | 162 elif binary and not hascapability(tool, "binary", strictcheck): |
161 ui.warn(_("tool %s can't handle binary\n") % tmsg) | 163 ui.warn(_("tool %s can't handle binary\n") % tmsg) |
162 elif changedelete and not supportscd(tool): | 164 elif changedelete and not supportscd(tool): |
163 # the nomerge tools are the only tools that support change/delete | 165 # the nomerge tools are the only tools that support change/delete |
164 # conflicts | 166 # conflicts |
165 pass | 167 pass |
190 return ":prompt", None | 192 return ":prompt", None |
191 else: | 193 else: |
192 return (hgmerge, hgmerge) | 194 return (hgmerge, hgmerge) |
193 | 195 |
194 # then patterns | 196 # then patterns |
197 | |
198 # whether binary capability should be checked strictly | |
199 binarycap = binary and strictcheck | |
200 | |
195 for pat, tool in ui.configitems("merge-patterns"): | 201 for pat, tool in ui.configitems("merge-patterns"): |
196 mf = match.match(repo.root, '', [pat]) | 202 mf = match.match(repo.root, '', [pat]) |
197 if mf(path) and check(tool, pat, symlink, False, changedelete): | 203 if mf(path) and check(tool, pat, symlink, binarycap, changedelete): |
198 if binary and not hascapability(tool, "binary", strict=True): | 204 if binary and not hascapability(tool, "binary", strict=True): |
199 ui.warn(_("warning: check merge-patterns configurations," | 205 ui.warn(_("warning: check merge-patterns configurations," |
200 " if %r for binary file %r is unintentional\n" | 206 " if %r for binary file %r is unintentional\n" |
201 "(see 'hg help merge-tools'" | 207 "(see 'hg help merge-tools'" |
202 " for binary files capability)\n") | 208 " for binary files capability)\n") |