Commit Graph

68 Commits

Author SHA1 Message Date
Anton Shestakov
41e5f7f794 hgweb: remove negative top from .info line in graph
"top: -Xpx" shifts a block up by X pixels, which can be used to visually
compress two lines of text to have less space between them, in this case it's
used for the changesets on /graph page. But not only it's not needed there
(both lines fit fine into their allowed vertical space), but it would also look
better (not as crammed, more vertically centered) without these negative
values.

"position: relative" is needed solely for the "top" property to have effect on
the element, no children of the .info element rely on it, so let's remove it as
well.
2017-12-01 20:33:02 +08:00
Anton Shestakov
3696751497 gitweb: remove unused css classes
Looks like they were unused since the very introduction of gitweb theme in
8a464c5805aa.
2017-11-25 15:42:24 +08:00
Anton Shestakov
df1a7f71ac hgweb: show instabilities of a commit
In paper, coal, gitweb and monoblue a new "tag" (or multiple, if there are many
instabilities) is added to the same line that has phase, branch, etc of a
changeset; in gitweb and monoblue this element has a light red background, in
paper and coal the element is black and underlined. In spartan theme
instabilities are shown on a separate line.

While test-obsolete.t uses first(phasedivergent()) revset to pick a changeset
to test, that particular changeset is also an orphan, so two different
instability tags are displayed.
2017-11-19 14:02:50 +08:00
Anton Shestakov
980f6b961e hgweb: show obsolescence status of a commit
As with phases, spartan theme shows a simple "obsolete: yes" on its own line
(this allows replacing "yes" with something more useful in future, like output
of obsfate* template functions). Everywhere else a new "tag" is added to the
same line that has phase, branch, etc of a changeset; in gitweb and monoblue
the element has gray background, in paper and coal the element is gray with a
dashed underline.
2017-11-18 12:04:08 +08:00
Anton Shestakov
f8a893bdbf hgweb: show commit phase if it's not public
In spartan theme phase is shown on its own table row, because there's no single
line of "tags". Everywhere else phase is prepended to the list of "tags" of a
changeset. Its element has a purple-ish color in gitweb and monoblue, and a
dotted line under it and no color in paper and coal (as these themes are frugal
with colors).

This patch intentionally doesn't touch graph, because it needs a rewrite. I'll
get to it pretty soon and in the process will add phase and everything that's
still coming (e.g. obsolescence and instabilities).

.. feature::

   hgweb now displays phases of non-public changesets
2017-11-16 22:21:03 +08:00
Anton Shestakov
281eec2f1e hgweb: move changeset "tags" to a template in map file (paper and coal)
This patch puts all these changeset "tags" into one template shared everywhere
in paper and coal themes. But it should be noted that some of the templates had
different sets of tags, in some cases it was intended, in others - most likely
not.

First, what's up with all these different ways to get changeset's branch. There
are actually 3 ways to do it in hgweb, they can all be seen in this patch;
"branches", "inbranch" and "branch". They are all lists that consist of 1 or 0
items:

- "branches" has ctx.branch() if current changeset is the tip of that branch
- "inbranch" has ctx.branch() if current changeset is _not_ the tip of that
  branch and the branch is not "default"
- "branch" aka "changesetbranch" has ctx.branch() if the branch is not
  "default"

The majority of cases (7 vs 2 + /graph) in paper theme used only option 3,
which meant that "default" was never displayed. But other parts of the theme
disagreed with this and used option 1 and option 2 together. For example, the
default view (log) displays "default" on the branch tip (can be seen right
about now on m-s.o/repo/hg), but it disappears when you click on the commit.

Also, using option 3 alone meant that there was no way to tell if a changeset
is the tip of its branch or not (it was always assumed that it's not, see how
some css classes change from "branchname" to the correct "branchhead" in tests)
-- so the two different css styles that exist in paper just for this were
underused.

I think this patch improves the situation, even though it changes the old (even
if inconsistent) behavior. The new behavior matches that of gitweb and
monoblue.
2017-11-15 23:55:09 +08:00
Anton Shestakov
1132b26766 gitweb: apply styles from annotate tooltip to followlines popup
These new colors and styles are already used in the tooltip that gets shown
when user hovers over line numbers on annotate page. The old styles, replaced
in this patch, look completely unrelated to gitweb or any other hgweb theme.
2017-11-10 18:50:44 +08:00
Gregory Szorc
28b7db089e hgweb: add HTML elements to control whitespace settings for annotate
Building on top of the new URL query string arguments to control
whitespace settings for annotate, this commit adds HTML checkboxes
reflecting the values of these arguments to the paper and gitweb
themes.

The actual diff settings are now exported to the templating layer.
The HTML templates add these as data-* attributes so they are
accessible to the DOM.

A new <form> with various <input> elements is added. The <form>
is initially hidden via CSS. A shared JavaScript function (which
runs after the <form> has been rendered but before the annotate
HTML (because annotate HTML could take a while to load and we want
the form to render quickly) takes care of setting the checked state
of each box from the data-* attributes. It also registers an event
handler to modify the URL and refresh the page whenever the checkbox
state is changed.

I'm using the URLSearchParams interface to perform URL manipulation.
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams tells
me this may not be supported on older web browsers. Yes, apparently
the web API didn't have a standard API to parse and format query
strings until recently. Hence the check for the presence of this
feature in the JavaScript. If the browser doesn't support the
feature, the <form> will remain hidden and behavior will like it
currently is. We could polyfill this feature or implement our own
query string parsing. But I'm lazy and this could be done as a
follow-up if people miss it.

We could certainly expand this feature to support more diff options
(such as lines of context). That's why the potentially reusable code
is stored in a reusable place. It is also certainly possible to
add diff controls to other pages that display diffs. But since
Mozillians are making noise about controlling which revisions
annotate shows, I figured I'd start there.

.. feature::

   Control whitespace settings for annotation on hgweb

   /annotate URLs on hgweb now accept query string arguments to
   influence how whitespace changes impact results.

   The arguments "ignorews," "ignorewsamount," "ignorewseol," and
   "ignoreblanklines" now have the same meaning as their [annotate]
   config section counterparts. Any provided setting overrides the
   server default.

   HTML checkboxes have been added to the paper and gitweb themes
   to expose current whitespace settings and to easily modify the
   current view.

Differential Revision: https://phab.mercurial-scm.org/D850
2017-09-30 09:01:36 +01:00
Gregory Szorc
21ad83cca7 gitweb: preserve whitespace in description
Without this, multiple spaces or tabs in the commit message aren't
preserved and things like tables don't align properly.

As part of adding the CSS rule, we had to cuddle the content
with the <div> to not introduce leading and trailing whitespace.
The "addbreaks" filter was also removed because it would insert
an additional newline, effectively double spacing content.

Differential Revision: https://phab.mercurial-scm.org/D113
2017-07-17 15:54:15 -07:00
Denis Laxalde
e4402fa19c hgweb: re-implement followlines UI selection using buttons
This changeset attempts to solve two issues with the "followlines" UI in
hgweb. First the "followlines" action is currently not easily discoverable
(one has to hover on a line for some time, wait for the invite message to
appear and then perform some action). Second, it gets in the way of natural
line selection, especially in filerevision view.

This changeset introduces an additional markup element (a <button
class="btn-followlines">) alongside each content line of the view. This button
now holds events for line selection that were previously plugged onto content
lines directly. Consequently, there's no more action on content lines, hence
restoring the "natural line selection" behavior (solving the second problem).
These buttons are hidden by default and get displayed upon hover of content
lines; then upon hover of a button itself, a text inviting followlines section
shows up. This solves the first problem (discoverability) as we now have a
clear visual element indicating that "some action could be perform" (i.e. a
button) and that is self-documented.

In followlines.js, all event listeners are now attached to these <button>
elements. The custom "floating tooltip" element is dropped as <button>
elements are now self-documented through a "title" attribute that changes
depending on preceding actions (selection started or not, in particular).

The new <button> element is inserted in followlines.js script (thus only
visible if JavaScript is activated); it contains a "+" and "-" with a
"diff-semantics" style; upon hover, it scales up.

To find the parent element under which to insert the <button> we either rely
on the "data-selectabletag" attribute (which defines the HTML tag of children
of class="sourcelines" element e.g. <span> for filerevision view and <tr> for
annotate view) or use a child of the latter elements if we find an element
with class="followlines-btn-parent" (useful for annotate view, for which we
have to find the <td> in which to insert the <button>).

On noticeable change in CSS concerns the "margin-left" of span:before
pseudo-elements in filelog view that has been increased a bit in order to
leave space for the new button to appear between line number column and
line content one.
Also note the "z-index" addition for "annotate-info" box so that the latter
appears on top of new buttons (instead of getting hidden).

In some respect, the UI similar to line commenting feature that is implemented
in popular code hosting site like GitHub, BitBucket or Kallithea.
2017-07-03 13:49:03 +02:00
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