Patchwork [STABLE] hgwebdir: avoid redundant repo and directory entries when 'web.name' is set

login
register
mail settings
Submitter Matt Harbison
Date June 1, 2015, 9:22 p.m.
Message ID <f78f73c02d135eb14b1b.1433193754@MATT7H-PC.attotech.com>
Download mbox | patch
Permalink /patch/9434/
State Accepted
Headers show

Comments

Matt Harbison - June 1, 2015, 9:22 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# 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.

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
@@ -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
   </tr>
   
   <tr>
-  <td><a href="/coll/notrepo/f/?style=paper">coll/notrepo/f</a></td>
+  <td><a href="/coll/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -409,7 +416,7 @@  should succeed, slashy names
   </tr>
   
   <tr>
-  <td><a href="/rcoll/notrepo/f/?style=paper">rcoll/notrepo/f</a></td>
+  <td><a href="/rcoll/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -500,7 +507,7 @@  should succeed, slashy names
   </tr>
   
   <tr>
-  <td><a href="/star/webdir/notrepo/f/?style=paper">star/webdir/notrepo/f</a></td>
+  <td><a href="/star/webdir/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -604,7 +611,7 @@  should succeed, slashy names
   </tr>
   
   <tr>
-  <td><a href="/starstar/webdir/notrepo/f/?style=paper">starstar/webdir/notrepo/f</a></td>
+  <td><a href="/starstar/webdir/notrepo/f/?style=paper">fancy name for repo f</a></td>
   <td>unknown</td>
   <td>&#70;&#111;&#111;&#32;&#66;&#97;&#114;&#32;&#60;&#102;&#111;&#111;&#46;&#98;&#97;&#114;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#62;</td>
   <td class="age">*</td> (glob)
@@ -900,6 +907,7 @@  Test collapse = True
   $ cat >> paths.conf <<EOF
   > [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