[PATCH STABLE] hgwebdir: don't allow the hidden parent of a subrepo to show as a directory

Matt Harbison mharbison at attotech.com
Mon Jun 1 17:29:37 CDT 2015


# HG changeset patch
# User Matt Harbison <mharbison at attotech.com>
# Date 1433196380 14400
#      Mon Jun 01 18:06:20 2015 -0400
# Branch stable
# Node ID 2a85b335cdc3fc6f410884c068bc7787ac4fa5b0
# Parent  f78f73c02d135eb14b1b2bcfc4efdfee091ea684
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).

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
@@ -292,6 +292,12 @@ class hgwebdir(object):
                         # 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('/'))
diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t
--- a/tests/test-hgwebdir.t
+++ b/tests/test-hgwebdir.t
@@ -944,6 +944,25 @@ Test collapse = True
 
 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
   


More information about the Mercurial-devel mailing list