Commit Graph

191 Commits

Author SHA1 Message Date
Yuya Nishihara
3f981af86b templater: separate function to create templater from map file (API)
New frommapfile() function will make it clear when template aliases will be
loaded. They should be applied to command arguments and templates in hgrc,
but not to map files. Otherwise, our stock styles and web templates
(i.e map-file templates) could be modified unintentionally.

Future patches will add "aliases" argument to __init__(), but not to
frommapfile().
2016-04-03 23:26:48 +09:00
Yuya Nishihara
47690f822c hgweb: use absolute_import 2015-10-31 22:07:40 +09:00
Yuya Nishihara
6f91677786 hgweb: import wsgicgi at top level
There should be no practical reason to delay the import of wsgicgi.
2015-11-01 15:09:35 +09:00
Yuya Nishihara
e142543972 hgweb: do not import hgweb_mod.hgweb and .makebreadcrumb as symbol
It will be enforced by the import checker.
2015-11-01 14:23:23 +09:00
Yuya Nishihara
ad55f13658 hgweb: alias ui module as uimod
It will be enforced by the import checker.
2015-11-01 13:58:32 +09:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Gregory Szorc
962145920a hgweb: add some documentation
It took longer than I wanted to grok how the various parts of hgweb
worked. So I added some class and method documentation to help whoever
hacks on this next.
2015-08-22 13:58:59 -07:00
Gregory Szorc
6e680ddd62 hgweb: make refresh interval configurable
hgwebdir refreshes the set of known repositories periodically. This
is necessary because refreshing on every request could add significant
request latency.

More than once I've found myself wanting to tweak this interval at
Mozilla. I've also wanted the ability to always refresh (often when
writing tests for our replication setup).

This patch makes the refresh interval configurable. Negative values
indicate to always refresh. The default is left unchanged.
2015-08-22 22:59:51 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Pierre-Yves David
2e04e420cc hgewb: disable progress when serving (issue4582)
Before this patch, progress bar could be displayed when serving, creating
hypothetical problems.
2015-06-07 17:14:17 -07:00
Matt Mackall
182254fe57 merge with stable 2015-06-04 17:51:19 -05:00
Matt Harbison
a1a73ad1ab hgwebdir: don't allow the hidden parent of a subrepo to show as a directory
Previously, if a subrepo parent had 'web.hidden=True' set, neither the parent
nor child had a repository entry.  However, the directory entry for the parent
would be listed (it wouldn't have the fancy 'web.name' if configured), and that
link went to the repo's summary page, effectively making it not hidden.

This simply disables the directory processing if a valid repository is present.
Whether or not the subrepo should be hidden is debatable, but this leaves that
behavior unchanged (i.e. it stays hidden).
2015-06-01 18:06:20 -04:00
Matt Harbison
7ed6e6b3e0 hgwebdir: avoid redundant repo and directory entries when 'web.name' is set
Previously, when 'web.name' was set on a subrepo parent and 'web.collapse=True',
the parent repo would show in the list with the configured 'web.name', and a
directory with the parent repo's filesystem name (with a trailing slash) would
also appear.  The subrepo(s) would unexpectedly be excluded from the list of
repositories.  Clicking the directory entry would go right to the repo page.

Now both the parent and the subrepos show up, without the additional directory
entry.

The configured hgweb paths used '**' for finding the repos in this scenario.


A couple of notes about the tests:

- The area where the subrepo was added has a comment that it tests subrepos,
  though none previously existed there.  One now does.

- The 'web.descend' option is required for collapse to work.  I'm not sure what
  the previous expectations were for the test.  Nothing changed with it set,
  prior to adding the code in this patch.  It is however required for this test.

- The only output changes are for the hyperlinks, obviously because of the
  'web.name' parameter.

- Without this code change, there would be an additional diff:

    --- /usr/local/mercurial/tests/test-hgwebdir.t
    +++ /usr/local/mercurial/tests/test-hgwebdir.t.err
    @@ -951,7 +951,7 @@
       /rcoll/notrepo/e/
       /rcoll/notrepo/e/e2/
       /rcoll/notrepo/f/
    -  /rcoll/notrepo/f/f2/
    +  /rcoll/notrepo/f/


     Test repositories inside intermediate directories

I'm not sure why the fancy name doesn't come out, but it is enough to
demonstrate that the parent is not listed redundantly, and the subrepo isn't
skipped.
2015-06-01 14:42:55 -04:00
Matt Mackall
a5b83eed23 merge with stable 2015-06-02 13:24:39 -05:00
Matt Mackall
25a97bf622 hgweb: use try/except/finally 2015-05-15 09:56:27 -05:00
Mads Kiilerich
374f35aab5 templater: introduce templatepaths for getting paths searched for templates
Avoid function with different return types depending on parameters.
2014-09-28 16:57:37 +02:00
Matt Mackall
7a68007f38 hgweb: avoid config object race with hgwebdir (issue4326)
Turns out hgwebdir passes full repo objects to each hgweb request
instance, but with a shared baseui. We explicitly break the sharing.
2014-08-10 13:53:36 -05:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Augie Fackler
66b125778a hgwebdir_mod: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:15:37 -04:00
Paul Boddie
202d2d5cf4 hgweb: ensure isdirectory is None for repositories, replacing any True value
Until now, repositories did not provide any value for isdirectory in rows
produced for the index output, and thus isdirectory was generally evaluated as
None for each index entry representing a repository.

However, directories (visible when viewed with the descend and collapse
settings enabled) did provide a value of True and this value appeared to
persist in subsequent rows processed by the templater, causing isdirectory
tests in templates to produce incorrect results for index entries appearing
after directories.

This patch asserts the None value for repositories, thus erasing any such
persistent True values.
2014-02-27 00:24:06 +01:00
Takumi IINO
db72b3b5e8 hgweb: avoid invalid infinity scroll request when overwritten web.style
Infinity scroll is broken when you override the web.style in the following ways:

    $ hg --config='web.style=gitweb' serve
    $ open http://localhost:8080/shortlog?style=paper

ajaxScrollInit should use http://localhost:8080/shortlog/%next%?style=paper.
however, http://localhost:8080/shortlog/%next% is used actually.
It is missing style parameter.

This patch add style parameter to request url.
2014-01-08 00:35:03 +09:00
Alexander Plavin
24f9b953ea hgweb: remove now unnecessary explicit header() and footer()
They became unnecessary after allowing custom-named entries in templates.
2013-07-24 03:20:26 +04: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
Mads Kiilerich
e4f8deae3f hgweb: simplify internal staticfile return codes 2013-02-10 18:24:29 +01: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
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
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
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
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
Matt Mackall
764c110123 hgweb: use ui.nontty to disable all cooked I/O 2012-05-20 14:37:22 -05: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
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
wujek
05cf460c3e hgweb: handle 'baseurl' configurations with leading slash (issue2934) 2011-08-01 09:48:10 +02: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
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
Adrian Buehlmann
267c80394b move walkrepos from util to scmutil 2011-04-21 16:06:19 +02: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
Brodie Rao
744f9e0914 hgweb: use url.url when setting CGI environment variables 2011-03-30 20:01:46 -07: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
timeless
81c1d7fc8b hgweb: support multiple directories for the same path
[paths]
/dir = /path/1/*, /path/2/*
2011-03-16 03:06:57 +01:00
Patrick Mezard
3974219479 test-doctest: handle unix/windows path discrepancies 2011-03-06 14:17:47 +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
Matt Mackall
e6a9c922d9 hgweb: abort if config file isn't found 2010-12-29 15:23:16 -06: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