diff mercurial/hgweb/common.py @ 7288:9c399c53469d

Allow per-file shadowing of static directory in templatepath
author Brendan Cully <brendan@kublai.com>
date Tue, 28 Oct 2008 22:24:17 -0700
parents 125c8fedcbe0
children bd522d09d5e3
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Tue Oct 28 21:58:30 2008 -0700
+++ b/mercurial/hgweb/common.py	Tue Oct 28 22:24:17 2008 -0700
@@ -53,12 +53,17 @@
 
     """
     parts = fname.split('/')
-    path = directory
     for part in parts:
         if (part in ('', os.curdir, os.pardir) or
             os.sep in part or os.altsep is not None and os.altsep in part):
             return ""
-        path = os.path.join(path, part)
+    fpath = os.path.join(*parts)
+    if isinstance(directory, str):
+        directory = [directory]
+    for d in directory:
+        path = os.path.join(d, fpath)
+        if os.path.exists(path):
+            break
     try:
         os.stat(path)
         ct = mimetypes.guess_type(path)[0] or "text/plain"