changeset 2001:a439b7b51530

Windows py2exe version didn't handle names given to templatepath() correctly
author Lee Cantey <lcantey@gmail.com>
date Fri, 24 Mar 2006 10:33:18 -0800
parents 6f6e210b38cf
children 4aab906517c6
files mercurial/templater.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Fri Mar 24 10:31:23 2006 -0800
+++ b/mercurial/templater.py	Fri Mar 24 10:33:18 2006 -0800
@@ -292,13 +292,14 @@
 def templatepath(name=None):
     '''return location of template file or directory (if no name).
     returns None if not found.'''
+    # executable version (py2exe) doesn't support __file__
+    if hasattr(sys, 'frozen'):
+        module = sys.executable
+    else:
+        module = __file__
     for f in 'templates', '../templates':
         fl = f.split('/')
         if name: fl.append(name)
-        p = os.path.join(os.path.dirname(__file__), *fl)
+        p = os.path.join(os.path.dirname(module), *fl)
         if (name and os.path.exists(p)) or os.path.isdir(p):
             return os.path.normpath(p)
-    else:
-        # executable version (py2exe) doesn't support __file__
-        if hasattr(sys, 'frozen'):
-            return os.path.join(sys.prefix, "templates")