changeset 25396:78e8890cfb4b stable

hgwebdir: avoid redundant repo and directory entries when 'web.name' is set Previously, when 'web.name' was set on a subrepo parent and 'web.collapse=True', the parent repo would show in the list with the configured 'web.name', and a directory with the parent repo's filesystem name (with a trailing slash) would also appear. The subrepo(s) would unexpectedly be excluded from the list of repositories. Clicking the directory entry would go right to the repo page. Now both the parent and the subrepos show up, without the additional directory entry. The configured hgweb paths used '**' for finding the repos in this scenario. A couple of notes about the tests: - The area where the subrepo was added has a comment that it tests subrepos, though none previously existed there. One now does. - The 'web.descend' option is required for collapse to work. I'm not sure what the previous expectations were for the test. Nothing changed with it set, prior to adding the code in this patch. It is however required for this test. - The only output changes are for the hyperlinks, obviously because of the 'web.name' parameter. - Without this code change, there would be an additional diff: --- /usr/local/mercurial/tests/test-hgwebdir.t +++ /usr/local/mercurial/tests/test-hgwebdir.t.err @@ -951,7 +951,7 @@ /rcoll/notrepo/e/ /rcoll/notrepo/e/e2/ /rcoll/notrepo/f/ - /rcoll/notrepo/f/f2/ + /rcoll/notrepo/f/ Test repositories inside intermediate directories I'm not sure why the fancy name doesn't come out, but it is enough to demonstrate that the parent is not listed redundantly, and the subrepo isn't skipped.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 01 Jun 2015 14:42:55 -0400
parents d46f6b078799
children 724d7982b790 9263f86b9681
files mercurial/hgweb/hgwebdir_mod.py tests/test-hgwebdir.t
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Mon Jun 01 15:16:28 2015 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Mon Jun 01 14:42:55 2015 -0400
@@ -356,6 +356,7 @@
 
                 contact = get_contact(get)
                 description = get("web", "description", "")
+                seenrepos.add(name)
                 name = get("web", "name", name)
                 row = {'contact': contact or "unknown",
                        'contact_sort': contact.upper() or "unknown",
@@ -370,7 +371,6 @@
                        'isdirectory': None,
                        }
 
-                seenrepos.add(name)
                 yield row
 
         sortdefault = None, False
--- a/tests/test-hgwebdir.t	Mon Jun 01 15:16:28 2015 -0500
+++ b/tests/test-hgwebdir.t	Mon Jun 01 14:42:55 2015 -0400
@@ -56,6 +56,13 @@
   $ echo f2 > f/f2/f2
   $ hg --cwd f/f2 ci -Amf2 -d '4 0'
   adding f2
+  $ echo 'f2 = f2' > f/.hgsub
+  $ hg -R f ci -Am 'add subrepo' -d'4 0'
+  adding .hgsub
+  $ cat >> f/.hg/hgrc << EOF
+  > [web]
+  > name = fancy name for repo f
+  > EOF
   $ cd ..
 
 create repository without .hg/store
@@ -305,7 +312,7 @@
   </tr>
   
   <tr>
-  <td><a href="/coll/notrepo/f/?style=paper">coll/notrepo/f</a></td>
+  <td><a href="/coll/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -409,7 +416,7 @@
   </tr>
   
   <tr>
-  <td><a href="/rcoll/notrepo/f/?style=paper">rcoll/notrepo/f</a></td>
+  <td><a href="/rcoll/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -500,7 +507,7 @@
   </tr>
   
   <tr>
-  <td><a href="/star/webdir/notrepo/f/?style=paper">star/webdir/notrepo/f</a></td>
+  <td><a href="/star/webdir/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -604,7 +611,7 @@
   </tr>
   
   <tr>
-  <td><a href="/starstar/webdir/notrepo/f/?style=paper">starstar/webdir/notrepo/f</a></td>
+  <td><a href="/starstar/webdir/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -900,6 +907,7 @@
   $ cat >> paths.conf <<EOF
   > [web]
   > collapse=true
+  > descend = true
   > EOF
   $ hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
   >     -A access-paths.log -E error-paths-3.log