comparison mercurial/hook.py @ 43671:664e24207728

procutil: move mainfrozen() to new resourceutil.py The i18n module practically depends on procutil for mainfrozen() but since procutil depends on i18n, it would be a circular dependency if i18n depended directly on procutil. The cycle is currently resolved by having the higher-level util module calculate the "datapath" and inject it into i18n. Extracting mainfrozen() to a new module lets us clean up the dependencies. Differential Revision: https://phab.mercurial-scm.org/D7433
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 14 Nov 2019 11:52:22 -0800
parents 313e3a279828
children 3cbbfd0bfc17
comparison
equal deleted inserted replaced
43670:02fe8dedab8c 43671:664e24207728
20 pycompat, 20 pycompat,
21 util, 21 util,
22 ) 22 )
23 from .utils import ( 23 from .utils import (
24 procutil, 24 procutil,
25 resourceutil,
25 stringutil, 26 stringutil,
26 ) 27 )
27 28
28 29
29 def pythonhook(ui, repo, htype, hname, funcname, args, throw): 30 def pythonhook(ui, repo, htype, hname, funcname, args, throw):
46 _(b'%s hook is invalid: "%s" not in a module') 47 _(b'%s hook is invalid: "%s" not in a module')
47 % (hname, funcname) 48 % (hname, funcname)
48 ) 49 )
49 modname = funcname[:d] 50 modname = funcname[:d]
50 oldpaths = sys.path 51 oldpaths = sys.path
51 if procutil.mainfrozen(): 52 if resourceutil.mainfrozen():
52 # binary installs require sys.path manipulation 53 # binary installs require sys.path manipulation
53 modpath, modfile = os.path.split(modname) 54 modpath, modfile = os.path.split(modname)
54 if modpath and modfile: 55 if modpath and modfile:
55 sys.path = sys.path[:] + [modpath] 56 sys.path = sys.path[:] + [modpath]
56 modname = modfile 57 modname = modfile