~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2010-12-06 10:15:25 UTC
  • mto: (5321.1.101 mergetools)
  • mto: This revision was merged to the branch mainline in revision 5632.
  • Revision ID: v.ladeuil+lp@free.fr-20101206101525-4f9xea2yqcak0vlx
Prefix mergetools option names with 'bzr.'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
361
361
    def get_merge_tools(self):
362
362
        tools = []
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.'):],
366
366
                                                  value))
367
367
        trace.mutter('loaded merge tools: %r' % tools)
368
368
        return tools
369
369
 
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
        # merge_tools
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 == '':
382
383
                continue
383
384
            self.set_user_option(oname, value)
384
385
 
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:
388
389
            return None
389
390
        return mergetools.MergeTool(name, commandline)
390
391
 
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')
393
394
        if name is None:
394
395
            trace.mutter('no default merge tool defined')
395
396
            return None
399
400
 
400
401
    def set_default_merge_tool(self, name):
401
402
        if name is None:
402
 
            self.remove_user_option('default_mergetool')
 
403
            self.remove_user_option('bzr.default_mergetool')
403
404
        else:
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)
410
411
 
411
412
 
412
413
class IniBasedConfig(Config):