changeset 25426:5f3666da6910 stable

hgwebdir: don't allow the hidden parent of a subrepo to show as a directory Previously, if a subrepo parent had 'web.hidden=True' set, neither the parent nor child had a repository entry. However, the directory entry for the parent would be listed (it wouldn't have the fancy 'web.name' if configured), and that link went to the repo's summary page, effectively making it not hidden. This simply disables the directory processing if a valid repository is present. Whether or not the subrepo should be hidden is debatable, but this leaves that behavior unchanged (i.e. it stays hidden).
author Matt Harbison <mharbison@attotech.com>
date Mon, 01 Jun 2015 18:06:20 -0400
parents 9263f86b9681
children d0c7ffc4c8bc 093d38165e5a
files mercurial/hgweb/hgwebdir_mod.py tests/test-hgwebdir.t
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Jun 03 14:29:11 2015 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Mon Jun 01 18:06:20 2015 -0400
@@ -292,6 +292,12 @@
                         # remove name parts plus accompanying slash
                         path = path[:-len(discarded) - 1]
 
+                        try:
+                            r = hg.repository(self.ui, path)
+                            directory = False
+                        except (IOError, error.RepoError):
+                            pass
+
                 parts = [name]
                 if 'PATH_INFO' in req.env:
                     parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
--- a/tests/test-hgwebdir.t	Wed Jun 03 14:29:11 2015 -0700
+++ b/tests/test-hgwebdir.t	Mon Jun 01 18:06:20 2015 -0400
@@ -944,6 +944,25 @@
 
 Test intermediate directories
 
+Hide the subrepo parent
+
+  $ cp $root/notrepo/f/.hg/hgrc $root/notrepo/f/.hg/hgrc.bak
+  $ cat >> $root/notrepo/f/.hg/hgrc << EOF
+  > [web]
+  > hidden = True
+  > EOF
+
+  $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 'rcoll/notrepo/?style=raw'
+  200 Script output follows
+  
+  
+  /rcoll/notrepo/e/
+  /rcoll/notrepo/e/e2/
+  
+
+Subrepo parent not hidden
+  $ mv $root/notrepo/f/.hg/hgrc.bak $root/notrepo/f/.hg/hgrc
+
   $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 'rcoll/notrepo/?style=raw'
   200 Script output follows