From patchwork Mon Jun 1 21:22:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [STABLE] hgwebdir: avoid redundant repo and directory entries when 'web.name' is set From: Matt Harbison X-Patchwork-Id: 9434 Message-Id: To: mercurial-devel@selenic.com Cc: matt_harbison@yahoo.com Date: Mon, 01 Jun 2015 17:22:34 -0400 # HG changeset patch # User Matt Harbison # Date 1433184175 14400 # Mon Jun 01 14:42:55 2015 -0400 # Branch stable # Node ID f78f73c02d135eb14b1b2bcfc4efdfee091ea684 # Parent 9dfcd6d9fd7268961db86bd6b15e9f3aaae40e38 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 --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -356,6 +356,7 @@ class hgwebdir(object): 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 @@ class hgwebdir(object): 'isdirectory': None, } - seenrepos.add(name) yield row sortdefault = None, False diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t --- a/tests/test-hgwebdir.t +++ b/tests/test-hgwebdir.t @@ -56,6 +56,13 @@ create a subdirectory containing reposit $ 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 @@ should succeed, slashy names - coll/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -409,7 +416,7 @@ should succeed, slashy names - rcoll/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -500,7 +507,7 @@ should succeed, slashy names - star/webdir/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -604,7 +611,7 @@ should succeed, slashy names - starstar/webdir/notrepo/f + fancy name for repo f unknown Foo Bar <foo.bar@example.com> * (glob) @@ -900,6 +907,7 @@ Test collapse = True $ 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