--- mercurial-0.9.3/mercurial/hgweb/hgwebdir_mod.py	2006-12-18 01:02:33.000000000 +0000
+++ lib/python/mercurial/hgweb/hgwebdir_mod.py	2007-04-11 21:25:47.000000000 +0100
@@ -5,7 +5,7 @@
 #
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
-
+import sys # temporary
 import os
 from mercurial.demandload import demandload
 demandload(globals(), "mimetools cStringIO")
@@ -95,7 +95,7 @@
                     yield {"type" : i[0], "extension": i[1],
                            "node": nodeid, "url": url}
 
-        def entries(sortcolumn="", descending=False, **map):
+        def entries(sortcolumn="", descending=False, prefix="", **map):
             def sessionvars(**map):
                 fields = []
                 if req.form.has_key('style'):
@@ -110,7 +110,13 @@
 
             rows = []
             parity = 0
+            if prefix > '' and not prefix.endswith('/'):
+                prefix += '/'
             for name, path in self.repos:
+                if not name.startswith(prefix):
+                    continue
+                name = name[len(prefix):]
+                sys.stderr.write(name+"\n")
                 u = ui.ui(report_untrusted=False)
                 try:
                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
@@ -162,11 +168,17 @@
                     yield row
 
         virtual = req.env.get("PATH_INFO", "").strip('/')
+        sys.stderr.write (virtual + "\n")
         if virtual.startswith('static/'):
             static = os.path.join(templater.templatepath(), 'static')
             fname = virtual[7:]
             req.write(staticfile(static, fname, req) or
                       tmpl('error', error='%r not found' % fname))
+        elif virtual and virtual.find('/static/') >= 0:
+            static = os.path.join(templater.templatepath(), 'static')
+            fname = virtual[virtual.find('/static/')+8:]
+            req.write(staticfile(static, fname, req) or
+                      tmpl('error', error='%r not found' % fname))
         elif virtual:
             while virtual:
                 real = dict(self.repos).get(virtual)
@@ -185,7 +197,31 @@
                 except hg.RepoError, inst:
                     req.write(tmpl("error", error=str(inst)))
             else:
-                req.write(tmpl("notfound", repo=virtual))
+                if req.form.has_key('static'):
+                    static = os.path.join(templater.templatepath(), "static")
+                    sys.stderr.write (static + "\n")
+                    fname = req.form['static'][0]
+                    req.write(staticfile(static, fname, req)
+                              or tmpl("error", error="%r not found" % fname))
+                else:
+                    sortable = ["name", "description", "contact", "lastchange"]
+                    sortcolumn, descending = self.repos_sorted
+                    if req.form.has_key('sort'):
+                        sortcolumn = req.form['sort'][0]
+                        descending = sortcolumn.startswith('-')
+                        if descending:
+                            sortcolumn = sortcolumn[1:]
+                        if sortcolumn not in sortable:
+                            sortcolumn = ""
+
+                    sort = [("sort_%s" % column,
+                             "%s%s" % ((not descending and column == sortcolumn)
+                                       and "-" or "", column))
+                            for column in sortable]
+                    req.write(tmpl("index", entries=entries,
+                                   sortcolumn=sortcolumn, descending=descending,
+                                   prefix=virtual, **dict(sort)))
+                #req.write(tmpl("notfound", repo=virtual))
         else:
             if req.form.has_key('static'):
                 static = os.path.join(templater.templatepath(), "static")
@@ -209,4 +245,4 @@
                         for column in sortable]
                 req.write(tmpl("index", entries=entries,
                                sortcolumn=sortcolumn, descending=descending,
-                               **dict(sort)))
+                               prefix="", **dict(sort)))
