~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Andrew Bennetts
  • Date: 2011-02-07 04:14:29 UTC
  • mfrom: (5535.4.26 fetch-all-tags-309682)
  • mto: This revision was merged to the branch mainline in revision 5648.
  • Revision ID: andrew.bennetts@canonical.com-20110207041429-3kc1blj34rvvxod9
Merge fetch-all-tags-309682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#            and others
4
4
#
82
82
    errors,
83
83
    lockdir,
84
84
    mail_client,
 
85
    mergetools,
85
86
    osutils,
86
87
    registry,
87
88
    symbol_versioning,
357
358
        else:
358
359
            return True
359
360
 
 
361
    def get_merge_tools(self):
 
362
        tools = {}
 
363
        for (oname, value, section, conf_id, parser) in self._get_options():
 
364
            if oname.startswith('bzr.mergetool.'):
 
365
                tool_name = oname[len('bzr.mergetool.'):]
 
366
                tools[tool_name] = value
 
367
        trace.mutter('loaded merge tools: %r' % tools)
 
368
        return tools
 
369
 
 
370
    def find_merge_tool(self, name):
 
371
        # We fake a defaults mechanism here by checking if the given name can 
 
372
        # be found in the known_merge_tools if it's not found in the config.
 
373
        # This should be done through the proposed config defaults mechanism
 
374
        # when it becomes available in the future.
 
375
        command_line = (self.get_user_option('bzr.mergetool.%s' % name) or
 
376
                        mergetools.known_merge_tools.get(name, None))
 
377
        return command_line
 
378
 
360
379
 
361
380
class IniBasedConfig(Config):
362
381
    """A configuration policy that draws from ini files."""
1131
1150
    """
1132
1151
    base = os.environ.get('BZR_HOME', None)
1133
1152
    if sys.platform == 'win32':
 
1153
        # environ variables on Windows are in user encoding/mbcs. So decode
 
1154
        # before using one
 
1155
        if base is not None:
 
1156
            base = base.decode('mbcs')
1134
1157
        if base is None:
1135
1158
            base = win32utils.get_appdata_location_unicode()
1136
1159
        if base is None:
1137
1160
            base = os.environ.get('HOME', None)
 
1161
            if base is not None:
 
1162
                base = base.decode('mbcs')
1138
1163
        if base is None:
1139
1164
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1140
1165
                                  ' or HOME set')