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

login
register
mail settings
Submitter Matt Harbison
Date June 1, 2015, 10:29 p.m.
Message ID <2a85b335cdc3fc6f4108.1433197777@MATT7H-PC.attotech.com>
Download mbox | patch
Permalink /patch/9435/
State Superseded
Commit 5f3666da691005d8f2c8afe9d2c249ee80fa96ed
Headers show

Comments

Matt Harbison - June 1, 2015, 10:29 p.m.
# HG changeset patch
# User Matt Harbison <mharbison@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).
Pierre-Yves David - June 2, 2015, 7:26 a.m.
On 06/01/2015 03:29 PM, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <mharbison@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

This one is pushed to the clowncopter.

Congratulation for missing the bug fix release by less than 15 minutes ;-)
Matt Harbison - June 4, 2015, 12:46 a.m.
On Tue, 02 Jun 2015 03:26:27 -0400, Pierre-Yves David  
<pierre-yves.david@ens-lyon.org> wrote:

>
>
> On 06/01/2015 03:29 PM, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison <mharbison@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
>
> This one is pushed to the clowncopter.
>
> Congratulation for missing the bug fix release by less than 15 minutes  
> ;-)
>

Should I resend this?  One with the same topic[1] got ninja queued as  
78e8890cfb4b, but I don't see this in main, crew or clowncopter.

[1] https://www.selenic.com/pipermail/mercurial-devel/2015-June/070680.html
Matt Mackall - June 4, 2015, 6:51 p.m.
On Wed, 2015-06-03 at 20:46 -0400, Matt Harbison wrote:
> On Tue, 02 Jun 2015 03:26:27 -0400, Pierre-Yves David  
> <pierre-yves.david@ens-lyon.org> wrote:
> 
> >
> >
> > On 06/01/2015 03:29 PM, Matt Harbison wrote:
> >> # HG changeset patch
> >> # User Matt Harbison <mharbison@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
> >
> > This one is pushed to the clowncopter.
> >
> > Congratulation for missing the bug fix release by less than 15 minutes  
> > ;-)
> >
> 
> Should I resend this?  One with the same topic[1] got ninja queued as  
> 78e8890cfb4b, but I don't see this in main, crew or clowncopter.

Please do.

Patch

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