mercurial/scmwindows.py
changeset 29760 3df9f780c90e
parent 27481 029f02757c20
child 30309 4b1af1c867fa
equal deleted inserted replaced
29759:e584c6235500 29760:3df9f780c90e
     1 from __future__ import absolute_import
     1 from __future__ import absolute_import
     2 
     2 
     3 import _winreg
       
     4 import os
     3 import os
     5 
     4 
     6 from . import (
     5 from . import (
     7     osutil,
     6     osutil,
     8     util,
     7     util,
     9 )
     8 )
       
     9 
       
    10 try:
       
    11     import _winreg as winreg
       
    12     winreg.CloseKey
       
    13 except ImportError:
       
    14     import winreg
    10 
    15 
    11 def systemrcpath():
    16 def systemrcpath():
    12     '''return default os-specific hgrc search path'''
    17     '''return default os-specific hgrc search path'''
    13     rcpath = []
    18     rcpath = []
    14     filename = util.executablepath()
    19     filename = util.executablepath()
    21         for f, kind in osutil.listdir(progrcd):
    26         for f, kind in osutil.listdir(progrcd):
    22             if f.endswith('.rc'):
    27             if f.endswith('.rc'):
    23                 rcpath.append(os.path.join(progrcd, f))
    28                 rcpath.append(os.path.join(progrcd, f))
    24     # else look for a system rcpath in the registry
    29     # else look for a system rcpath in the registry
    25     value = util.lookupreg('SOFTWARE\\Mercurial', None,
    30     value = util.lookupreg('SOFTWARE\\Mercurial', None,
    26                            _winreg.HKEY_LOCAL_MACHINE)
    31                            winreg.HKEY_LOCAL_MACHINE)
    27     if not isinstance(value, str) or not value:
    32     if not isinstance(value, str) or not value:
    28         return rcpath
    33         return rcpath
    29     value = util.localpath(value)
    34     value = util.localpath(value)
    30     for p in value.split(os.pathsep):
    35     for p in value.split(os.pathsep):
    31         if p.lower().endswith('mercurial.ini'):
    36         if p.lower().endswith('mercurial.ini'):