Commit Graph

58 Commits

Author SHA1 Message Date
Denis Laxalde
831d4dcf5b hgweb: plug followlines action in annotate view
Add the followlines.js script and corresponding parameters as data attribute
on <tbody class="sourcelines"> element.
Extend CSS rules so that they also match the DOM structure of annotate view.

As previously, only address paper and gitweb styles (other styles do not have
followlines at all).
2017-06-21 17:17:17 +02:00
Gregory Szorc
09c5531c2e hgweb: use separate CSS class for navigation links in footer
c0593b622180 changed the styling of the "page_nav" CSS class to use
flexbox to separate elements within the <div>. I didn't realize that
this class was used outside of the links in the header. So this
resulted in incorrectly formatting links in the footer of various
pages. Fix that by introducing a new CSS class that preserves the
old CSS behavior.
2017-06-20 20:53:29 -07:00
Gregory Szorc
fa21f12af8 hgweb: refresh styling of gitweb's search form
gitweb was missing the hint hover box. So that was added.

Also, the positioning of the form was absolute and it didn't
vertically align on all pages. The element has been moved inline
with the navigation links (which now are contained in a div) and
flexbox is used to obtain sane alignment of the navigation links
and search form. For those new to flexbox,
"justify-content: space-between" basically says to maximize space
elements. You can use it to easily get left and right justified
containers without having to worry about width, floating, etc.
"align-items: center" centers all items in a cross-axis. I've
literally wasted hours trying to figure out both these problems
before flexbox. Flexbox is amazing.

Flexbox has been supported by Chrome and Firefox for a few years.
But it is only supported by IE 11. I'm willing to wager that
people using this either won't be using IE or will be using IE 11.
So I'm willing to be a bit aggressive in adopting flexbox because
it makes CSS alignment so much easier.
2017-06-09 13:55:51 -07:00
Gregory Szorc
3816d83a29 hgweb: consolidate search form for paper
AFAICT this was mostly a bunch of copy pasta. The only variation is
some pages defined a "value" attribute. The "query" variable will
just be empty on pages that don't accept it. So let's consolidate
the template and remove the redundancy.
2017-06-09 13:59:13 -07:00
Denis Laxalde
160d0b298e gitweb: plug followlines UI in filerevision view
Mostly copy CSS rules from style-paper.css into style-gitweb.css. The only
modification is addition of !important on "background-color" rule for
"pre.sourcelines > span.followlines-selected" selector as the background color
is otherwise overriden by "pre.sourcelines.stripes > :nth-child(4n+4)" rule.
2017-04-13 09:49:48 +02:00
Gregory Szorc
ee826b7708 gitweb: use monospace font for commit messages
Commit messages often contain vertically aligned text. The default
paper style already uses monospace fonts for rendering commit messages.
And, AFAICT, a number of Git servers also render commit messages
with monospace. It seems like the reasonable thing to do.

This commit converts all instances of the full commit message
in the gitweb style to render with monospace.
2017-03-24 19:52:43 -07:00
Gregory Szorc
49f189afa0 hgweb: call process_dates() via DOM event listener
All the hgweb templates include mercurial.js in their header. All
the hgweb templates have the same <script> boilerplate to run
process_dates(). This patch factors that function call into
mercurial.js as part of a DOMContentLoaded event listener.
2017-01-10 20:47:48 -08:00
Tooru Fujisawa
2c9ec77e6d hgweb: avoid line wrap between revision and annotate-info (issue5398)
Add white-space: nowrap to td.annotate to avoid wrapping div.annotate-info
into next line if there is revision number in the same cell, as it is hard to
mouse over div.annotate-info if it's wrapped into next line.
2016-10-08 19:32:54 +09:00
Anton Shestakov
fbb5b06e2e gitweb: make annotate popup use theme colors 2016-07-25 12:33:18 +08:00
Anton Shestakov
5c14c79488 gitweb: make different blocks of annotated lines have different colors 2016-07-16 15:00:36 +08:00
Denis Laxalde
07a35f6357 hgweb: add link to parents of annotated revision in annotate view
The link is embedded into a div with class="annotate-info" that only shows up
upon hover of the annotate column. To avoid duplicate hover-overs (this new
one and the one coming from link's title), drop "title" attribute from a
element and put it in the annotate-info element.
2016-06-28 11:42:42 +02:00
Denis Laxalde
c4ddd5ce73 hgweb: highlight data of the current revision in annotate view
* Distinguish the /annotate/<revision>/<file>#<linenumber> link when it would
  lead to the current page (i.e. <revision> is the current revision) (style it
  gray and undecorated). This indicates more clearly that this is a "dead-end"
  in blame navigation.

* Display lines changed in current revision in green.
2016-06-02 16:26:50 +02:00
Jun Wu
463f2aebe1 tests: reorder hg serve commands
chg currently does not support hg serve -d. It has a quick path testing if the
command is hg serve -d and fallbacks to hg if so. But the test only works if
"serve" is the first argument since the test wants to avoid false positives
(for example, "-r serve" is different).
This patch reorders "hg server" commands in tests, making them chg friendly.
2016-03-15 09:51:54 +00:00
Anton Shestakov
1ea7911d8a gitweb: visually highlight source lines when hovering over line numbers
Due to how the line links now reside outside of the source lines, hovering over
line numbers doesn't count as hovering over the appropriate source line. It can
be worked around by using a "+" css selector. However, it's necessary to
reorder the elements and put <a> before <span> (which is actually quite
logical). It works without further css tweaks because <a> is already
absolute-positioned and so the order doesn't matter visually.
2015-10-15 00:04:58 +08:00
Gijs Kruitbosch
92cf6734a1 hgweb: ensure both foreground and background colors are specified (issue4872)
When users configure the default foreground or background color to
non-default (black on white) values, several hgweb styles lack
contrast for headers and table row items. This patch fixes that by
ensuring that where either foreground or background colors are
specified, both are specified.
2015-10-07 21:08:14 +01:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Anton Shestakov
e295b5a51b gitweb, monoblue: port highlighting linked lines from paper
This is adapted from a9c9f5ef6abf, 38b0132204f4 and 1555d017cac7.
2015-09-25 12:38:20 +08:00
Anton Shestakov
9643ca35f2 gitweb, monoblue: fix vertical align of spans in .sourcelines
Empty lines in file view could produce an inexplicable margin before the next
line (most noticeable in browsers on webkit/blink engine). That was making
empty lines seem taller than the rest.

Instead of using default vertical align, let's set it to 'top'.

This issue is actually present in paper, and only recently got into gitweb
(0609781075c1) and monoblue (b7a7757577fb). There's a bit more to it in paper,
so that will be dealt with in a future patch.

Recipe to see live: preferably using a webkit/blink browser, such as chromium,
browse a file with empty lines, e.g. https://selenic.com/hg/file/3.5/README#l8
Selecting a block of text that includes empty lines will reveal white "breaks"
in the selection. Highlighted line (#l8) also shows such a break below itself.
2015-09-25 03:02:38 +08:00
Anton Shestakov
de245a8121 gitweb: port code selection without line numbers from paper
This is adapted from a46863946982 and 8d7bff75072d.

It also fixes issue4790 in gitweb; tab characters now have meaningful width on
the modified pages (file view, file diff, changeset).
2015-09-22 02:09:10 +08:00
Anton Shestakov
039254207e tests: fix css-related test-hgweb.t breakage from c9bd2969e789 2015-09-04 21:12:07 +08:00
Anton Shestakov
59f182075a hgweb: allow symbolic revisions with forward slashes in urls
It's possible to have a branch/tag/bookmark with all kinds of special
characters, such as {}/\!?. While not very conveniently, symbolic revisions
with such characters work from command line if user correctly quotes the
characters. These characters also work in hgweb, when they are properly
encoded, with one exception: '/' (forward slash, urlencoded as '%2F'), which
was getting decoded before hgweb could parse it as a part of PATH_INFO.
Because of that, hgweb was seeing it as any other forward slash, that is, as
just another url parts separator.

For example, if user wanted to see the content of dir/file at bookmark
'feature/eggs', url could be: '/file/feature%2Feggs/dir/file'. But hgweb tried
to find a revision 'feature' and get contents of 'eggs/dir/file'.

To fix this, let's assume forward slashes are doubly-urlencoded (%252F), so
CGI/WSGI server decodes it into %2F. Then we can decode %2F in the revision
part of the url into an actual '/' character.

Making hgweb produce such urls will be done in the next 2 patches.
2015-07-12 16:06:57 +08:00
Anton Shestakov
d76c5b8c5a hgweb: link to revision by node hash in paper & coal
Unlike other styles, paper and coal had only one link to current revision: in
the sidebar. Since those links now use symbolic revisions after 4b263b99440b,
it's nice to have a link that allows going from /rev/tip to /rev/<tip hash>,
for instance. Let's make the node hash in the page header that new link.
2015-06-18 17:06:18 +08:00
Anton Shestakov
eb4bfc238e hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Let's make paper (and coal, since it borrows so much from paper) templates use
symbolic revision in navigation links.

The majority of links (log, filelog, annotate, etc) still use node hashes.

Some pages don't have permanent links to current node hash (so it's not very
easy to go from /rev/tip to /rev/<tip hash>), this will be addressed in future
patches.
2015-06-16 16:07:39 +08:00
Matt Mackall
b709208c37 tests: drop DAEMON_PIDS from killdaemons calls 2015-06-08 14:55:40 -05:00
Matt Mackall
3ad28905f6 tests: drop explicit $TESTDIR from executables
$TESTDIR is added to the path, so this is superfluous. Also,
inconsistent use of quotes means we might have broken on tests with
paths containing spaces.
2015-06-08 14:44:30 -05:00
Matt Mackall
7537e70971 merge with stable 2015-03-13 17:55:04 -05:00
Yuya Nishihara
7445ebd638 hgweb: prevent loading style map from directories other than specified paths
A style name should not contain "/", "\", "." and "..". Otherwise, templates
could be loaded from outside of the specified templates directory by invalid
?style= parameter. hgweb should not allow such requests.

This change means subdir/name is also rejected.
2015-03-13 21:18:59 +09:00
Matt Mackall
45d5d3b1b1 test-hgweb: fix shutdown race
Logfiles weren't necessarily being flushed before being read.
2015-01-23 17:47:04 -06:00
Anton Shestakov
48ec2b2e8f hgweb: replace implicit <tbody> with explicit <thead> where appropriate
Some templates in paper style use <tbody> elements inside <table> to assign a
class to "body" part of that table (in this case, to make rows striped). The
problem is that the <tbody> is preceded by <tr> element, which browsers
understand as an implicit start of table body, so the following exlicit <tbody>
will actually be "nested", which is not valid.

Since that first <tr> contains table headers, wrapping it in <thead> is both
semantically correct and follows the advertised XHTML 1.1 doctype.
2015-02-06 15:52:55 +08:00
Gregory Szorc
49e88a6464 templates: use CSS classes for diff styling
Use of inline style for diff styling led to significant browser memory
usage on large diffs. Moving the styling into CSS classes corrects this.

This patch is based on work from
https://bugzilla.mozilla.org/show_bug.cgi?id=766952
and
https://hg.mozilla.org/hgcustom/version-control-tools/rev/2c355a580af6
2015-01-06 15:29:02 -08:00
Gregory Szorc
9ccf5570f8 hgweb: send proper HTTP response after uncaught exception
This patch fixes a bug where hgweb would send an incomplete HTTP
response.

If an uncaught exception is raised when hgweb is processing a request,
hgweb attempts to send a generic error response and log that exception.

The server defaults to chunked transfer coding. If an uncaught exception
occurred, it was sending the error response string / chunk properly.
However, RFC 7230 Section 4.1 mandates a 0 size last chunk be sent to
indicate end of the entity body. hgweb was failing to send this last
chunk. As a result, properly written HTTP clients would assume more data
was coming and they would likely time out waiting for another chunk to
arrive.

Mercurial's own test harness was paving over the improper HTTP behavior
by not attempting to read the response body if the status code was 500.
This incorrect workaround was added in faced8f5c2af and has been removed
with this patch.
2014-11-28 10:59:02 -08:00
Augie Fackler
a5ddb1dcfe tests: use $PYTHON instead of hardcoding python
This makes running the testsuite with pypy possible.
2014-10-15 15:35:59 -04:00
Matt Mackall
275eb5bdd1 merge with stable 2014-09-29 17:23:38 -05:00
Anton Shestakov
1119de7215 hgweb: refresh hgweb.repo on phase change (issue4061)
Make hgweb.refresh() also look at phaseroots file (in addition to 00changelog.i
file) and reload the repo when os.stat returns different mtime or size than
cached, signifying the file was modified.

This way if user changes phase of a changeset (secret <-> draft), there's no
need to restart hg serve to see the change.
2014-09-27 21:59:55 +09:00
Anton Shestakov
20c415845d hgweb: fail if an invalid command was supplied in url path (issue4071)
Traditionally, the way to specify a command for hgweb was to use url query
arguments (e.g. "?cmd=batch"). If the command is unknown to hgweb, it gives an
error (e.g. "400 no such method: badcmd").

But there's also another way to specify a command: as a url path fragment (e.g.
"/graph"). Before, hgweb was made forgiving (looks like it was made in
cd356f4efd91) and user could put any unknown command in the url. If hgweb
couldn't understand it, it would just silently fall back to the default
command, which depends on the actual style (e.g. for paper it's shortlog, for
monoblue it's summary). This was inconsistent and was breaking some tools that
rely on http status codes (as noted in the issue4071). So this patch changes
that behavior to the more consistent one, i.e. hgweb will now return "400 no
such method: badcmd".

So if some tool was relying on having an invalid command return http status
code 200 and also have some information, then it will stop working. That is, if
somebody typed foobar when they really meant shortlog (and the user was lucky
enough to choose a style where the default command is shortlog too), that fact
will now be revealed.

Code-wise, the changed if block is only relevant when there's no "?cmd" query
parameter (i.e. only when command is specified as a url path fragment), and
looks like the removed else branch was there only for falling back to default
command. With that removed, the rest of the code works as expected: it looks at
the command, and if it's not known, raises a proper ErrorResponse exception
with an appropriate message.

Evidently, there were no tests that required the old behavior. But, frankly, I
don't know any way to tell if anyone actually exploited such forgiving behavior
in some in-house tool.
2014-09-22 23:46:38 +09:00
Matt Mackall
dd1fdce87e merge with stable 2014-09-27 14:47:52 -05:00
Matt Mackall
11be5cc27c tests: replace exit 80 with #require 2014-08-06 11:43:59 -05:00
Augie Fackler
2f98d90618 test-hgweb-*: output change fixes from b1d65cb8 2014-01-16 09:23:31 -05:00
Alexander Plavin
8495f525a8 paper: edit search hint to include new feature description 2013-09-06 13:30:57 +04:00
Alexander Plavin
e94f8da7af paper: define searchhint message in map file and use it in other templates 2013-07-25 01:12:25 +04:00
Alexander Plavin
d32de28413 hgweb: make stripes in directory view with CSS 2013-07-13 17:44:46 +04:00
Alexander Plavin
93a914c0c3 css: remove repeated property
'margin' property was repeated for the same selector
2013-04-20 16:46:38 +04: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
Bryan O'Sullivan
a527962b71 tests: update hgweb tests to include breadcrumbs 2013-01-08 16:16:29 -08:00
Patrick Mezard
7d8680da1f killdaemons: take file argument explicitely
It makes it easier to use as a generic replacement for kill utility,
mostly for Windows tests.
2012-08-20 22:36:51 +02:00
Ross Lagerwall
7137940459 hgweb: make paper:error consistent with template
Tests fixed by Patrick Mézard <patrick@mezard.eu>
2012-07-30 11:33:27 +02:00
Matt Mackall
c40407a58a hgweb: improve colors for comparison page
delete: red -> red
insert: green -> yellow
change: yellow -> gray
2012-07-25 14:49:53 -05: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
Mads Kiilerich
1fda0b1af1 tests: prepare get-with-headers.py for MSYS
get-with-headers.py took the http GET parameter as a command line parameter
that had to start with '/'. MSYS on windows will mangle such paths.

Instead of applying a workaround everywhere (such as an extra '/') we let
get-with-headers.py add the mandatory '/'. That is consistent with the
url path handling in the Mercurial url class.

A few tests sent 'GET ?cmd=...' which is invalid. They will now send 'GET
/?cmd=...'.

This will not enable any tests for being run on windows - only remove one
reason they were disabled.
2012-06-21 03:05:02 +02:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00