# HG changeset patch # User Matt Harbison # Date 2015-06-01 22:06:20 # Node ID 5f3666da691005d8f2c8afe9d2c249ee80fa96ed # Parent 9263f86b96810cda7df0113328fae71f1c22650f 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