Show More
@@ -27,6 +27,13 b' def _pythonhook(ui, repo, name, hname, f' | |||||
27 | raise util.Abort(_('%s hook is invalid ("%s" not in ' |
|
27 | raise util.Abort(_('%s hook is invalid ("%s" not in ' | |
28 | 'a module)') % (hname, funcname)) |
|
28 | 'a module)') % (hname, funcname)) | |
29 | modname = funcname[:d] |
|
29 | modname = funcname[:d] | |
|
30 | oldpaths = sys.path[:] | |||
|
31 | if hasattr(sys, "frozen"): | |||
|
32 | # binary installs require sys.path manipulation | |||
|
33 | path, name = os.path.split(modname) | |||
|
34 | if path and name: | |||
|
35 | sys.path.append(path) | |||
|
36 | modname = name | |||
30 | try: |
|
37 | try: | |
31 | obj = __import__(modname) |
|
38 | obj = __import__(modname) | |
32 | except ImportError: |
|
39 | except ImportError: | |
@@ -37,6 +44,7 b' def _pythonhook(ui, repo, name, hname, f' | |||||
37 | raise util.Abort(_('%s hook is invalid ' |
|
44 | raise util.Abort(_('%s hook is invalid ' | |
38 | '(import of "%s" failed)') % |
|
45 | '(import of "%s" failed)') % | |
39 | (hname, modname)) |
|
46 | (hname, modname)) | |
|
47 | sys.path = oldpaths | |||
40 | try: |
|
48 | try: | |
41 | for p in funcname.split('.')[1:]: |
|
49 | for p in funcname.split('.')[1:]: | |
42 | obj = getattr(obj, p) |
|
50 | obj = getattr(obj, p) | |
@@ -110,9 +118,9 b' def hook(ui, repo, name, throw=False, **' | |||||
110 | if hasattr(cmd, '__call__'): |
|
118 | if hasattr(cmd, '__call__'): | |
111 | r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r |
|
119 | r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r | |
112 | elif cmd.startswith('python:'): |
|
120 | elif cmd.startswith('python:'): | |
113 |
if cmd.count(':') |
|
121 | if cmd.count(':') >= 2: | |
114 | path, cmd = cmd[7:].split(':') |
|
122 | path, cmd = cmd[7:].rsplit(':', 1) | |
115 |
mod = extensions.loadpath(path, 'hg |
|
123 | mod = extensions.loadpath(path, 'hghook.%s' % hname) | |
116 | hookfn = getattr(mod, cmd) |
|
124 | hookfn = getattr(mod, cmd) | |
117 | else: |
|
125 | else: | |
118 | hookfn = cmd[7:].strip() |
|
126 | hookfn = cmd[7:].strip() |
General Comments 0
You need to be logged in to leave comments.
Login now