Commit Graph

721 Commits

Author SHA1 Message Date
Alexander Plavin
e2c135afa3 hgweb: add link to force literal keyword search
This makes it possible to make keyword search in case the search query also
specifies an exact revision (like '1234' or 'abcdef'), or a revset expression.
2013-09-06 13:30:56 +04:00
Alexander Plavin
ce8859ee70 hgweb: pass variable with current search mode name to the search template 2013-09-06 13:30:56 +04:00
Alexander Plavin
eee67f7bda hgweb: add nextentry variable for easy pagination in changelog
nextentry always contains the first entry not shown on current page (if there is
such entry)
2013-09-06 13:30:57 +04:00
Alexander Plavin
be32ad07fd hgweb: always compute all entries and latestentry in changelog
Get the whole list of entries before rendering instead of using lazy evaluation.
This doesn't affect the performance for usual case when the entries are shown
anyway. When both entries and latestentry are used, this performs unnoticeably
faster, and for pages which use only latestentry (quite uncommon case) it
would be a bit slower.
This change will make it possible to get the first entry of the next page easily
without computing the list twice.
2013-09-06 13:30:57 +04:00
Alexander Plavin
3f021369d6 hgweb: remove unused argument of changelist function in changelog
This doesn't change the behavior as the argument isn't used anyway, and
it's a preparation to the next patches,
2013-09-06 13:30:57 +04:00
Alexander Plavin
e1392e4ce2 hgweb: add revset syntax support to search
This mode is used when all the conditions are met:
- 'reverse(%s)' % query string can be parsed to a revset tree
- this tree has depth more than two, i.e. the query has some part of
revset syntax used
- the repo can be actually matched against this tree, i.e. it has only existent
function/operators and revisions/tags/bookmarks specified are correct
- no revset regexes are used in the query (strings which start with 're:')
- only functions explicitly marked as safe in revset.py are used in the query

Add several new tests for different parsing conditions and exception handling.
2013-09-06 13:30:56 +04:00
Alexander Plavin
279ad45b7d hgweb: import the whole util module in webcommands instead of just one function
This is to allow using other functions from this module easily.
2013-09-03 20:02:53 +04:00
Alexander Plavin
0aac0cdac8 hgweb: add string constants for search mode names
It helps detecting mistakes in the mode names.
2013-09-04 19:40:04 +04:00
Alexander Plavin
eac9cb37ca hgweb: always run search when a query is entered (bc)
This changes the behavior for queries which point at a revision directly,
now the output is consistent to other cases: it results in only this matched
revision shown, not the log starting with it.
A new test checks this behaviour and fails for the old one.
2013-07-19 02:09:13 +04:00
Alexander Plavin
ea40ee8f63 hgweb: search() function supports direct pointing to revision
This doesn't change the behavior, as queries directly pointing to revisions
are not delegated to the search() function now.
2013-07-19 02:41:11 +04:00
Alexander Plavin
d2cc03584c hgweb: pass arguments which a function depends on explicitly in search
This changes makes clearer which arguments can a function depend on. Now all
the modified functions depend on the 'query' argument only, but future additions
will change it.
2013-08-22 16:42:10 +04:00
Alexander Plavin
44f0fb3b4e hgweb: add dynamic search function selection, depending on the query
This allows adding other specific search functions, in addition to current
keyword search.
2013-08-22 16:45:23 +04:00
Alexander Plavin
1a5c5a0196 hgweb: cleaner if conditions in changelog() function
This removes unneeded extra nesting level and extra variable, which makes
the code easier to understand.
2013-07-19 02:08:19 +04:00
Alexander Plavin
888e02c499 hgweb: separate search itself and template generation
This will make it simpler to add other search modes.
2013-07-15 01:10:22 +04:00
Alexander Plavin
f7a860d1a8 hgweb: replace next(revs) to revs.next() to fix compatibility with Python 2.5- 2013-07-25 15:27:41 +04:00
Alexander Plavin
953f96e356 hgweb: fix duplication for some search queries
Given that N is maximum revision number in a repo, than if a revision with
number N-100n or N-100n+1 (for any integer n) is found with a hgweb search,
this revision is duplicated in search results.
2013-07-21 01:38:04 +04:00
Augie Fackler
c8819014d3 hgweb: force connection close on early response
Not all WSGI servers close the socket when an early response is sent
to a large POST request, which can cause the server to interpret the
already-sent request body as an incoming (but hopelessly invalid)
request.
2013-05-11 20:40:15 -05:00
Alexander Plavin
0b5af3690c hgweb: fix incorrect revisions count in graph (issue3977)
Actual amount of revisions is used now instead of their numbers in the repo
before to deal with skipped numbers correctly.
2013-07-25 02:41:22 +04:00
Alexander Plavin
553f7e5d2b hgweb: fix incorrect way to count revisions in log (issue3977)
Actual amount of revisions is used now instead of their numbers in the repo
before to deal with skipped numbers correctly.
This iterates starting from the newest revision (which is shown on top)
yielding up to the specified count, instead of the reversed order used before.
Effect of this change on efficiency is negligible, when the same changesets are
returned.
2013-07-25 02:22:39 +04:00
Alexander Plavin
f8894d94ab hgweb: always start graph with the revision in url
It is the same fix for graph command, as was recently for log. This makes the
specified revision be always on top of the graph view.
Before the patch, for example with repo having revisions 0, 1, 2, 3 and revision
in url being '2', all revisions were shown and the specified one wasn't
the first.
2013-07-25 02:48:21 +04:00
Alexander Plavin
39b918d7ca hgweb: always start log with searched revision
This makes the specified revision be always on top of the list.
Before the patch, for example with repo having revisions 0, 1, 2, 3 and user
searching for '2', all revisions were shown and the specified one wasn't
the first.
2013-07-13 02:36:29 +04:00
Alexander Plavin
f36cebc920 hgweb: run search instead of showing wrong error for ambigious identifier
Before this when multiple changesets hashes in the repos started with the
search query string, error was given that the revision isn't found, and it
was misleading. Now a simple keyword search runs in this case.
2013-07-12 01:58:48 +04:00
Alexander Plavin
79f178845b hgweb: move local changelist function to the beginning of the parent one 2013-07-15 01:05:42 +04:00
Alexander Plavin
b84ced8343 hgweb: show current search query in the input field 2013-07-11 17:01:54 +04:00
Pierre-Yves David
e23948d63d hgweb: handle filtered "0" rev in navigation
Before this changeset, navigation generation crashed if revision "0" was
filtered. We introduce a `_first` methods on revision navigation that return the
lowest unfiltered element and use it in two place were the "0" changeset was
explicitly referenced.

Test case are introduced.
2013-04-30 13:53:49 +02:00
Pierre-Yves David
f362d20bef hgweb: fix empty navigation detection
For some obscure reason, changelog.node(0) returns nullid if changelog is empty.
this break empty navigation detection. We fix this code by using the length of
the changelog.

Using the length have some issue with revision filtering but this is a small
step in the right direction. Proper fix comes in later changeset.
2013-04-30 15:11:12 +02:00
Wagner Bruna
acdea706bb hgweb: refactor checks for granting and revoking user permissions
Provides an entry point for extensions implementing more complex
authorization schemes.

Original patch proposed by Markus Zapke-Gründemann.
2013-04-15 18:57:04 -03:00
Angel Ezquerra
21863e23e9 hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files 2013-03-21 23:27:37 +01:00
Bryan O'Sullivan
82ca6ed101 merge with mpm 2013-04-02 08:58:42 -07:00
Simon Heimberg
6da920afed hgweb: do not pass on repo.ui when recreating a repo
Recreate the repo with the global configuration in repo.baseui. The repo
configuration is reread anyway. And now deleted repo configuration is reset to
the default value.
2013-03-21 18:16:48 +01:00
Takumi IINO
94c0d6fcb6 hgweb: show correct error message for i18n environment
If exception is error.LookupError and running in i18n environment,
below condition is always true.
Because msg is translated and dosen't contain 'manifest'.

    if util.safehasattr(err, 'name') and 'manifest' not in msg:

This patch creates a new exception class and uses it instead of
string match.
2013-02-15 18:07:14 +09: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
Angel Ezquerra
ec145a5631 hgweb: teach archive how to download a specific directory or file
The archive web command now takes into account the "file" request entry, if one
is provided.

The provided "file" is processed as a "path" corresponding to a directory or
file that will be downloaded.

With this change hgweb can to process requests such as:

    http://mercurial.selenic.com/hg/archive/tip.zip/mercurial/templates

This will download all files on the mercurial/templates directory as a zip file.
It is not possible to specify file patterns ('glob', 'relglob', 'path',
'relpath', 're', 'relre' nor 'set'). The server will reject those with a
403 HTTP error response.

Note that this is a first step to add support for downloading directories from
the web interface. A following patch will modify the archiveentry map entry on
the different templates so that it adds the current folder path to the archive
links.
2013-02-10 11:52:05 +01:00
Dan Villiom Podlaski Christiansen
9e387ff40b hgweb: generate HTML documentation
It's generated from the raw ReST source, as returned from help.help_().
2013-02-09 21:51:21 +00:00
Benoit Boissinot
e6adbab04a merge crew and main 2013-02-11 01:17:50 +01:00
Angel Ezquerra
4651989f9b extensions: obsolete and remove interhg extension
With the addition of the websub filter extension this extension is no longer
needed. We maintain a sort of backwards compatibility by reading the [interhg]
section and using it as we would use the [websub] section.
2013-02-09 11:00:42 +01:00
Angel Ezquerra
ed79324ad4 hgweb: add websub template filter
The purpose of this new filter is to make it possible to partially replace the
functionality of the interhg extension. The idea is to be able to define regular
expression based substitutions on a new "websub" config section. hgweb will then
be able to apply these substitutions wherever the "websub" filter is used on a
template.

This first revision just adds the code necessary to load the websub expressions
and adds the websub filter, but it does not add any calls to the websub filter
itself on any of the templates. That will be done on the following revisions.
2013-02-08 18:05:32 +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
Mads Kiilerich
e4f8deae3f hgweb: simplify internal staticfile return codes 2013-02-10 18:24:29 +01: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