mercurial/scmwindows.py
changeset 43077 687b865b95ad
parent 43075 57875cf423c9
child 43453 a50fecefa691
child 43788 fe73ec69350e
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
    15     winreg.CloseKey
    15     winreg.CloseKey
    16 except ImportError:
    16 except ImportError:
    17     import winreg
    17     import winreg
    18 
    18 
    19 # 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.
    20 fallbackpager = 'more'
    20 fallbackpager = b'more'
    21 
    21 
    22 
    22 
    23 def systemrcpath():
    23 def systemrcpath():
    24     '''return default os-specific hgrc search path'''
    24     '''return default os-specific hgrc search path'''
    25     rcpath = []
    25     rcpath = []
    26     filename = win32.executablepath()
    26     filename = win32.executablepath()
    27     # Use mercurial.ini found in directory with hg.exe
    27     # Use mercurial.ini found in directory with hg.exe
    28     progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
    28     progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini')
    29     rcpath.append(progrc)
    29     rcpath.append(progrc)
    30     # Use hgrc.d found in directory with hg.exe
    30     # Use hgrc.d found in directory with hg.exe
    31     progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d')
    31     progrcd = os.path.join(os.path.dirname(filename), b'hgrc.d')
    32     if os.path.isdir(progrcd):
    32     if os.path.isdir(progrcd):
    33         for f, kind in util.listdir(progrcd):
    33         for f, kind in util.listdir(progrcd):
    34             if f.endswith('.rc'):
    34             if f.endswith(b'.rc'):
    35                 rcpath.append(os.path.join(progrcd, f))
    35                 rcpath.append(os.path.join(progrcd, f))
    36     # else look for a system rcpath in the registry
    36     # else look for a system rcpath in the registry
    37     value = util.lookupreg(
    37     value = util.lookupreg(
    38         'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE
    38         b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE
    39     )
    39     )
    40     if not isinstance(value, str) or not value:
    40     if not isinstance(value, str) or not value:
    41         return rcpath
    41         return rcpath
    42     value = util.localpath(value)
    42     value = util.localpath(value)
    43     for p in value.split(pycompat.ospathsep):
    43     for p in value.split(pycompat.ospathsep):
    44         if p.lower().endswith('mercurial.ini'):
    44         if p.lower().endswith(b'mercurial.ini'):
    45             rcpath.append(p)
    45             rcpath.append(p)
    46         elif os.path.isdir(p):
    46         elif os.path.isdir(p):
    47             for f, kind in util.listdir(p):
    47             for f, kind in util.listdir(p):
    48                 if f.endswith('.rc'):
    48                 if f.endswith(b'.rc'):
    49                     rcpath.append(os.path.join(p, f))
    49                     rcpath.append(os.path.join(p, f))
    50     return rcpath
    50     return rcpath
    51 
    51 
    52 
    52 
    53 def userrcpath():
    53 def userrcpath():
    54     '''return os-specific hgrc search path to the user dir'''
    54     '''return os-specific hgrc search path to the user dir'''
    55     home = os.path.expanduser('~')
    55     home = os.path.expanduser(b'~')
    56     path = [os.path.join(home, 'mercurial.ini'), os.path.join(home, '.hgrc')]
    56     path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')]
    57     userprofile = encoding.environ.get('USERPROFILE')
    57     userprofile = encoding.environ.get(b'USERPROFILE')
    58     if userprofile and userprofile != home:
    58     if userprofile and userprofile != home:
    59         path.append(os.path.join(userprofile, 'mercurial.ini'))
    59         path.append(os.path.join(userprofile, b'mercurial.ini'))
    60         path.append(os.path.join(userprofile, '.hgrc'))
    60         path.append(os.path.join(userprofile, b'.hgrc'))
    61     return path
    61     return path
    62 
    62 
    63 
    63 
    64 def termsize(ui):
    64 def termsize(ui):
    65     return win32.termsize()
    65     return win32.termsize()