[PATCH 4 of 6] Cleaned up hgweb.hgwebdir.run()

Thomas Arendsen Hein thomas at intevation.de
Mon Aug 29 00:44:00 CDT 2005


# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Node ID 74d184a40a2ea2fb6bddc518af8fa3953d0b02f6
# Parent  033c968d7c667b2bc107ed95a5d902731516355f
Cleaned up hgweb.hgwebdir.run()

diff -r 033c968d7c66 -r 74d184a40a2e mercurial/hgweb.py
--- a/mercurial/hgweb.py	Mon Aug 29 05:28:39 2005
+++ b/mercurial/hgweb.py	Mon Aug 29 05:34:35 2005
@@ -934,8 +934,7 @@
         def footer(**map):
             yield tmpl("footer", **map)
 
-        templates = templatepath()
-        m = os.path.join(templates, "map")
+        m = os.path.join(templatepath(), "map")
         tmpl = templater(m, common_filters,
                          {"header": header, "footer": footer})
 
@@ -946,8 +945,8 @@
                 u.readconfig(file(os.path.join(path, '.hg', 'hgrc')))
                 get = u.config
 
-                url = os.environ["REQUEST_URI"] + "/" + name
-                url = url.replace("//", "/")
+                url = ('/'.join([os.environ["REQUEST_URI"], name])
+                       .replace("//", "/"))
 
                 yield dict(contact=get("web", "contact") or
                                    get("web", "author", "unknown"),
@@ -956,25 +955,16 @@
                            parity=parity,
                            shortdesc=get("web", "description", "unknown"),
                            lastupdate=os.stat(os.path.join(path, ".hg",
-                                                "00changelog.d")).st_mtime)
+                                              "00changelog.d")).st_mtime)
 
                 parity = 1 - parity
 
-        try:
-            virtual = os.environ["PATH_INFO"]
-        except:
-            virtual = ""
-
-        virtual = virtual.strip('/')
-
-        if len(virtual):
+        virtual = os.environ.get("PATH_INFO", "").strip('/')
+        if virtual:
             real = dict(self.repos).get(virtual)
             if real:
-                h = hgweb(real)
-                h.run()
-                return
+                hgweb(real).run()
             else:
-                write(tmpl("notfound", repo = virtual))
-                return
-
-        write(tmpl("index", entries=entries))
+                write(tmpl("notfound", repo=virtual))
+        else:
+            write(tmpl("index", entries=entries))


More information about the Mercurial mailing list