Mercurial > public > mercurial-scm > hg
comparison mercurial/windows.py @ 13986:9c374cf76b7d
move system_rcpath and user_rcpath to scmutil
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Thu, 21 Apr 2011 21:16:54 +0200 |
parents | 31eb145b50b6 |
children | 97ed99d1f419 |
comparison
equal
deleted
inserted
replaced
13985:26335a817dd0 | 13986:9c374cf76b7d |
---|---|
70 except AttributeError: | 70 except AttributeError: |
71 return 'command' in os.environ.get('comspec', '') | 71 return 'command' in os.environ.get('comspec', '') |
72 | 72 |
73 def openhardlinks(): | 73 def openhardlinks(): |
74 return not _is_win_9x() | 74 return not _is_win_9x() |
75 | |
76 _HKEY_LOCAL_MACHINE = 0x80000002L | |
77 | |
78 def system_rcpath(): | |
79 '''return default os-specific hgrc search path''' | |
80 rcpath = [] | |
81 filename = executable_path() | |
82 # Use mercurial.ini found in directory with hg.exe | |
83 progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') | |
84 if os.path.isfile(progrc): | |
85 rcpath.append(progrc) | |
86 return rcpath | |
87 # Use hgrc.d found in directory with hg.exe | |
88 progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d') | |
89 if os.path.isdir(progrcd): | |
90 for f, kind in osutil.listdir(progrcd): | |
91 if f.endswith('.rc'): | |
92 rcpath.append(os.path.join(progrcd, f)) | |
93 return rcpath | |
94 # else look for a system rcpath in the registry | |
95 value = lookup_reg('SOFTWARE\\Mercurial', None, _HKEY_LOCAL_MACHINE) | |
96 if not isinstance(value, str) or not value: | |
97 return rcpath | |
98 value = value.replace('/', os.sep) | |
99 for p in value.split(os.pathsep): | |
100 if p.lower().endswith('mercurial.ini'): | |
101 rcpath.append(p) | |
102 elif os.path.isdir(p): | |
103 for f, kind in osutil.listdir(p): | |
104 if f.endswith('.rc'): | |
105 rcpath.append(os.path.join(p, f)) | |
106 return rcpath | |
107 | |
108 def user_rcpath(): | |
109 '''return os-specific hgrc search path to the user dir''' | |
110 home = os.path.expanduser('~') | |
111 path = [os.path.join(home, 'mercurial.ini'), | |
112 os.path.join(home, '.hgrc')] | |
113 userprofile = os.environ.get('USERPROFILE') | |
114 if userprofile: | |
115 path.append(os.path.join(userprofile, 'mercurial.ini')) | |
116 path.append(os.path.join(userprofile, '.hgrc')) | |
117 return path | |
118 | 75 |
119 def parse_patch_output(output_line): | 76 def parse_patch_output(output_line): |
120 """parses the output produced by patch and returns the filename""" | 77 """parses the output produced by patch and returns the filename""" |
121 pf = output_line[14:] | 78 pf = output_line[14:] |
122 if pf[0] == '`': | 79 if pf[0] == '`': |