361
361
def get_merge_tools(self):
363
363
for (oname, value, section, conf_id, parser) in self._get_options():
364
if oname.startswith('mergetool.'):
365
tools.append(mergetools.MergeTool(oname[len('mergetool.'):],
364
if oname.startswith('bzr.mergetool.'):
365
tools.append(mergetools.MergeTool(oname[len('bzr.mergetool.'):],
367
367
trace.mutter('loaded merge tools: %r' % tools)
370
370
def set_merge_tools(self, tools):
371
# remove entries from config for tools which do not appear in merge_tools
371
# remove entries from config for tools which do not appear in
372
373
tool_names = [tool.get_name() for tool in tools]
373
374
for (oname, value, section, conf_id, parser) in self._get_options():
374
if oname.startswith('mergetool.'):
375
if oname[len('mergetool.'):] not in tool_names:
375
if oname.startswith('bzr.mergetool.'):
376
if oname[len('bzr.mergetool.'):] not in tool_names:
376
377
self.remove_user_option(oname)
377
378
# set config entries
378
379
for tool in tools:
379
oname = 'mergetool.%s' % tool.get_name()
380
oname = 'bzr.mergetool.%s' % tool.get_name()
380
381
value = tool.get_commandline()
381
382
if oname == '' or value == '':
383
384
self.set_user_option(oname, value)
385
386
def find_merge_tool(self, name):
386
commandline = self.get_user_option('mergetool.%s' % name)
387
commandline = self.get_user_option('bzr.mergetool.%s' % name)
387
388
if commandline is None:
389
390
return mergetools.MergeTool(name, commandline)
391
392
def get_default_merge_tool(self):
392
name = self.get_user_option('default_mergetool')
393
name = self.get_user_option('bzr.default_mergetool')
394
395
trace.mutter('no default merge tool defined')
400
401
def set_default_merge_tool(self, name):
402
self.remove_user_option('default_mergetool')
403
self.remove_user_option('bzr.default_mergetool')
404
405
if isinstance(name, mergetools.MergeTool):
405
406
name = name.get_name()
406
407
if self.find_merge_tool(name) is None:
407
408
raise errors.BzrError('invalid merge tool name: %r' % name)
408
409
trace.mutter('setting default merge tool: %s', name)
409
self.set_user_option('default_mergetool', name)
410
self.set_user_option('bzr.default_mergetool', name)
412
413
class IniBasedConfig(Config):