[PATCH 1 of 1 stable rfc] hgweb: handle paths with wildcards expanding in a repository root

Mads Kiilerich mads at kiilerich.com
Wed Feb 2 20:33:54 CST 2011


Do you agree that this is how it should work?

Or should 'repo' be excluded when expanding 'repo/*'? That could make sense,
but it wouldn't be very convenient.


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1296700431 -3600
# Branch stable
# Node ID 0497e8f94992e481eca3abb773b2501cf28a906a
# Parent  5fc7c84ed9b0ae9c3b9d16214db147405627d7dd
hgweb: handle paths with wildcards expanding in a repository root

There was a trailing / too much when the wildcard expanded to nothing.

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
@@ -35,9 +35,8 @@
         roothead = os.path.normpath(os.path.abspath(roothead))
         for path in util.walkrepos(roothead, followsym=True, recurse=recurse):
             path = os.path.normpath(path)
-            name = util.pconvert(path[len(roothead):]).strip('/')
-            if prefix:
-                name = prefix + '/' + name
+            name = (prefix + '/' +
+                    util.pconvert(path[len(roothead):]).lstrip('/')).strip('/')
             repos.append((name, path))
     return repos
 
diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t
--- a/tests/test-hgwebdir.t
+++ b/tests/test-hgwebdir.t
@@ -99,6 +99,7 @@
   > rcoll=$root/**
   > star=*
   > starstar=**
+  > astar=webdir/a/*
   > EOF
   $ hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
   >     -A access-paths.log -E error-paths-2.log
@@ -130,6 +131,8 @@
   /starstar/webdir/b/
   /starstar/webdir/b/d/
   /starstar/webdir/c/
+  /astar/
+  /astar/.hg/patches/
   
   $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/?style=paper'
   200 Script output follows
@@ -322,6 +325,22 @@
   <td class="indexlinks"></td>
   </tr>
   
+  <tr class="parity0">
+  <td><a href="/astar/?style=paper">astar</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">* ago</td> (glob)
+  <td class="indexlinks"></td>
+  </tr>
+  
+  <tr class="parity1">
+  <td><a href="/astar/.hg/patches/?style=paper">astar/.hg/patches</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">* ago</td> (glob)
+  <td class="indexlinks"></td>
+  </tr>
+  
   </table>
   </div>
   </div>
@@ -470,7 +489,7 @@
   
   a
 
-est [paths] '**' extension
+Test [paths] '**' extension
 
   $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/rcoll/?style=raw'
   200 Script output follows
@@ -486,6 +505,12 @@
   200 Script output follows
   
   d
+
+Test [paths] '*' in a repo root
+
+  $ hg id http://localhost:$HGPORT1/astar
+  8580ff50825a
+
   $ "$TESTDIR/killdaemons.py"
   $ cat > paths.conf <<EOF
   > [paths]


More information about the Mercurial-devel mailing list