Commit Graph

753 Commits

Author SHA1 Message Date
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
Mads Kiilerich
53a7e81f78 hgweb: handle invalid requests with both form data and querystring
Invalid requests could give an unhandled ErrorResponse.

Now this ErrorResponse is handled like other ErrorResponses so the client gets
an error message which also is logged on the server.
2011-02-21 00:57:19 +01:00
Mads Kiilerich
4a3ec69835 hgweb: give ErrorResponse a descriptive string/Exception representation
Very handy if the exception should appear in output.
2011-02-21 00:52:26 +01:00
Mads Kiilerich
c77a84761e serve: catch and log all Exceptions, not only StandardException
Other exceptions than StandardExceptions were left to the default error handler
which was muted when running in daemon mode.

Now all Exceptions are handled and logged to the log file.
2011-02-21 00:52:23 +01:00
Wagner Bruna
44bdaed8cd hgwebdir: reduce memory usage for index generation
The archive list generator was holding a reference to each
temporary ui copy passed by rawentries(), so the memory
usage for index generation growed proportionally to the
ui object size and the amount of repositories. By returning a
list instead, the temporary reference is dropped immediately.
2011-02-17 18:05:27 -02:00
Mads Kiilerich
75f680564e hgweb: make paths wildcards expanding in a repo root match repo correctly
There was a trailing '/' too much when the wildcard part expanded to nothing.
The consequence was that the repo was announced but didn't work.
2011-02-15 01:04:10 +01:00
Mads Kiilerich
6e8efc0e0c hgweb: doctest of url creation from wildcard expansion 2011-02-15 01:04:10 +01:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Matt Mackall
f6fde7c0c9 merge with stable 2010-12-29 15:31:25 -06:00
Matt Mackall
e6a9c922d9 hgweb: abort if config file isn't found 2010-12-29 15:23:16 -06:00
Oli Thissen
19beab3bf6 hgweb: added revision date to annotate line data
The only revision information yielded by the annotate view was the revision
number itself. The patch allows the use of per-line revision dates in the
corresponding templates.
2010-12-06 16:56:06 +01:00
Wagner Bruna
e391a0d422 hgwebdir: fix incorrect index generation for invalid paths (issue2023)
8aa8db6deb47 moved the subdirectory match inside the repository match
loop. A virtual path existing/path/invalid/path would then match
existing/path, and generate a wrong index page.
2010-11-30 12:45:25 -02:00
Mads Kiilerich
edd19f159b hgweb: let HTTPS serve use more compatible and less secure encryption
PROTOCOL_SSLv3 on the server side doesn't work everywhere. Sometimes the client
reports "EOF occurred in violation of protocol" (for example on Mac and Solaris).

The more compatible PROTOCOL_SSLv23 is now used instead. It works but is less
"secure" for some OpenSSL versions as it can fall back to weak encryption.
2010-10-21 03:18:52 +02:00
Mads Kiilerich
affe4fdcad hgweb: use Pythons ssl module for HTTPS serve when using Python 2.6 or later
pyOpenSSL apparently doesn't work for Python 2.7 and isn't very actively
maintained.

The built-in ssl module seems like a long-term winner, so we now use that with
Python 2.6 and higher.
2010-10-20 20:19:34 +02:00
Mads Kiilerich
1edb529392 hgweb: refactor all pyOpenSSL references into one class 2010-10-20 20:19:32 +02:00
Mads Kiilerich
c627f511ce serve: fix https mode and add test
The https mode failed in super because BaseRequestHandler is an old-style
class.

This introduces the first test of https client/server functionality - and
"hghave ssl". The test is currently only run on Python 2.6.
2010-10-17 04:13:35 +02:00
Augie Fackler
4ec8b25214 hgweb: don't send a body or illegal headers during 304 response
Without this fix, mod_wsgi and spawning get in a wedged state after
sending a 304 response. Not sending a body fixed that problem. The
header change was discovered by using wsgiref.validate.validator to
check for other errors.
2010-10-16 17:29:04 -05:00
Benoit Boissinot
9bd037b429 wireproto/http: drain the incoming bundle in case of errors 2010-10-11 12:47:11 -05:00
Benoit Boissinot
16e11c728a wireproto: introduce pusherr() to deal with "unsynced changes" error
The behaviour between http and ssh still differ:
- the "unsynced changes" is seen as a remote output in the http cases
- but it is correctly seen as a push error for ssh
2010-10-11 12:45:36 -05:00
Matt Mackall
60aea94981 hgweb: another fix for the help termwidth bug 2010-10-10 17:35:28 -05:00
Matt Mackall
d12e3634d3 hgweb: more ui fiddling 2010-10-10 11:05:06 -05:00
Augie Fackler
8969884a91 hgweb: fix hgweb_mod as well as hgwebdir_mod 2010-10-10 10:42:44 -05:00
Augie Fackler
dd4bc6e0c2 hgwebdir_mod: use fake termwidth to avoid mod_wsgi's wrath 2010-10-10 10:07:17 -05:00
Augie Fackler
1978da6b24 web: add a help view for getting hg help output 2010-10-09 12:27:14 -05:00
Matt Mackall
e06b83d527 merge with stable 2010-09-27 10:48:50 -05:00
Ry4an Brase
87ae742f5e Correct Content-Type header values for archive downloads.
The content type for both .tar.gz and .tar.bz2 downloads was
application/x-tar, which is correct for .tar files when no
Content-Encoding is present, but is not correct for .tar.gz and .tar.bz2
files unless Content-Encoding is set to gzip or x-bzip2, respectively.

However, setting Content-Encoding causes browsers to undo that encoding
during download, when a .gz or .bz2 file is usually the desired
artifact.  Omitting the Content-Encoding header is preferred to avoid
having browsers uncompress non-render-able files.

Additionally, the Content-Disposition line indicates a final desired
filename with .tar.gz or .tar.bz2 extension which makes providing a
Content-Encoding header inappropriate.

With the current configuration browsers (Chrome and Firefox thus far)
are registering the application/x-tar Content-Type and not .tar
extension and appending that extension, yielding filename.tar.gz.tar as
a final on-disk artifact.  This was originally reported here:
http://stackoverflow.com/questions/3753659

I've changed the .tar.gz and .tar.bz2 Content-Type values to
application/x-gzip and application/x-bzip2, respectively.  Which yields
correctly named download artifacts on Firefox, Chrome, and IE.
2010-09-20 14:56:08 -05:00
Dirkjan Ochtman
fcd515c23a hgweb: support very simple caching model (issue1845) 2010-09-08 15:23:48 +02:00
Brodie Rao
d1905b7d87 mail/hgweb: support service names for ports (issue2350)
This adds util.getport(port) which tries to parse port as an int, and
failing that, looks it up using socket.getservbyname(). Thus, the
following will work:

    [smtp]
    port = submission

    [web]
    port = http

This does not apply to ports in URLs used in clone, pull, etc.
2010-08-28 12:31:07 -04:00
Brodie Rao
0f9d940cb9 cleanup: remove unused variables 2010-08-27 13:32:40 -04:00
Brodie Rao
203cf2fbd9 cleanup: remove unused imports 2010-08-27 13:32:38 -04:00
Patrick Mezard
aaaf3eb673 webcommands: remove unncessary access to repo.changelog
changectx are good enough in these cases and their interface is more stable.
2010-08-26 23:38:13 +02:00
Matt Mackall
aad5cb0594 merge with stable 2010-08-25 15:20:25 -05:00
Yuya Nishihara
f2b7b3bc23 hgweb: handle exception of misconfigured path on index page
If hgweb.config contains wrong path mapping, hgweb causes internal server
error on repository index page.

This patch changes makeindex() to ignore RepoError, because it looks to be
designed to suppress configuration error.
2010-08-24 23:30:51 +09:00
Matt Mackall
42d9b2046b Merge with stable 2010-07-25 21:20:05 -05:00
Mads Kiilerich
f9812d5b5f hgwebdir: allow pure relative globs in paths
This allows the (to me, in some setups) obvious configuration:
  [paths]
  / = *
or
  / = **

Relative paths used to work with [collections] even though it isn't documented.
Perhaps it should be documented?
2010-07-21 22:22:28 +02:00
Christian Fischer
1863a66dc9 hgwebdir: use template paths configured in the hgrc (issue2281) 2010-07-12 16:07:58 +02:00
Peter Arrenbrecht
6646f48826 wireproto: add getbundle() function
getbundle(common, heads) -> bundle

Returns the changegroup for all ancestors of heads which are not ancestors of common. For both
sets, the heads are included in the set.

Intended to eventually supercede changegroupsubset and changegroup. Uses heads of common region
to exclude unwanted changesets instead of bases of desired region, which is more useful and
easier to implement.

Designed to be extensible with new optional arguments (which will have to be guarded by
corresponding capabilities).
2011-03-23 16:02:11 +01:00
Peter Arrenbrecht
5925b26799 wireproto: fix handling of '*' args for HTTP and SSH 2011-03-22 07:38:32 +01:00
timeless
81c1d7fc8b hgweb: support multiple directories for the same path
[paths]
/dir = /path/1/*, /path/2/*
2011-03-16 03:06:57 +01:00
Matt Mackall
cc6de8544b hgweb: drop use of super() for Exception base class
In Python 2.4, Exception is an old-style class and doesn't work with super.
2011-03-14 15:28:56 -05:00
Martin Geisler
d5f1c9d5be merge with stable 2011-03-13 13:05:16 +01:00
Dirkjan Ochtman
0af26a9d11 don't depend on features of Exception as much
BaseException.message has been deprecated, so we try to not rely on it.
2011-03-12 15:51:39 +01:00
Augie Fackler
01f4abe03c hgweb_mod: respond right away if the client specified 100-continue support
Clients that send 100-continue should make sure they really support
continue intelligently. In a later patch we'll introduce a capability so
new clients don't pay a performance penalty talking to old servers.
2011-01-07 15:19:21 -06:00
Matt Mackall
c761a1dc40 Merge with stable 2010-07-22 08:24:56 -05:00
Dirkjan Ochtman
5772f0c9ef protocol: use generators instead of req.write() for hgweb stream responses 2010-07-20 09:56:37 +02:00
Dirkjan Ochtman
bfec66d497 protocol: wrap non-string protocol responses in classes 2010-07-20 20:53:33 +02:00
Dirkjan Ochtman
d80015833d protocol: extract compression from streaming mechanics 2010-07-16 22:20:10 +02:00
Dirkjan Ochtman
3e08fe969b protocol: rename send methods to get grouping by prefix 2010-07-16 18:18:35 +02:00
Dirkjan Ochtman
4d89fb24c9 protocol: shuffle server methods to group send methods 2010-07-16 18:16:15 +02:00