##// END OF EJS Templates
merge: add registry look up bits to tool search
Matt Mackall -
r6006:3c9dbb74 default
parent child Browse files
Show More
@@ -16,6 +16,13 b' def _toolbool(ui, tool, part, default=Fa'
16 return ui.configbool("merge-tools", tool + "." + part, default)
16 return ui.configbool("merge-tools", tool + "." + part, default)
17
17
18 def _findtool(ui, tool):
18 def _findtool(ui, tool):
19 k = _toolstr(ui, tool, "regkey")
20 if k:
21 p = util.lookup_reg(k, _toolstr(ui, tool, "regname"))
22 if p:
23 p = util.find_exe(p + _toolstr(ui, tool, "regappend"))
24 if p:
25 return p
19 return util.find_exe(_toolstr(ui, tool, "executable", tool))
26 return util.find_exe(_toolstr(ui, tool, "executable", tool))
20
27
21 def _picktool(repo, ui, path, binary, symlink):
28 def _picktool(repo, ui, path, binary, symlink):
@@ -1086,6 +1086,9 b" if os.name == 'nt':"
1086 else:
1086 else:
1087 nulldev = '/dev/null'
1087 nulldev = '/dev/null'
1088
1088
1089 def lookup_reg(key, name=None, scope=None):
1090 return None
1091
1089 def rcfiles(path):
1092 def rcfiles(path):
1090 rcs = [os.path.join(path, 'hgrc')]
1093 rcs = [os.path.join(path, 'hgrc')]
1091 rcdir = os.path.join(path, 'hgrc.d')
1094 rcdir = os.path.join(path, 'hgrc.d')
@@ -187,6 +187,37 b' def testpid(pid):'
187 return details[0] != winerror.ERROR_INVALID_PARAMETER
187 return details[0] != winerror.ERROR_INVALID_PARAMETER
188 return True
188 return True
189
189
190 def lookup_reg(key, valname=None, scope=None):
191 ''' Look up a key/value name in the Windows registry.
192
193 valname: value name. If unspecified, the default value for the key
194 is used.
195 scope: optionally specify scope for registry lookup, this can be
196 a sequence of scopes to look up in order. Default (CURRENT_USER,
197 LOCAL_MACHINE).
198 '''
199 try:
200 from _winreg import HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, \
201 QueryValueEx, OpenKey
202 except ImportError:
203 return None
204
205 def query_val(scope, key):
206 try:
207 keyhandle = OpenKey(scope, key)
208 return QueryValueEx(keyhandle, valname)[0]
209 except EnvironmentError:
210 return None
211
212 if scope is None:
213 scope = (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE)
214 elif not isinstance(scope, (list, tuple)):
215 scope = (scope,)
216 for s in scope:
217 val = query_val(s, key, valname)
218 if val is not None:
219 return val
220
190 def system_rcpath_win32():
221 def system_rcpath_win32():
191 '''return default os-specific hgrc search path'''
222 '''return default os-specific hgrc search path'''
192 proc = win32api.GetCurrentProcess()
223 proc = win32api.GetCurrentProcess()
General Comments 0
You need to be logged in to leave comments. Login now