Current state of web view

Matt Schulte matts at commtech-fastcom.com
Wed Aug 10 02:21:50 UTC 2011


On Mon, Aug 8, 2011 at 5:46 AM, Paul Boddie <paul.boddie at biotek.uio.no> wrote:
> On 08/08/11 12:23, Lester Caine wrote:
>>
>> Have been round a few houses, I now have a stable setup that I'm happy
>> that I can manage, but I've lost something in the process ...
>>
>> Someone generated a nice patch to get the sub-repo view working in the
>> web interface. I'm probably going to go down a slightly different path
>> anyway, and create my own PHP controlled front page, but currently I
>> have http://lsces.co.uk/hg/ and http://lsces.co.uk/bwhg/ for the detail
>> ...
>> It would be nice to get the first page to wrap properly to the
>> 'super-projects' I'm working with.
>>
>> What is the current status of this ?
>
> I think Matt Schulte was maintaining the patch against hgweb for this, at
> least according to his mail back in May. Look for "Re: Returning to
> hgwebdir.cgi and subdirectories ..." in the archives for previous
> information.
>

I don't know if I would call it "maintaining the patch" as I don't
have the first clue what is actually happening in the code, however I
have been bringing this patch forward with each new release and it
still works for me.  I believe one of you two (Paul or Lester)
originally wrote this code.

Looks like the attachment got whacked by the list archiver so here was
the patch as of May 5th inline (I apologize if this is a no-no):

-------------------------------------------------------------
diff -r 31ec4d7eb63f mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue May 03 11:46:02 2011 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu May 05 09:41:26 2011 -0500
@@ -214,13 +214,61 @@
         def rawentries(subdir="", **map):

             descend = self.ui.configbool('web', 'descend', True)
+            seenrepos = set()
+            seendirs = set()
             for name, path in self.repos:

                 if not name.startswith(subdir):
                     continue
                 name = name[len(subdir):]
+                directory = False
+
                 if not descend and '/' in name:
-                    continue
+                    nameparts = name.split('/')
+                    rootname = nameparts[0]
+
+                    if rootname in seendirs:
+                        continue
+                    elif rootname in seenrepos:
+                        pass
+                    else:
+                        directory = True
+                        name = rootname
+
+                        # redefine the path to refer to the directory
+                        discarded = '/'.join(nameparts[1:])
+
+                        # remove name parts plus accompanying slash
+                        path = path[:-len(discarded) - 1]
+
+                parts = [name]
+                if 'PATH_INFO' in req.env:
+                    parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
+                if req.env['SCRIPT_NAME']:
+                    parts.insert(0, req.env['SCRIPT_NAME'])
+                url = re.sub(r'/+', '/', '/'.join(parts) + '/')
+
+                # show either a directory entry or a repository
+                if directory:
+                    # get the directory's time information
+                    try:
+                        d = (get_mtime(path), util.makedate()[1])
+                    except OSError:
+                        continue
+
+                    row = dict(contact="",
+                               contact_sort="",
+                               name=name,
+                               name_sort=name,
+                               url=url,
+                               description="",
+                               description_sort="",
+                               lastchange=d,
+                               lastchange_sort=d[1]-d[0],
+                               archives=[])
+
+                    seendirs.add(name)
+                    yield row

                 u = self.ui.copy()
                 try:
@@ -237,13 +285,6 @@
                 if not self.read_allowed(u, req):
                     continue

-                parts = [name]
-                if 'PATH_INFO' in req.env:
-                    parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
-                if req.env['SCRIPT_NAME']:
-                    parts.insert(0, req.env['SCRIPT_NAME'])
-                url = re.sub(r'/+', '/', '/'.join(parts) + '/')
-
                 # update time with local timezone
                 try:
                     r = hg.repository(self.ui, path)
@@ -268,6 +309,8 @@
                            lastchange=d,
                            lastchange_sort=d[1]-d[0],
                            archives=archivelist(u, "tip", url))
+
+                seenrepos.add(name)
                 yield row

         sortdefault = None, False
----------------------------------------------------------------------

I am not in the office currently so I cannot grab the current patch
right now, but I would be happy to send it again when I get back.

Matt Schulte



More information about the Mercurial mailing list