Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG7929bb58146f: windows: factor the hgrc directory scan into a function
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/scmwindows.py (20 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
7929bb58146f | fa3835a15a17 | Matt Harbison | Dec 17 2019, 9:25 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 |
def systemrcpath(): | def systemrcpath(): | ||||
'''return default os-specific hgrc search path''' | '''return default os-specific hgrc search path''' | ||||
rcpath = [] | rcpath = [] | ||||
filename = win32.executablepath() | filename = win32.executablepath() | ||||
# Use mercurial.ini found in directory with hg.exe | # Use mercurial.ini found in directory with hg.exe | ||||
progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini') | progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini') | ||||
rcpath.append(progrc) | rcpath.append(progrc) | ||||
# Use hgrc.d found in directory with hg.exe | |||||
progrcd = os.path.join(os.path.dirname(filename), b'hgrc.d') | def _processdir(progrcd): | ||||
if os.path.isdir(progrcd): | if os.path.isdir(progrcd): | ||||
for f, kind in util.listdir(progrcd): | for f, kind in util.listdir(progrcd): | ||||
if f.endswith(b'.rc'): | if f.endswith(b'.rc'): | ||||
rcpath.append(os.path.join(progrcd, f)) | rcpath.append(os.path.join(progrcd, f)) | ||||
# Use hgrc.d found in directory with hg.exe | |||||
_processdir(os.path.join(os.path.dirname(filename), b'hgrc.d')) | |||||
# next look for a system rcpath in the registry | # next look for a system rcpath in the registry | ||||
value = util.lookupreg( | value = util.lookupreg( | ||||
b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE | b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE | ||||
) | ) | ||||
if value and isinstance(value, bytes): | if value and isinstance(value, bytes): | ||||
value = util.localpath(value) | value = util.localpath(value) | ||||
for p in value.split(pycompat.ospathsep): | for p in value.split(pycompat.ospathsep): | ||||
if p.lower().endswith(b'mercurial.ini'): | if p.lower().endswith(b'mercurial.ini'): | ||||
rcpath.append(p) | rcpath.append(p) | ||||
elif os.path.isdir(p): | else: | ||||
for f, kind in util.listdir(p): | _processdir(p) | ||||
if f.endswith(b'.rc'): | |||||
rcpath.append(os.path.join(p, f)) | |||||
return rcpath | return rcpath | ||||
def userrcpath(): | def userrcpath(): | ||||
'''return os-specific hgrc search path to the user dir''' | '''return os-specific hgrc search path to the user dir''' | ||||
home = os.path.expanduser(b'~') | home = os.path.expanduser(b'~') | ||||
path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')] | path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')] | ||||
userprofile = encoding.environ.get(b'USERPROFILE') | userprofile = encoding.environ.get(b'USERPROFILE') | ||||
if userprofile and userprofile != home: | if userprofile and userprofile != home: | ||||
path.append(os.path.join(userprofile, b'mercurial.ini')) | path.append(os.path.join(userprofile, b'mercurial.ini')) | ||||
path.append(os.path.join(userprofile, b'.hgrc')) | path.append(os.path.join(userprofile, b'.hgrc')) | ||||
return path | return path | ||||
def termsize(ui): | def termsize(ui): | ||||
return win32.termsize() | return win32.termsize() |