[PATCH] paramiter to show folder navigation in web view instead of listing all repositories in the hgweb.conf

Diego de Oliveira lokimad at gmail.com
Tue May 26 20:48:49 CDT 2009


# HG changeset patch
# User diego at diegooliveira.com
# Date 1243388298 10800
# Node ID 8efe071dffc73bf6f3062d1fbaa422780d80172d
# Parent  c31fe74a66335b99907ce622eb8d79f372db3f81
paramiter to show folder navigation in web view instead of listing all repositories in the hgweb.conf

diff -r c31fe74a6633 -r 8efe071dffc7 doc/hgrc.5.txt
--- a/doc/hgrc.5.txt	Tue May 26 23:49:53 2009 +0200
+++ b/doc/hgrc.5.txt	Tue May 26 22:38:18 2009 -0300
@@ -786,6 +786,10 @@
     Example: "UTF-8"
   errorlog;;
     Where to output the error log. Default is stderr.
+  folderview;;
+    Shows the folders for navigation if using a collections of repositories
+    in paths. Instead of show "Folder\Repository" will show just
+    "Folder\". 
   hidden;;
     Whether to hide the repository in the hgwebdir index. Default is false.
   ipv6;;
diff -r c31fe74a6633 -r 8efe071dffc7 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue May 26 23:49:53 2009 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue May 26 22:38:18 2009 -0300
@@ -197,17 +197,27 @@
         def entries(sortcolumn="", descending=False, subdir="", **map):
             rows = []
             parity = paritygen(self.stripecount)
+            
+            
+            paths = {'' : '' }
             for name, path in self.repos:
                 if not name.startswith(subdir):
                     continue
                 name = name[len(subdir):]
-
+                
+                def isRepository(rootPath, u):
+                    hgrcPath = os.path.join(rootPath, '.hg', 'hgrc')
+                    try:
+                        u.readconfig(hgrcPath)
+                        return True
+                    except Exception, e:
+                        u.warn(_('error reading %s/.hg/hgrc: %s\n') % (rootPath, e))
+                        return False 
+                
                 u = self.ui.copy()
-                try:
-                    u.readconfig(os.path.join(path, '.hg', 'hgrc'))
-                except Exception, e:
-                    u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e))
+                if not isRepository(path, u):
                     continue
+                
                 def get(section, name, default=None):
                     return u.config(section, name, default, untrusted=True)
 
@@ -229,10 +239,39 @@
                     d = (get_mtime(path), util.makedate()[1])
                 except OSError:
                     continue
-
+                
+                #Parser the path to group folders 
+                #with repositories
+                displayngFolder = False
+                if get('web', 'folderview') is not None :
+                    nameSplit = name.split('/')
+                    name = nameSplit[0]
+                    
+                    urlSplit = url.split('/')
+                    auxUrl = ''
+                    for part in urlSplit:
+                        if part == '':
+                            continue 
+                        if subdir.startswith( auxUrl + part + '/') :
+                            auxUrl += '/' + part
+                            continue
+                        auxUrl += '/' + part + '/'
+                        break
+                       
+                    if paths.has_key(auxUrl):
+                        continue
+                    paths[auxUrl] = auxUrl
+                    displayngFolder = auxUrl != url
+                    url = auxUrl    
+                
                 contact = get_contact(get)
                 description = get("web", "description", "")
                 name = get("web", "name", name)
+                
+                if displayngFolder :
+                    contact = _('-')
+                    description = _('Repository group folder')
+                    
                 row = dict(contact=contact or "unknown",
                            contact_sort=contact.upper() or "unknown",
                            name=name,


More information about the Mercurial-devel mailing list