Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hook.py @ 10103:37679dbf2ee3 stable
hook: fix bug (reuse of variable) introduced in 872d49dd577a
For binary installs, the 'name' argument would be reused as a local variable,
destroying its original value. The patch fixes that, and also avoids copying
sys.path when it's not necessary.
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Mon, 21 Dec 2009 16:12:43 +0100 |
parents | 9e7b2c49d25d |
children | 25e572394f5c |
comparison
equal
deleted
inserted
replaced
10099:f5e46dfb38c7 | 10103:37679dbf2ee3 |
---|---|
25 d = funcname.rfind('.') | 25 d = funcname.rfind('.') |
26 if d == -1: | 26 if d == -1: |
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[:] | 30 oldpaths = sys.path |
31 if hasattr(sys, "frozen"): | 31 if hasattr(sys, "frozen"): |
32 # binary installs require sys.path manipulation | 32 # binary installs require sys.path manipulation |
33 path, name = os.path.split(modname) | 33 modpath, modfile = os.path.split(modname) |
34 if path and name: | 34 if modpath and modfile: |
35 sys.path.append(path) | 35 sys.path = sys.path[:] + [modpath] |
36 modname = name | 36 modname = modfile |
37 try: | 37 try: |
38 obj = __import__(modname) | 38 obj = __import__(modname) |
39 except ImportError: | 39 except ImportError: |
40 e1 = sys.exc_type, sys.exc_value, sys.exc_traceback | 40 e1 = sys.exc_type, sys.exc_value, sys.exc_traceback |
41 try: | 41 try: |