# HG changeset patch # User Matt Harbison # Date 1433184175 14400 # Node ID 78e8890cfb4b49fad98f6cd5419fd736fb24aec0 # Parent d46f6b07879952ccd5c93cf16018cf5501f77a04 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. diff -r d46f6b078799 -r 78e8890cfb4b mercurial/hgweb/hgwebdir_mod.py --- 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 diff -r d46f6b078799 -r 78e8890cfb4b tests/test-hgwebdir.t --- 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 @@ - coll/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -409,7 +416,7 @@ - rcoll/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -500,7 +507,7 @@ - star/webdir/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -604,7 +611,7 @@ - starstar/webdir/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -900,6 +907,7 @@ $ cat >> paths.conf < [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