##// END OF EJS Templates
hgwebdir: add support for explicit index files...
Matt Harbison -
r31482:da7d1932 default
parent child Browse files
Show More
@@ -254,13 +254,21 b' class hgwebdir(object):'
254 return []
254 return []
255
255
256 # top-level index
256 # top-level index
257 elif not virtual:
257
258 repos = dict(self.repos)
259
260 if not virtual or (virtual == 'index' and virtual not in repos):
258 req.respond(HTTP_OK, ctype)
261 req.respond(HTTP_OK, ctype)
259 return self.makeindex(req, tmpl)
262 return self.makeindex(req, tmpl)
260
263
261 # nested indexes and hgwebs
264 # nested indexes and hgwebs
262
265
263 repos = dict(self.repos)
266 if virtual.endswith('/index') and virtual not in repos:
267 subdir = virtual[:-len('index')]
268 if any(r.startswith(subdir) for r in repos):
269 req.respond(HTTP_OK, ctype)
270 return self.makeindex(req, tmpl, subdir)
271
264 virtualrepo = virtual
272 virtualrepo = virtual
265 while virtualrepo:
273 while virtualrepo:
266 real = repos.get(virtualrepo)
274 real = repos.get(virtualrepo)
@@ -352,8 +360,7 b' class hgwebdir(object):'
352 pass
360 pass
353
361
354 parts = [name]
362 parts = [name]
355 if 'PATH_INFO' in req.env:
363 parts.insert(0, '/' + subdir.rstrip('/'))
356 parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
357 if req.env['SCRIPT_NAME']:
364 if req.env['SCRIPT_NAME']:
358 parts.insert(0, req.env['SCRIPT_NAME'])
365 parts.insert(0, req.env['SCRIPT_NAME'])
359 url = re.sub(r'/+', '/', '/'.join(parts) + '/')
366 url = re.sub(r'/+', '/', '/'.join(parts) + '/')
@@ -1566,6 +1566,119 b' immediately.'
1566 /b/
1566 /b/
1567 /c/
1567 /c/
1568
1568
1569 $ killdaemons.py
1570 $ cat > paths.conf << EOF
1571 > [paths]
1572 > /dir1/a_repo = $root/a
1573 > /dir1/a_repo/b_repo = $root/b
1574 > /dir1/dir2/index = $root/b
1575 > EOF
1576 $ hg serve -p $HGPORT1 -d --pid-file hg.pid --webdir-conf paths.conf
1577 $ cat hg.pid >> $DAEMON_PIDS
1578
1579 $ echo 'index file' > $root/a/index
1580 $ hg --cwd $root/a ci -Am 'add index file'
1581 adding index
1582
1583 $ get-with-headers.py localhost:$HGPORT1 '' | grep 'a_repo'
1584 <td><a href="/dir1/a_repo/">dir1/a_repo</a></td>
1585 <a href="/dir1/a_repo/atom-log" title="subscribe to repository atom feed">
1586 <td><a href="/dir1/a_repo/b_repo/">dir1/a_repo/b_repo</a></td>
1587 <a href="/dir1/a_repo/b_repo/atom-log" title="subscribe to repository atom feed">
1588
1589 $ get-with-headers.py localhost:$HGPORT1 'index' | grep 'a_repo'
1590 <td><a href="/dir1/a_repo/">dir1/a_repo</a></td>
1591 <a href="/dir1/a_repo/atom-log" title="subscribe to repository atom feed">
1592 <td><a href="/dir1/a_repo/b_repo/">dir1/a_repo/b_repo</a></td>
1593 <a href="/dir1/a_repo/b_repo/atom-log" title="subscribe to repository atom feed">
1594
1595 $ get-with-headers.py localhost:$HGPORT1 'dir1' | grep 'a_repo'
1596 <td><a href="/dir1/a_repo/">a_repo</a></td>
1597 <a href="/dir1/a_repo/atom-log" title="subscribe to repository atom feed">
1598 <td><a href="/dir1/a_repo/b_repo/">a_repo/b_repo</a></td>
1599 <a href="/dir1/a_repo/b_repo/atom-log" title="subscribe to repository atom feed">
1600
1601 $ get-with-headers.py localhost:$HGPORT1 'dir1/index' | grep 'a_repo'
1602 <td><a href="/dir1/a_repo/">a_repo</a></td>
1603 <a href="/dir1/a_repo/atom-log" title="subscribe to repository atom feed">
1604 <td><a href="/dir1/a_repo/b_repo/">a_repo/b_repo</a></td>
1605 <a href="/dir1/a_repo/b_repo/atom-log" title="subscribe to repository atom feed">
1606
1607 $ get-with-headers.py localhost:$HGPORT1 'dir1/a_repo' | grep 'a_repo'
1608 <link rel="icon" href="/dir1/a_repo/static/hgicon.png" type="image/png" />
1609 <link rel="stylesheet" href="/dir1/a_repo/static/style-paper.css" type="text/css" />
1610 <script type="text/javascript" src="/dir1/a_repo/static/mercurial.js"></script>
1611 <title>dir1/a_repo: log</title>
1612 href="/dir1/a_repo/atom-log" title="Atom feed for dir1/a_repo" />
1613 href="/dir1/a_repo/rss-log" title="RSS feed for dir1/a_repo" />
1614 <img src="/dir1/a_repo/static/hglogo.png" alt="mercurial" /></a>
1615 <li><a href="/dir1/a_repo/graph/tip">graph</a></li>
1616 <li><a href="/dir1/a_repo/tags">tags</a></li>
1617 <li><a href="/dir1/a_repo/bookmarks">bookmarks</a></li>
1618 <li><a href="/dir1/a_repo/branches">branches</a></li>
1619 <li><a href="/dir1/a_repo/rev/tip">changeset</a></li>
1620 <li><a href="/dir1/a_repo/file/tip">browse</a></li>
1621 <li><a href="/dir1/a_repo/help">help</a></li>
1622 <a href="/dir1/a_repo/atom-log" title="subscribe to atom feed">
1623 <img class="atom-logo" src="/dir1/a_repo/static/feed-icon-14x14.png" alt="atom feed" />
1624 <h2 class="breadcrumb"><a href="/">Mercurial</a> &gt; <a href="/dir1">dir1</a> &gt; <a href="/dir1/a_repo">a_repo</a> </h2>
1625 <form class="search" action="/dir1/a_repo/log">
1626 number or hash, or <a href="/dir1/a_repo/help/revsets">revset expression</a>.</div>
1627 <a href="/dir1/a_repo/shortlog/tip?revcount=30">less</a>
1628 <a href="/dir1/a_repo/shortlog/tip?revcount=120">more</a>
1629 | rev 1: <a href="/dir1/a_repo/shortlog/8580ff50825a">(0)</a> <a href="/dir1/a_repo/shortlog/tip">tip</a>
1630 <a href="/dir1/a_repo/rev/71a89161f014">add index file</a>
1631 <a href="/dir1/a_repo/rev/8580ff50825a">a</a>
1632 <a href="/dir1/a_repo/shortlog/tip?revcount=30">less</a>
1633 <a href="/dir1/a_repo/shortlog/tip?revcount=120">more</a>
1634 | rev 1: <a href="/dir1/a_repo/shortlog/8580ff50825a">(0)</a> <a href="/dir1/a_repo/shortlog/tip">tip</a>
1635 '/dir1/a_repo/shortlog/%next%',
1636
1637 $ get-with-headers.py localhost:$HGPORT1 'dir1/a_repo/index' | grep 'a_repo'
1638 <h2 class="breadcrumb"><a href="/">Mercurial</a> &gt; <a href="/dir1">dir1</a> &gt; <a href="/dir1/a_repo">a_repo</a> </h2>
1639 <td><a href="/dir1/a_repo/b_repo/">b_repo</a></td>
1640 <a href="/dir1/a_repo/b_repo/atom-log" title="subscribe to repository atom feed">
1641
1642 Files named 'index' are not blocked
1643
1644 $ get-with-headers.py localhost:$HGPORT1 'dir1/a_repo/raw-file/tip/index'
1645 200 Script output follows
1646
1647 index file
1648
1649 Repos named 'index' take precedence over the index file
1650
1651 $ get-with-headers.py localhost:$HGPORT1 'dir1/dir2/index' | grep 'index'
1652 <link rel="icon" href="/dir1/dir2/index/static/hgicon.png" type="image/png" />
1653 <meta name="robots" content="index, nofollow" />
1654 <link rel="stylesheet" href="/dir1/dir2/index/static/style-paper.css" type="text/css" />
1655 <script type="text/javascript" src="/dir1/dir2/index/static/mercurial.js"></script>
1656 <title>dir1/dir2/index: log</title>
1657 href="/dir1/dir2/index/atom-log" title="Atom feed for dir1/dir2/index" />
1658 href="/dir1/dir2/index/rss-log" title="RSS feed for dir1/dir2/index" />
1659 <img src="/dir1/dir2/index/static/hglogo.png" alt="mercurial" /></a>
1660 <li><a href="/dir1/dir2/index/graph/tip">graph</a></li>
1661 <li><a href="/dir1/dir2/index/tags">tags</a></li>
1662 <li><a href="/dir1/dir2/index/bookmarks">bookmarks</a></li>
1663 <li><a href="/dir1/dir2/index/branches">branches</a></li>
1664 <li><a href="/dir1/dir2/index/rev/tip">changeset</a></li>
1665 <li><a href="/dir1/dir2/index/file/tip">browse</a></li>
1666 <li><a href="/dir1/dir2/index/help">help</a></li>
1667 <a href="/dir1/dir2/index/atom-log" title="subscribe to atom feed">
1668 <img class="atom-logo" src="/dir1/dir2/index/static/feed-icon-14x14.png" alt="atom feed" />
1669 <h2 class="breadcrumb"><a href="/">Mercurial</a> &gt; <a href="/dir1">dir1</a> &gt; <a href="/dir1/dir2">dir2</a> &gt; <a href="/dir1/dir2/index">index</a> </h2>
1670 <form class="search" action="/dir1/dir2/index/log">
1671 number or hash, or <a href="/dir1/dir2/index/help/revsets">revset expression</a>.</div>
1672 <a href="/dir1/dir2/index/shortlog/tip?revcount=30">less</a>
1673 <a href="/dir1/dir2/index/shortlog/tip?revcount=120">more</a>
1674 | rev 0: <a href="/dir1/dir2/index/shortlog/39505516671b">(0)</a> <a href="/dir1/dir2/index/shortlog/tip">tip</a>
1675 <a href="/dir1/dir2/index/rev/39505516671b">b</a>
1676 <a href="/dir1/dir2/index/shortlog/tip?revcount=30">less</a>
1677 <a href="/dir1/dir2/index/shortlog/tip?revcount=120">more</a>
1678 | rev 0: <a href="/dir1/dir2/index/shortlog/39505516671b">(0)</a> <a href="/dir1/dir2/index/shortlog/tip">tip</a>
1679 '/dir1/dir2/index/shortlog/%next%',
1680
1681 $ killdaemons.py
1569
1682
1570 paths errors 1
1683 paths errors 1
1571
1684
General Comments 0
You need to be logged in to leave comments. Login now