Commit Graph

801 Commits

Author SHA1 Message Date
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
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
Matt Mackall
a671a1cc84 hgweb: fix iterator reuse in atom feed generation 2012-12-05 15:38:18 -06:00
Angel Ezquerra
d3a4755c75 hgwebdir: do not show RSS and Atom links for plain directories
Up until now the templates that show RSS and Atom feeds on the "repository
lists" (i.e. gitweb and monoblue) showed them for all entries, including regular
folders. Clicking on those "folder RSS" links would result in an error page
being shown.

This patch hides those links for regular folders.
2012-11-27 22:24:02 +01:00
Matt Mackall
af1b0b230f merge with stable 2012-12-06 16:42:15 -06:00
Weiwen
64b5450a1f hgweb: display diff for a changeset against any parents (issue2810)
During merge of branches, it is useful to compare merge results against
the two parents.  This change adds this support to hgweb.  To specify
which parent to compare to, use rev/12300:12345 where 12300 is a
parent changeset number.  Two links are added to changeset web page so
that one can choose which parent to compare to.
2012-11-12 14:05:39 -08:00
Jordi Gutiérrez Hermoso
c9424a0caa webcommands: allow hgweb's archive to recurse into subrepos
Currently when obtaining an archive snapshot of a repository via the
web interface, subrepositories are not taken in the snapshot. I
introduce an option, archivesubrepos, which allows this.
2012-10-29 10:53:46 -04:00
Angel Ezquerra
8a78ba05e3 hgwebdir: make collapsed folders easier to distinguish from repositories
Add a "/" character after the collapsed folder names, to make them easier to
distinguish from regular repository and subrepository entries.
2012-07-26 21:29:39 +02:00
Yuya Nishihara
ee6b575238 hgweb: respond 403 forbidden for ssl required error
It's preferable to report "ssl required" as an error, so that the client
can detect error and exit with 255. Currently hg exits with 1, which is
"nothing to push."
2012-09-05 23:59:27 +09:00
Mads Kiilerich
e973af65d0 improve some comments and docstrings, fixing issues found when spell checking 2012-08-21 02:41:20 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Mads Kiilerich
4d30442bbe help: use the first topic name from helptable, not the longest alias
This makes the 'additional help topics' list consistent with the output from
keyword search (for instance subrepo/subrepos).

The sorting by longest name was introduced in 4cbe49492ad3. There might have
been a good reason for it back then, but now it seems like a better idea to
place the preferred name first in the list in helptable.
2012-08-01 14:59:15 +02:00
Patrick Mezard
5ddea72e60 hgweb: fix graph view paging
- Fix off-by-one error on displayed entries count in normal mode
- Fix incorrect paging when the top revision was lower than revcount
- Fix revcount not overriding web.maxshortchanges everywhere
2012-07-29 23:16:20 +02:00
wujek srujek
5f5df03779 hgweb: fixes invalid parents / children in comparison
Previously, the parents / children were computed relative to the cset of the
currently shown file, which was wrong and inconsistent with diff and others.
With this patch, the listed csets are those that contain changes to the
currently compared file, which don't necessarily have to be the direct parents
and children of the changeset itself.
2012-07-31 00:59:38 +02:00
wujek srujek
7bcb15a47e hgweb: fixes traceback for invalid files by removing top-level template
The top-level 'comparison' template was not really needed, and it also caused a
traceback to be shown for inexistent files (as reported by Ross Lagerwall).
Getting rid of it makes the overall templating structure simpler and causes
invalid files to be handled nicely.
2012-07-31 14:14:15 +02:00
Ross Lagerwall
efa6c8abd3 hgweb: avoid traceback when file or node parameters are missing
Previously, browsing to http://serv/diff would generate an internal
server error due to the file and node parameters being missing.
The same error also occurred for filelog, comparison and annotate.
2012-07-30 11:02:10 +02:00
Patrick Mezard
00c80f6fa8 webcommands: do not modify repo.tagslist()
Repeatedly refreshing a gitweb summary page served by hg serve would
show the tags list switching between two different sequences.
2012-07-27 17:48:49 +02:00
wujek srujek
a8963fc179 hgweb: side-by-side comparison functionality
Adds new web command to the core, ``comparison``, which enables colorful
side-by-side change display, which for some might be much easier to work with
than the standard line diff output. The idea how to implement comes from the
SonicHq extension.
The web interface gets a new link to call the comparison functionality. It lets
users configure the amount of context lines around change blocks, or to show
full files - check help (also in this changeset) for details and defaults. The
setting in hgrc can be overridden by adding ``context=<value>`` to the request
query string. The comparison creates addressable lines, so as to enable sharing
links to specific lines, just as standard diff does.
Incorporates updates to all web related styles.

Known limitations:
* the column diff is done against the first parent, just as the standard diff
* this change allows examining diffs for single files only (as I am not sure if
  examining the whole changeset in this way would be helpful)
* syntax highlighting of the output changes is not performed (enabling the
  highlight extension has no influence on it)
2012-07-08 17:17:02 +02:00
Adrian Buehlmann
dad9940448 hgweb: show help with verbose sections included
This makes sure we see the same help info as with 'hg help <command> --verbose'
on the command line, that is, with verbose sections included.
2012-07-10 17:52:43 +02:00
Mads Kiilerich
ff855a00ed help: improve hgweb help
The existing help only walked through an example.

Now we first explain the basic rules and then show an example.

The 'collections' example and description only cause confusion and is removed.

Bikeshedded by Patrick Mezard <patrick@mezard.eu>
2012-06-21 12:50:15 +02:00
Paul Boddie
5b2a1dc5f5 hgweb: make graph data suitable for template usage
Previously, graph data has been encoded for processing done by
JavaScript code run in the browser, employing simple structures
with implicit member positions. This patch modifies the graph
command to also produce data employing a dictionary-based
structure suitable for use with the templating mechanism, thus
permitting other ways of presenting repository graphs using that
mechanism.

In order to test these changes, the raw theme has been modified
to include templates for graph nodes and edges. In a similar
fashion, themes could employ technologies such as SVG that lend
themselves to templating to produce the graph display. This patch
makes use of a much simpler output representation than SVG in
order to maintain clarity.
2012-05-21 00:20:05 +02:00
Matt Mackall
764c110123 hgweb: use ui.nontty to disable all cooked I/O 2012-05-20 14:37:22 -05:00
Matt Mackall
264c1fb976 merge with stable 2012-05-15 07:00:55 +02:00
Matt Mackall
dbfb64e582 hgweb: fix filediff base calculation
Previously, we were finding the most recent version of a file in a
changeset and comparing it against its first file parent. This was
wrong on three counts:

- it would show a diff in revisions where there was no change to a file
- it would show a diff when only the exec bit changed
- it would potentially compare against a much older changeset, which
  could be very expensive if git-style rename detection was enabled

This compares the file in the current context with that context's
parent, which may result in an empty diff when looking at a file not
touched by the current changeset.
2012-05-14 12:56:43 +02:00
Brodie Rao
ab32f1721d context: add changectx.closesbranch() method
This removes the duplicated code for inspecting the 'close' extra field in
a changeset.
2012-05-13 14:04:06 +02:00
Brodie Rao
d36ae7f264 localrepo: add branchtip() method for faster single-branch lookups
For the PyPy repo with 744 branches and 843 branch heads, this brings
hg log -r default over NFS from:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
        3249            0      1.3222      1.3222   <open>
        3244            0      0.6211      0.6211   <method 'close' of 'file' objects>
        3243            0      0.0800      0.0800   <method 'read' of 'file' objects>
        3241            0      0.0660      0.0660   <method 'seek' of 'file' objects>
        3905            0      0.0476      0.0476   <zlib.decompress>
        3281            0      2.6756      0.0472   mercurial.changelog:182(read)
       +3281            0      2.5256      0.0453   +mercurial.revlog:881(revision)
       +3276            0      0.0389      0.0196   +mercurial.changelog:28(decodeextra)
       +6562            0      0.0123      0.0123   +<method 'split' of 'str' objects>
       +6562            0      0.0408      0.0073   +mercurial.encoding:61(tolocal)
       +3281            0      0.0054      0.0054   +<method 'index' of 'str' objects>
        3241            0      2.2464      0.0456   mercurial.revlog:818(_loadchunk)
       +3241            0      0.6205      0.6205   +<method 'close' of 'file' objects>
       +3241            0      0.0765      0.0765   +<method 'read' of 'file' objects>
       +3241            0      0.0660      0.0660   +<method 'seek' of 'file' objects>
       +3241            0      1.4209      0.0135   +mercurial.store:374(__call__)
       +3241            0      0.0122      0.0107   +mercurial.revlog:810(_addchunk)
        3281            0      2.5256      0.0453   mercurial.revlog:881(revision)
       +3280            0      0.0175      0.0175   +mercurial.revlog:305(rev)
       +3281            0      2.2819      0.0119   +mercurial.revlog:847(_chunkraw)
       +3281            0      0.0603      0.0083   +mercurial.revlog:945(_checkhash)
       +3281            0      0.0051      0.0051   +mercurial.revlog:349(flags)
       +3281            0      0.0040      0.0040   +<mercurial.mpatch.patches>
       13682            0      0.0479      0.0248   <method 'decode' of 'str' objects>
       +7418            0      0.0228      0.0076   +encodings.utf_8:15(decode)
          +1            0      0.0003      0.0000   +encodings:71(search_function)
        3248            0      1.3995      0.0246   mercurial.scmutil:218(__call__)
       +3248            0      1.3222      1.3222   +<open>
       +3248            0      0.0235      0.0184   +os.path:80(split)
       +3248            0      0.0084      0.0068   +mercurial.scmutil:92(__call__)
Time: real 2.750 secs (user 0.680+0.000 sys 0.360+0.000)

down to:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
          55           31      0.0197      0.0163   <__import__>
          +1            0      0.0006      0.0002   +mercurial.context:8(<module>)
          +1            0      0.0042      0.0001   +mercurial.revlog:12(<module>)
          +1            0      0.0002      0.0001   +mercurial.match:8(<module>)
          +1            0      0.0003      0.0001   +mercurial.dirstate:7(<module>)
          +1            0      0.0057      0.0001   +mercurial.changelog:8(<module>)
           1            0      0.0117      0.0032   mercurial.localrepo:525(_readbranchcache)
        +844            0      0.0015      0.0015   +<binascii.unhexlify>
        +845            0      0.0010      0.0010   +<method 'split' of 'str' objects>
        +843            0      0.0045      0.0009   +mercurial.encoding:61(tolocal)
        +843            0      0.0004      0.0004   +<method 'setdefault' of 'dict' objects>
          +1            0      0.0003      0.0003   +<method 'close' of 'file' objects>
           3            0      0.0029      0.0029   <method 'read' of 'file' objects>
           9            0      0.0018      0.0018   <open>
         990            0      0.0017      0.0017   <binascii.unhexlify>
          53            0      0.0016      0.0016   mercurial.demandimport:43(__init__)
         862            0      0.0015      0.0015   <_codecs.utf_8_decode>
         862            0      0.0037      0.0014   <method 'decode' of 'str' objects>
        +862            0      0.0023      0.0008   +encodings.utf_8:15(decode)
         981            0      0.0011      0.0011   <method 'split' of 'str' objects>
         861            0      0.0046      0.0009   mercurial.encoding:61(tolocal)
        +861            0      0.0037      0.0014   +<method 'decode' of 'str' objects>
         862            0      0.0023      0.0008   encodings.utf_8:15(decode)
        +862            0      0.0015      0.0015   +<_codecs.utf_8_decode>
           4            0      0.0008      0.0008   <method 'close' of 'file' objects>
         179          154      0.0202      0.0004   mercurial.demandimport:83(__getattribute__)
         +36           11      0.0199      0.0003   +mercurial.demandimport:55(_load)
         +72            0      0.0001      0.0001   +mercurial.demandimport:83(__getattribute__)
         +36            0      0.0000      0.0000   +<getattr>
           1            0      0.0015      0.0004   mercurial.tags:148(_readtagcache)
Time: real 0.060 secs (user 0.030+0.000 sys 0.010+0.000)
2012-05-13 14:04:04 +02:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
FUJIWARA Katsunori
c7ab63f3a6 i18n: show localized messages for commands/extensions in hgweb help top (issue3383)
in hgweb help top page, help topics are localized, but abstracts of
commands and extensions are not, although these are already
translated.

it is because localized messages for them should be explicitly looked
up by original ones.

this patch looks localized messages up for each commands/extensions.
2012-04-19 20:54:56 +09:00
Martin Geisler
b08f38425c hgweb: add hook for remapping repository path into virtual paths
Extensions such as largefiles can use this to remap files so they
appear in the same location as they do in the user's working copy.
2012-04-15 16:05:53 +02:00
Paul Boddie
0e0c036052 hgweb: add block numbers to diff regions and related links
The changeset view may show several diff regions, one per file, and this patch
numbers each of them so that links produced by the filenodelink fragment can
reference each diff region produced by the diffblock fragment through the use
of the blockno variable made available to both of them. This permits
navigation to diff regions on the changeset page from the file list, and
where the :target pseudo-class is supported in browsers, permits selective
presentation of diffs, showing one at a time instead of potentially many in
what would otherwise be a very long page that is difficult to navigate.
2012-03-23 01:31:31 +01:00
Paul Boddie
7bbd727829 hgweb: support multi-level repository indexes by enabling descend and collapse
The descend option in hgweb can be used to display all reachable repositories
within a directory hierarchy if set to True. However, all reachable
repositories, regardless of their depth below the root of the hierarchy, are
then listed at the same level - expanded - in the hgweb interface. This patch
adds support for showing only each level of a directory hierarchy, with
subrepositories being shown alongside their parent repositories only at the
appropriate level (because there is no way to navigate to subrepositories from
within repositories), and the contents of directories hidden - collapsed -
behind a link for each directory. To enable this multi-level navigation, a new
option called collapse must be set to True when the descend option is set to
True.
2012-02-18 20:10:19 +01:00
Constantine Linnick
c28ce344f6 graph: in hgrc specify line width for main branch
You can specify width to visually distinguish main branch (trunk)
on hgweb's graph page. Settings format is branch_name.width = value,
where width in px e.g.:
[graph]
default.width = 3
2012-01-22 19:35:26 +07:00
FUJIWARA Katsunori
20f2cd3a0c i18n: use "encoding.lower()" to normalize string in hgweb search query
some problematic encoding (e.g.: cp932) uses ASCII alphabet characters
in byte sequence of multi byte characters.

"str.lower()" on such byte sequence may treat distinct characters as
same one, and cause unexpected log matching.

this patch uses "encoding.lower()" instead of "str.lower()" to
normalize strings for compare.
2011-12-25 20:35:16 +09:00
Patrick Mezard
cc3315778f annotate: support diff whitespace filtering flags (issue3030)
splitblock() was added to handle blocks returned by bdiff.blocks() which differ
only by blank lines but are not made only of blank lines. I do not know exactly
how it could happen but mdiff.blocks() threshold behaviour makes me think it
can if those blocks are made of very popular lines mixed with popular blank
lines. If it is proven to be wrong, the function can be dropped.

The first implementation made annotate share diff configuration entries. But it
looks like users will user -w/b for annotate but not for diff, on both the
command line and hgweb. Since the latter cannot use command line entries, we
introduce a new [annotate] section duplicating the diff whitespace options.
2011-11-18 12:04:31 +01:00
Matt Mackall
944b7f7b5c pyflakes: clean up some import noise 2011-10-11 23:16:05 -05:00
Andrew Pritchard
2d8acb3e0b wireproto: add out-of-band error class to allow remote repo to report errors
Older clients will still print the provided error message and not much else:
over ssh, this will be each line prefixed with 'remote: ' in addition to an
"abort: unexpected response: '\n'"; over http, this will be the '---%<---'
banners in addition to the 'does not appear to be a repository' message.

Currently, clients with this patch will display 'abort: remote error:\n' and
the provided error text, but it is trivial to style the error text however is
deemed appropriate.
2011-08-02 15:21:10 -04:00
Matt Mackall
bd0261e46e merge with stable 2011-08-01 18:10:05 -05:00
Matt Mackall
b170d63e2a hgweb: extract the path logic from updatereqenv and add doctests 2011-08-01 14:53:10 -05:00
Matt Mackall
eb714d4d00 merge with stable 2011-08-01 14:52:11 -05:00
Matt Mackall
e75325116a merge with stable 2011-08-01 10:54:34 -05:00
wujek
05cf460c3e hgweb: handle 'baseurl' configurations with leading slash (issue2934) 2011-08-01 09:48:10 +02:00
Matt Mackall
9dd4882287 hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Before: hgweb made it possible to download file content with a content type
detected from the file extension. It would serve .html files as text/html and
could thus cause XSS vulnerabilities if the web site had any kind of session
authorization and the repository content wasn't fully trusted.

Now: all files default to "application/binary", which all important
browsers will refuse to treat as text/html. See the table here:

https://code.google.com/p/browsersec/wiki/Part2#Survey_of_content_sniffing_behaviors
2011-07-31 01:46:52 +02:00
Augie Fackler
8e5c4fa38c http2: send an extra header to signal a non-broken client
Some proxies strip the expect header because they forward requests in
a non-compliant way or as a way to defend against bogus clients.
2011-07-27 18:35:35 -05:00
Jesse Long
33d5742949 hgweb: treat branch attribute closed' as more important than inactive'
In the branches page, branches that are closed and are merged into another
branch are displayed as `inactive'. This patch changes that behaviour to
show these branches as `closed'.

For me, the `closed' attribute is more important than the `inactive'
attribute.

Branches that are not closed, and are merged into other branches will still
be shown as `inactive'.

Branches that are closed, and are not merged into other branches will still
be shown as `closed'.
2011-06-29 09:36:45 +02:00
Thomas Arendsen Hein
692a53d202 classes: fix class style problems found by 06e968819ac9
This makes test-wireprotocol.py work on Python 2.4
2011-06-29 15:00:00 +02:00
Idan Kamara
325f77da0a ui: use I/O descriptors internally
and as a result:
- fix webproto to redirect the ui descriptors instead of sys.stdout/err
- fix sshserver to use the ui descriptors
2011-06-08 01:39:20 +03:00
Steven Brown
d6246b1341 web: provide diff summary to the changeset page
This is the same message displayed at the end of the "diff --stat" command.
For example, "9 files changed, 1651 insertions(+), 2 deletions(-)".

The webutil.diffstatgen function allows the diffstat data to be lazily
calculated only once and then re-used.
2011-06-11 21:11:43 +08:00
Steven Brown
d042b9d9a8 web: provide the file number to the diffstat templates
This allows the diffstat templates to link into the diff output. For example,
the URLs of the first three files within the diff are #l1.1, #l2.1, #l3.1.
2011-06-09 01:15:49 +08:00
Steven Brown
b9c161f1f5 web: include all files in the diffstat
The webutil.diffstat function now returns a diffstat template for each file
in the diff. It previously returned a template for each file returned by
ctx.files() which did not work well for merge changesets.
2011-06-09 01:14:22 +08:00
Steven Brown
ef568e7358 web: prevent TypeError thrown when using the diffstat templates
Remove the lambda used to wrap webutil.diffstat because:
- functions passed to the templater must accept keyword arguments
- webutil.diffstat is a generator, so already calculates the diffstat lazily

This reverts the changes made to a4067e29e29d after it was submitted to the
mailing list but before it was queued.
2011-06-02 18:52:31 +08:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Steven Brown
a8c12e93a7 web: provide diffstat to the changeset page
This includes all affected files, so it can be used for an extended view of
the files or as a replacement for the filenodelink and filenolink templates.
2011-05-28 14:44:45 +08:00
Augie Fackler
5997cc6e9c hgweb: move remaining hasattr calls to safehasattr 2011-07-25 15:38:46 -05:00
Augie Fackler
1e620f0aad wsgicgi: use getattr instead of hasattr 2011-07-25 15:38:10 -05:00
Augie Fackler
caa4218c37 hgweb_mod: use safehasattr instead of hasattr 2011-07-25 16:27:08 -05:00
Augie Fackler
2e41c2e64a globally: use safehasattr(x, '__iter__') instead of hasattr(x, '__iter__') 2011-07-25 15:30:19 -05:00
Angel Ezquerra
9f2d3a19a5 hgweb: add a "web/logoimg" setting to customize the web logo image
This change complements the existing web/logourl setting, and lets the user
customize the logo image that is shown on many of the hg server pages.

If this setting is not set, hglogo.png is used.
2011-07-21 15:10:16 +02:00
Adrian Buehlmann
0e6715fa28 rename util.set_binary to setbinary 2011-05-06 15:25:35 +02:00
Matt Mackall
89ec131e91 http: minor tweaks to long arg handling
x-arg -> x-hgarg
replace itertools.count(1)
2011-05-01 03:51:04 -05:00
Steven Brown
c1075f3880 httprepo: long arguments support (issue2126)
Send the command arguments in the HTTP headers. The command is still part
of the URL. If the server does not have the 'httpheader' capability, the
client will send the command arguments in the URL as it did previously.

Web servers typically allow more data to be placed within the headers than
in the URL, so this approach will:
- Avoid HTTP errors due to using a URL that is too large.
- Allow Mercurial to implement a more efficient wire protocol.

An alternate approach is to send the arguments as part of the request body.
This approach has been rejected because it requires the use of POST
requests, so it would break any existing configuration that relies on the
request type for authentication or caching.

Extensibility:
- The header size is provided by the server, which makes it possible to
  introduce an hgrc setting for it.
- The client ignores the capability value after the first comma, which
  allows more information to be included in the future.
2011-05-01 01:04:37 +08:00
Brodie Rao
b7f0d2a103 url: move URL parsing functions into util to improve startup time
The introduction of the new URL parsing code has created a startup
time regression. This is mainly due to the use of url.hasscheme() in
the ui class. It ends up importing many libraries that the url module
requires.

This fix helps marginally, but if we can get rid of the urllib import
in the URL parser all together, startup time will go back to normal.

perfstartup time before the URL refactoring (707e4b1e8064):

! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

current startup time (9ad1dce9e7f4):

! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

after this change:

! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
2011-04-30 09:43:20 -07:00
Martin Geisler
a5dc911698 merge with mpm 2011-04-30 15:30:51 +02:00
Martin Geisler
e57b3a9f70 hgweb: initialize permhooks at definition time
This is simpler than creating it empty and then appending the default
checkauthz hook 50 lines below.
2011-04-30 13:47:22 +02:00
Alexander Solovyov
23228e2ea0 drop {short,hex}(ctx.node()) calls in favor of ctx methods 2011-04-30 12:55:07 +02:00
Alexander Solovyov
f4250e8e9c graphlog: make use of graphmod's revset support 2011-04-23 15:04:15 +02:00
Adrian Buehlmann
267c80394b move walkrepos from util to scmutil 2011-04-21 16:06:19 +02:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Steven Stallion
6daa9da6c9 hgweb: support disabling page cache
By default, hgweb_mod supports caching via the ETag header. This can
cause some confusion with browsers which cache aggressively. This change
preserves existing behavior while giving the administrator a knob to
disable the ETag header.
2011-04-20 00:01:50 -04:00
Steven Stallion
239482dbab hgweb: support alternate logo url
Clicking on the logo image/text in the hgweb interface brings the
user to the Mercurial project page. The majority of users expect that
this would bring them to the top level index. I have added a new template
variable named `logourl' which allows an administrator to change this
behavior. To stay compatible with existing behavior, `logourl' will
default to http://mercurial.selenic.com/. This change is very useful in
large installations where jumping to the index is common.
2011-04-19 23:37:06 -04:00
Martin Geisler
5a3f4fec03 merge with stable 2011-04-19 15:19:54 +02:00
Martin Geisler
6cd55d2029 hgweb: detect change based on changelog size too
Before, there was a race between an access and a modification made
within the same second.
2011-04-19 15:15:56 +02:00
Md. O. Shayan
20e62c51a1 hgweb: set minimum number of revision to display to 1 when revcount is 0
When revcount goes to 0 nothing is displayed in hgweb. This patch sets revcount to max(revcount, 1).
2011-04-13 07:40:24 +05:30
Yuya Nishihara
109c433261 hgweb: add bookmarks listing to summary page of gitweb/monoblue styles 2011-04-10 10:01:42 +09:00
Yuya Nishihara
fe54e1ef28 hgweb: remove useless notip handling from bookmarks listing 2011-04-10 10:01:39 +09:00
Yuya Nishihara
723e882e64 hgweb: sort bookmarks in the same manner as console command 2011-04-10 10:01:37 +09:00
Md. O. Shayan
43492ff710 hgweb: fix inconsistant display of graphlog (issue1706) 2011-04-07 13:23:07 +05:30
Yuya Nishihara
95ce899cb1 hgweb: add bookmark labels to monoblue theme (based on 4d7cfa1867b5) 2011-03-30 02:22:15 +09:00
Martin Geisler
be192b7fa4 merge with stable 2011-04-07 11:40:54 +02:00
Brodie Rao
744f9e0914 hgweb: use url.url when setting CGI environment variables 2011-03-30 20:01:46 -07:00
Matt Mackall
1d9a1adcf9 merge with stable 2011-03-30 13:23:24 -05:00
timeless@gmail.com
a09c2a5533 hgwebdir: handle IOErrors from localrepo while enumerating
Repository() raises a number of IOErrors in addition to RepoErrors.
 these are just as uninteresting as RepoErrors and should be ignored

The easiest case of this is a repo whose .hg/ directory is -rx
2011-03-29 16:33:10 +00:00
Dirkjan Ochtman
43eea49bf4 hgweb: pmezard thinks one default is enough 2011-03-12 16:00:54 +01:00
Dirkjan Ochtman
d17590d4e7 deal with empty Content-Length headers 2011-03-12 15:21:45 +01:00
Alexander Solovyov
84912d6eaf hgweb: add separate page with bookmarks listing 2011-03-12 11:20:03 +01:00
Alexander Solovyov
e67bfa95ac hgweb: add display of bookmarks for changelog and changeset 2011-03-12 11:19:44 +01:00