Mercurial > hg
comparison mercurial/scmwindows.py @ 43925:7929bb58146f
windows: factor the hgrc directory scan into a function
Differential Revision: https://phab.mercurial-scm.org/D7691
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 17 Dec 2019 21:25:54 -0500 |
parents | fa3835a15a17 |
children | 1ccf340acf14 |
comparison
equal
deleted
inserted
replaced
43924:fa3835a15a17 | 43925:7929bb58146f |
---|---|
26 rcpath = [] | 26 rcpath = [] |
27 filename = win32.executablepath() | 27 filename = win32.executablepath() |
28 # Use mercurial.ini found in directory with hg.exe | 28 # Use mercurial.ini found in directory with hg.exe |
29 progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini') | 29 progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini') |
30 rcpath.append(progrc) | 30 rcpath.append(progrc) |
31 | |
32 def _processdir(progrcd): | |
33 if os.path.isdir(progrcd): | |
34 for f, kind in util.listdir(progrcd): | |
35 if f.endswith(b'.rc'): | |
36 rcpath.append(os.path.join(progrcd, f)) | |
37 | |
31 # Use hgrc.d found in directory with hg.exe | 38 # Use hgrc.d found in directory with hg.exe |
32 progrcd = os.path.join(os.path.dirname(filename), b'hgrc.d') | 39 _processdir(os.path.join(os.path.dirname(filename), b'hgrc.d')) |
33 if os.path.isdir(progrcd): | 40 |
34 for f, kind in util.listdir(progrcd): | |
35 if f.endswith(b'.rc'): | |
36 rcpath.append(os.path.join(progrcd, f)) | |
37 # next look for a system rcpath in the registry | 41 # next look for a system rcpath in the registry |
38 value = util.lookupreg( | 42 value = util.lookupreg( |
39 b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE | 43 b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE |
40 ) | 44 ) |
41 if value and isinstance(value, bytes): | 45 if value and isinstance(value, bytes): |
42 value = util.localpath(value) | 46 value = util.localpath(value) |
43 for p in value.split(pycompat.ospathsep): | 47 for p in value.split(pycompat.ospathsep): |
44 if p.lower().endswith(b'mercurial.ini'): | 48 if p.lower().endswith(b'mercurial.ini'): |
45 rcpath.append(p) | 49 rcpath.append(p) |
46 elif os.path.isdir(p): | 50 else: |
47 for f, kind in util.listdir(p): | 51 _processdir(p) |
48 if f.endswith(b'.rc'): | |
49 rcpath.append(os.path.join(p, f)) | |
50 return rcpath | 52 return rcpath |
51 | 53 |
52 | 54 |
53 def userrcpath(): | 55 def userrcpath(): |
54 '''return os-specific hgrc search path to the user dir''' | 56 '''return os-specific hgrc search path to the user dir''' |