Commit Graph

685 Commits

Author SHA1 Message Date
Mads Kiilerich
e4f8deae3f hgweb: simplify internal staticfile return codes 2013-02-10 18:24:29 +01:00
Benoit Boissinot
b38415dcd7 templates: export extra as a dict to templates
Currently only useful with the json filter.
2013-02-08 21:55:46 +01:00
Kevin Bullock
eb96ccda75 hgweb: make 'summary' work with hidden changesets (issue3810)
Since the 'summary' view used by e.g. gitweb and monoblue shows both a
changelog and a bookmarks list, the same changes are needed here as were
made to the 'changelog' and 'bookmarks' web commands (2be8fa4eef83 and
70f6745775fa, respectively).
2013-02-05 11:31:43 -06:00
Mads Kiilerich
33daab8991 hgweb.cgi: fix internal WSGI emulation (issue3804)
The internal WSGI emulation in wsgicgi.py was not fully WSGI compliant and
assumed that all responses sent a body. With a9df76d7ca1f that caused a real
bug when using hgweb.cgi.

wsgicgi.py will now make sure headers always are sent, using the pattern from
PEP 333 and similar to how it is done in 38e07483cc16.
2013-02-04 23:25:25 +01:00
Matt Mackall
a1152e87ba merge with crew 2013-02-01 15:14:05 -06:00
Kevin Bullock
21ba139cdc hgweb: rename 'currentbaseline' template keyword to 'basenode'
Shorter and clearer. This keyword represents the node we're currently
diffing against.
2013-02-01 10:12:41 -06:00
Angel Ezquerra
b6d710beb8 hgwebdir: use web.prefix when creating url breadcrumbs (issue3790)
The web.prefix setting was being ignored when creating the index URL
breadcrumbs.

We only need to fix hgwebdir and not hgweb because hgweb gets the complete URL
request, including the prefix, while hgwebdir gets a "subdir" which does not
include the prefix.

This fix is slightly different of what was suggested on the bug tracker. In
there it was suggested to hide the prefix itself from the breadcrumb. I think
that would be a better solution, but it would require changing all the index
templates and passing the prefix to the template engine, which may be too big
a change for stable during the freeze. For now this fixes the problem, and the
fix could be improved during the next cycle.
2013-01-31 22:36:22 +01:00
Pierre-Yves David
32e4185163 hgweb: add a web.view to control filtering
This options add a new `web.view` to control filter level of hgweb.

This option have two purposes:

1) Allow fall back to unfiltered version in case a yet undetected by critical
   bug is found in filtering after 2.5 release

2) People use hgweb as a local repoviewer. When they have secret changesets,
   they wants to use "visible" filter not "served"

(modified by mpm, documentation deferred)
2013-01-31 19:56:55 +01:00
Pierre-Yves David
090c6ed52d hgweb: returns 404 for unknow revision instead of 500
I noticed that access to filtered revision returned HTTP 500 code (internal
server error). Investigation shown that it was the case for unknown revision
too. That wrong and we now properly return a 404 for revision not found.
2013-01-31 22:30:52 +01:00
Pierre-Yves David
11f4fbd0aa hgweb: fix navigation label (issue3792)
Latest refactoring (6653e43a8a16) was buggy and used a variable from
another loop.  Tests are run on repo too small to cache that.
2013-01-30 17:32:17 +01:00
Pierre-Yves David
efe098ab89 hgweb: prevent traceback during search when filtered (issue3783)
The search needs to iterate over the repo using changelog.revs like the rest of
the Mercurial code.
2013-01-29 16:44:51 +01:00
Kevin Bullock
dd5421b6fc hgweb: don't attempt to show hidden bookmarks (issue3774)
localrepository._bookmarks is unfiltered, but hgweb gets a filtered
repo. This fixes the resulting traceback on the 'bookmarks' page.
2013-01-25 11:43:54 -06:00
Kevin Bullock
03497018d8 hgweb: fetch tipmost unfiltered rev thru the changelog
This fixes a traceback when tip is filtered (e.g. because it's secret).
See issue3783, for which this is a partial fix.
2013-01-25 14:50:18 -06:00
Pierre-Yves David
64c0cafb9c hgweb: run with "served" filter
This changeset enable the "served" filter on all repo used by hgweb.

Hgweb misbehave in a lot of when filtering changeset are present but I do not
expect normal people to have secret or obsolete changeset on they server.
Misbehavior will be gradually fixed later.
2013-01-15 22:34:56 +01:00
Pierre-Yves David
afe0e7e52e hgweb: walk the graph through the changelog
This is necessary to enforce filtering. The result is a bit buggy (may provide
less changeset than expected, but it will stop crashing on filtered revision
access.

Note that changelog.revs can not represents empty iteration like xrange did. So
we have to explicitly prevent call when there is nothing to do.
2013-01-16 14:22:43 +01:00
Pierre-Yves David
fecb76e6b6 hgweb: use changelog for iteration
Iterating through changelog is  necessary to enforce filtering.
2013-01-11 01:08:00 +01:00
Pierre-Yves David
33157b2eac hgweb: ignore filtered revision in revnav
This changeset checks that a revision is known before adding it to the
navigation.

This will prevent traceback on filtered repository. This changeset result in an
incorrect behaviors, Navigation link may be dropped without any replacement.
However this bad navigation generation is much better than a crash
2013-01-16 14:19:28 +01:00
Pierre-Yves David
d99c8321fd hgweb: generate revnav in two phase
We first generate revision to link. Then we dispatch them in before, after list.

This will help filtering of unknown revision.
2013-01-10 19:29:48 +01:00
Pierre-Yves David
ec4010668e hgweb: pass repo object to revnav construction
For compatibility with changelog filtering we need access to the changelog, a
simple nodefunc is not sufficient, only the changelog and repo have access the
filteredrevs information.

For the filerevnav version, we use an unfiltered changelog. Linkrev is currently
broken with filtering and we need some failsafe to prevent traceback. This is
the same approach as the one used in 83a1b777fc02. The use of
filectx.changectx() allowed the previous code to use the 83a1b777fc02 hack.

This changeset may result in an incorrect behaviors, Navigation
link may point to missing revision. However this bad navigation
generation is much better than a plain crash
2013-01-16 13:18:22 +01:00
Pierre-Yves David
8864c08405 hgweb: introduction a filerevnav subclass
It'll be use to implement the file specific behavior.
2013-01-14 16:55:48 +01:00
Pierre-Yves David
ef8c7f5679 hgweb: simplify addition of "(0) navigation entry" 2013-01-10 19:09:32 +01:00
Pierre-Yves David
ab2828d3df hgweb: simplify the handling of empty repo
This abstraction have two advantages:

- If the revlog is empty, None of the code bellow is relevant,
  early returns seems a win.

- Abtraction of the 'emptiness' check will help later when we stop relying on
  nodefunc.

A bonus, with filtering, a non-empty revlog may not have '0' revision
accessible. It'll be easier to handle with the emptiness test in a dedicated
function
2013-01-14 16:30:06 +01:00
Pierre-Yves David
90fd1410db hgweb: move hex creation into an object method
This is clearer and allow later overwrite.
2013-01-10 18:54:50 +01:00
Pierre-Yves David
9a966205d5 hgweb: pass nodefunc to the revnav object
The issue between hgweb and filtering lay in this function. Moving it into the
object itself helps to abstract the erroneous bit.
2013-01-10 18:59:37 +01:00
Pierre-Yves David
4b000107bc hgweb: move revnavgen into an object
For later compatibility with changelog filtering some part of the navigation
generation logic will be altered. Those altered part will be different when in
the changelog case and in the filelog case. Moving this into an object will
allow to use inheritance to override just the part of the logic we need.

The aimed logic are for example:

- generation of revision 'hex' (different logic for changelog and filelog)
- revlog emptyness test
- fetching of the first revision of a revlog (may not be 0)
2013-01-15 21:17:18 +01:00
Pierre-Yves David
76b143ef87 hgweb: limit argument is actually latestonly renames and enforce
The `limit` argument of several generator have only two possible values in
practice: 0 and 1. We rename this parameter to `latestonly` and simplify it's
handling.

The simplification allows us to save fetching of data that we are sure to not
consume.

Having a function minimal function perimeter will helps future refactoring.
2013-01-16 12:51:24 +01:00
Pierre-Yves David
34e916676c hgweb: ensure _navseq yield strictly increasing numbers
This is not hard and allows to drop hack in the customer code.
2013-01-10 18:52:17 +01:00
Pierre-Yves David
21cc04b632 hgweb: better names for _navseq arguments
The old names were misleading.
2013-01-10 18:47:48 +01:00
Pierre-Yves David
cf7db1b791 hgweb: drop recursivity in _navseq
This is totally not needed.
2013-01-10 18:44:26 +01:00
Pierre-Yves David
32920e6f3b hgweb: move the seq function out of the revnavgen scope
There is not reason for it to be a in there. And this function could use a major
reworks.
2013-01-15 12:11:18 +01:00
Pierre-Yves David
c6e834a305 hgweb: simplify return value creation in for navgen
We now have access to better syntax allowing a clearer version.
2013-01-14 16:52:35 +01:00
Pierre-Yves David
2d6aca912a hgweb: do not access first changeset with a string
There is not reason not to use an int
2013-01-10 18:55:50 +01:00
Mads Kiilerich
5cabd60d62 serve: don't send any content headers with 304 responses
Fixes HTTP protocol violation introduced in e4a5f5db7028. 'hg serve' would show
a stacktrace when loading pages that not had been modified.

There was test coverage for this, but the wrong response headers wasn't shown
and thus not detected.
2013-01-15 20:54:57 +01:00
Mads Kiilerich
722f02dca0 hgweb: generate query strings with parameters sorted by key 2012-12-12 02:38:14 +01:00
Mads Kiilerich
3cb021c3b0 serve: use chunked encoding in hgweb responses
'hg serve' used to close connections when sending a response with unknown
length ... such as a bundle or archive.

Now chunked encoding will be used for responses with unknown length, and the
connection do thus not have to be closed to indicate the end of the response.

Chunked encoding is only used if the length is unknown, if the connection
wouldn't be closed for other reasons, AND if it is a HTTP 1.1 request.

This will not benefit other users of hgweb ... but it can serve as an example
that it can be done.
2013-01-15 01:10:08 +01:00
Mads Kiilerich
df2c27e00a serve: remove connection close hack for Python 2.3
Introduced in 172ac22869f4 and no longer needed - BaseHTTPServer handles
connection closing just fine if we don't mess with its internals.
2013-01-15 01:10:08 +01:00
Mads Kiilerich
202753eeb5 hgweb: pass the actual response body to request.response, not just the length
This makes it less likely to send a response that doesn't match Content-Length.
2013-01-15 01:07:03 +01:00
Mads Kiilerich
e3bf5c6dbe hgweb: don't pass empty response chunks on
hgweb internals will often produce empty writes - especially when returning
compressed data.  hgweb is no middleware application and there is thus no
reason to pass them on to be processed in other layers.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
00d7d25679 hgweb: remove handling of any else than strings from request.write
Iterators should be returned WSGI style, not written. And apparently all of
hgweb do that.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
01096c5713 serve: send response headers even if response has no body
The headers would usually be sent anyway because the app did a number of writes
of empty strings.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
ab33fcb117 hgweb: simplify wsgirequest header handling
Remove leaky header abstraction and prepare for other encodings.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
5b3ff65d9e hgweb: make type a mandatory parameter to request.respond
There will thus always be headers and the runtime check can be removed.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
87b39b3461 hgweb: use Content-Length for pushres
This prevents some unnecessary http connection close.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
14dc808b35 hgweb: send Content-Length 0 for zero length response
Before, Content-Length wasn't sent for 0 length responses. Now it is.

This could in principle prevent some unnecessary http connection close.
2013-01-15 01:05:12 +01:00
Pierre-Yves David
e4fab34c27 hgweb: document the revnavgen function 2013-01-13 21:36:35 +01:00
Pierre-Yves David
8f71cbe4e1 hgweb: no do not use listinsert(0, ...)
This is not efficient. We now append element and either reverse the list or
iterate in reverse order.
2012-12-19 19:06:50 +01:00
Angel Ezquerra
feab81183f hgweb: add a "URL breadcrumb" to the index and repository pages
The purpose of this change is to make it much easier to navigate up the
repository tree when the hg web server is used to serve more than one
repository.

A "URL breadcrumb" is a path where each of the path items can be clicked to go
to the corresponding path page.

This lets you go up the folder hierarchy very quickly. For example, when showing
the list of repositories in http://myserver/myteams/myprojects, the following
"breadcrumb" will be shown:

Mercurial > myteams > myprojects

Clicking on "myprojects" reloads the page. Clicking on "myteams" goes up one
folder. Clicking on the leftmost "Mercurial" goes to the server root.

This "breadcrumb" also appears on all repository pages. For example on the
summary page of the repository at http://myserver/myteams/myprojects/myrepo the
following will be shown:

Mercurial > myteams > myprojects > myrepo / summary

This change has been applied to all templates that already had a link to the
main repository page (i.e. gitweb, monoblue, paper and coal) plus to the index
page of the spartan template.

In order to make the breadcumb links stand out the some of the template styles
have been customized.
2012-11-28 20:21:26 +01:00
Matt Mackall
fe2cbf4904 merge with stable 2013-01-02 00:24:28 -06:00
Matt Mackall
6f6ef90fe2 hgwebdir: honor web.templates and web.static for static files (issue3734) 2012-12-22 18:11:51 -06:00
Matt Mackall
b867b2de5c hgweb: avoid generator exhaustion with branches 2012-12-06 13:21:27 -06:00