mercurial/scmwindows.py
changeset 43075 57875cf423c9
parent 37095 e24802ea8dbd
child 43077 687b865b95ad
equal deleted inserted replaced
43074:9cc55b743713 43075:57875cf423c9
     9     win32,
     9     win32,
    10 )
    10 )
    11 
    11 
    12 try:
    12 try:
    13     import _winreg as winreg
    13     import _winreg as winreg
       
    14 
    14     winreg.CloseKey
    15     winreg.CloseKey
    15 except ImportError:
    16 except ImportError:
    16     import winreg
    17     import winreg
    17 
    18 
    18 # MS-DOS 'more' is the only pager available by default on Windows.
    19 # MS-DOS 'more' is the only pager available by default on Windows.
    19 fallbackpager = 'more'
    20 fallbackpager = 'more'
       
    21 
    20 
    22 
    21 def systemrcpath():
    23 def systemrcpath():
    22     '''return default os-specific hgrc search path'''
    24     '''return default os-specific hgrc search path'''
    23     rcpath = []
    25     rcpath = []
    24     filename = win32.executablepath()
    26     filename = win32.executablepath()
    30     if os.path.isdir(progrcd):
    32     if os.path.isdir(progrcd):
    31         for f, kind in util.listdir(progrcd):
    33         for f, kind in util.listdir(progrcd):
    32             if f.endswith('.rc'):
    34             if f.endswith('.rc'):
    33                 rcpath.append(os.path.join(progrcd, f))
    35                 rcpath.append(os.path.join(progrcd, f))
    34     # else look for a system rcpath in the registry
    36     # else look for a system rcpath in the registry
    35     value = util.lookupreg('SOFTWARE\\Mercurial', None,
    37     value = util.lookupreg(
    36                            winreg.HKEY_LOCAL_MACHINE)
    38         'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE
       
    39     )
    37     if not isinstance(value, str) or not value:
    40     if not isinstance(value, str) or not value:
    38         return rcpath
    41         return rcpath
    39     value = util.localpath(value)
    42     value = util.localpath(value)
    40     for p in value.split(pycompat.ospathsep):
    43     for p in value.split(pycompat.ospathsep):
    41         if p.lower().endswith('mercurial.ini'):
    44         if p.lower().endswith('mercurial.ini'):
    44             for f, kind in util.listdir(p):
    47             for f, kind in util.listdir(p):
    45                 if f.endswith('.rc'):
    48                 if f.endswith('.rc'):
    46                     rcpath.append(os.path.join(p, f))
    49                     rcpath.append(os.path.join(p, f))
    47     return rcpath
    50     return rcpath
    48 
    51 
       
    52 
    49 def userrcpath():
    53 def userrcpath():
    50     '''return os-specific hgrc search path to the user dir'''
    54     '''return os-specific hgrc search path to the user dir'''
    51     home = os.path.expanduser('~')
    55     home = os.path.expanduser('~')
    52     path = [os.path.join(home, 'mercurial.ini'),
    56     path = [os.path.join(home, 'mercurial.ini'), os.path.join(home, '.hgrc')]
    53             os.path.join(home, '.hgrc')]
       
    54     userprofile = encoding.environ.get('USERPROFILE')
    57     userprofile = encoding.environ.get('USERPROFILE')
    55     if userprofile and userprofile != home:
    58     if userprofile and userprofile != home:
    56         path.append(os.path.join(userprofile, 'mercurial.ini'))
    59         path.append(os.path.join(userprofile, 'mercurial.ini'))
    57         path.append(os.path.join(userprofile, '.hgrc'))
    60         path.append(os.path.join(userprofile, '.hgrc'))
    58     return path
    61     return path
    59 
    62 
       
    63 
    60 def termsize(ui):
    64 def termsize(ui):
    61     return win32.termsize()
    65     return win32.termsize()