hook: fix bug (reuse of variable) introduced in 872d49dd577a stable
authorSune Foldager <cryo@cyanite.org>
Mon, 21 Dec 2009 16:12:43 +0100
branchstable
changeset 10103 37679dbf2ee3
parent 10099 f5e46dfb38c7
child 10104 e533fc8a058b
child 10112 703db37d186b
child 10162 b3a850c45620
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.
mercurial/hook.py
--- a/mercurial/hook.py	Sat Dec 19 22:55:33 2009 -0800
+++ b/mercurial/hook.py	Mon Dec 21 16:12:43 2009 +0100
@@ -27,13 +27,13 @@
             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: