Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 34826:18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
We register the merge-tools config section (which has an arbitrary base config
value) and the possible sub-attribute. The sub-attribute has to be registered
first or at the same time otherwise the '.*' item would shadow them.
Merge tools could include "." in their name so we can't constrain any more
than just ".*".
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sun, 08 Oct 2017 20:37:13 +0200 |
parents | 284fa44f7f39 |
children | cab34bda259e |
comparison
equal
deleted
inserted
replaced
34825:4d5d5009bd75 | 34826:18a3274ed675 |
---|---|
27 templatekw, | 27 templatekw, |
28 templater, | 28 templater, |
29 util, | 29 util, |
30 ) | 30 ) |
31 | 31 |
32 def _toolstr(ui, tool, part, default=""): | 32 def _toolstr(ui, tool, part, *args): |
33 return ui.config("merge-tools", tool + "." + part, default) | 33 return ui.config("merge-tools", tool + "." + part, *args) |
34 | 34 |
35 def _toolbool(ui, tool, part, default=False): | 35 def _toolbool(ui, tool, part,*args): |
36 return ui.configbool("merge-tools", tool + "." + part, default) | 36 return ui.configbool("merge-tools", tool + "." + part, *args) |
37 | 37 |
38 def _toollist(ui, tool, part, default=None): | 38 def _toollist(ui, tool, part): |
39 if default is None: | 39 return ui.configlist("merge-tools", tool + "." + part) |
40 default = [] | |
41 return ui.configlist("merge-tools", tool + "." + part, default) | |
42 | 40 |
43 internals = {} | 41 internals = {} |
44 # Merge tools to document. | 42 # Merge tools to document. |
45 internalsdoc = {} | 43 internalsdoc = {} |
46 | 44 |
184 tools = {} | 182 tools = {} |
185 disabled = set() | 183 disabled = set() |
186 for k, v in ui.configitems("merge-tools"): | 184 for k, v in ui.configitems("merge-tools"): |
187 t = k.split('.')[0] | 185 t = k.split('.')[0] |
188 if t not in tools: | 186 if t not in tools: |
189 tools[t] = int(_toolstr(ui, t, "priority", "0")) | 187 tools[t] = int(_toolstr(ui, t, "priority")) |
190 if _toolbool(ui, t, "disabled", False): | 188 if _toolbool(ui, t, "disabled"): |
191 disabled.add(t) | 189 disabled.add(t) |
192 names = tools.keys() | 190 names = tools.keys() |
193 tools = sorted([(-p, tool) for tool, p in tools.items() | 191 tools = sorted([(-p, tool) for tool, p in tools.items() |
194 if tool not in disabled]) | 192 if tool not in disabled]) |
195 uimerge = ui.config("ui", "merge") | 193 uimerge = ui.config("ui", "merge") |
325 | 323 |
326 # do we attempt to simplemerge first? | 324 # do we attempt to simplemerge first? |
327 try: | 325 try: |
328 premerge = _toolbool(ui, tool, "premerge", not binary) | 326 premerge = _toolbool(ui, tool, "premerge", not binary) |
329 except error.ConfigError: | 327 except error.ConfigError: |
330 premerge = _toolstr(ui, tool, "premerge").lower() | 328 premerge = _toolstr(ui, tool, "premerge", "").lower() |
331 if premerge not in validkeep: | 329 if premerge not in validkeep: |
332 _valid = ', '.join(["'" + v + "'" for v in validkeep]) | 330 _valid = ', '.join(["'" + v + "'" for v in validkeep]) |
333 raise error.ConfigError(_("%s.premerge not valid " | 331 raise error.ConfigError(_("%s.premerge not valid " |
334 "('%s' is neither boolean nor %s)") % | 332 "('%s' is neither boolean nor %s)") % |
335 (tool, premerge, _valid)) | 333 (tool, premerge, _valid)) |
506 'HG_OTHER_ISLINK': 'l' in fco.flags(), | 504 'HG_OTHER_ISLINK': 'l' in fco.flags(), |
507 'HG_BASE_ISLINK': 'l' in fca.flags(), | 505 'HG_BASE_ISLINK': 'l' in fca.flags(), |
508 } | 506 } |
509 ui = repo.ui | 507 ui = repo.ui |
510 | 508 |
511 args = _toolstr(ui, tool, "args", '$local $base $other') | 509 args = _toolstr(ui, tool, "args") |
512 if "$output" in args: | 510 if "$output" in args: |
513 # read input from backup, write to original | 511 # read input from backup, write to original |
514 out = a | 512 out = a |
515 a = repo.wvfs.join(back.path()) | 513 a = repo.wvfs.join(back.path()) |
516 replace = {'local': a, 'base': b, 'other': c, 'output': out} | 514 replace = {'local': a, 'base': b, 'other': c, 'output': out} |