Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 39123:4d7b11877dd0
filemerge: add the function to examine a capability of a internal tool
For "symlink" and "binary" capabilities, _toolbool() can not examine
these of internal merge tools strictly, because it examines only
configurations in "merge-tools" section.
Users can configure them explicitly as below for example, but this is
not ordinary usage and not convenient:
[merge-tools]
:other.symlink = true
:other.binary = true
This patch adds hascapability() internal function, which can examine
actual capabilities of a internal merge tool strictly.
At this patch, hascapability() is still used with "strict=False".
Subsequent patches use it with "strict=True".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 14 Aug 2018 20:15:51 +0900 |
parents | 5d3b58472660 |
children | 6618634e3325 |
comparison
equal
deleted
inserted
replaced
39122:5d3b58472660 | 39123:4d7b11877dd0 |
---|---|
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 def hascapability(tool, capability, strict=False): | |
141 if strict and tool in internals: | |
142 if internals[tool].capabilities.get(capability): | |
143 return True | |
144 return _toolbool(ui, tool, capability) | |
145 | |
140 def supportscd(tool): | 146 def supportscd(tool): |
141 return tool in internals and internals[tool].mergetype == nomerge | 147 return tool in internals and internals[tool].mergetype == nomerge |
142 | 148 |
143 def check(tool, pat, symlink, binary, changedelete): | 149 def check(tool, pat, symlink, binary, changedelete): |
144 tmsg = tool | 150 tmsg = tool |
147 if not _findtool(ui, tool): | 153 if not _findtool(ui, tool): |
148 if pat: # explicitly requested tool deserves a warning | 154 if pat: # explicitly requested tool deserves a warning |
149 ui.warn(_("couldn't find merge tool %s\n") % tmsg) | 155 ui.warn(_("couldn't find merge tool %s\n") % tmsg) |
150 else: # configured but non-existing tools are more silent | 156 else: # configured but non-existing tools are more silent |
151 ui.note(_("couldn't find merge tool %s\n") % tmsg) | 157 ui.note(_("couldn't find merge tool %s\n") % tmsg) |
152 elif symlink and not _toolbool(ui, tool, "symlink"): | 158 elif symlink and not hascapability(tool, "symlink"): |
153 ui.warn(_("tool %s can't handle symlinks\n") % tmsg) | 159 ui.warn(_("tool %s can't handle symlinks\n") % tmsg) |
154 elif binary and not _toolbool(ui, tool, "binary"): | 160 elif binary and not hascapability(tool, "binary"): |
155 ui.warn(_("tool %s can't handle binary\n") % tmsg) | 161 ui.warn(_("tool %s can't handle binary\n") % tmsg) |
156 elif changedelete and not supportscd(tool): | 162 elif changedelete and not supportscd(tool): |
157 # the nomerge tools are the only tools that support change/delete | 163 # the nomerge tools are the only tools that support change/delete |
158 # conflicts | 164 # conflicts |
159 pass | 165 pass |