# HG changeset patch # User Sune Foldager # Date 2009-12-21 15:12:43 # Node ID 37679dbf2ee3335f9025fc42fd30d35d034dc684 # Parent f5e46dfb38c7bcabf21f3f83159ca2daae523fec 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. diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -27,13 +27,13 @@ def _pythonhook(ui, repo, name, hname, f raise util.Abort(_('%s hook is invalid ("%s" not in ' 'a module)') % (hname, funcname)) modname = funcname[:d] - oldpaths = sys.path[:] + oldpaths = sys.path if hasattr(sys, "frozen"): # binary installs require sys.path manipulation - path, name = os.path.split(modname) - if path and name: - sys.path.append(path) - modname = name + modpath, modfile = os.path.split(modname) + if modpath and modfile: + sys.path = sys.path[:] + [modpath] + modname = modfile try: obj = __import__(modname) except ImportError: