Commit Graph

66 Commits

Author SHA1 Message Date
Jun Wu
e3bbd1757c serve: assign hg serve ports dynamically (part 2)
Summary:
This is similar to what D6925398 does. But covers areas that D6925398 missed
because the codemod script wasn't able to handle multiple-line `hg serve`
commands.

Reviewed By: DurhamG

Differential Revision: D6937919

fbshipit-source-id: a67de178527c11a0ed8bbac82f0c46d44b81be77
2018-04-13 21:51:08 -07:00
Jun Wu
4a7b28d08b serve: assign hg serve ports dynamically in tests
Summary:
Previously `hg server` uses `HGPORT` that might be in use. This patch uses
`-p 0 --port-file ...` so `hg server` always gets assigned a free port.

The change was first made by the following Ruby script:

```
re = /^  \$ hg serve(.*) -p \$(HGPORT[12]?) (.*[^\\])$\n  \$/
Dir['*.t'].each do |path|
  old = File.read(path)
  new = old.lines.map do |l|
    next l if l[/\(glob\)/] or not l['$HGPORT'] or l[/^  [$>]/]
    "#{l.chomp} (glob)\n"
  end.join.gsub re, <<-'EOS'.chomp
  $ hg serve\1 -p 0 --port-file $TESTTMP/.port \3
  $ \2=`cat $TESTTMP/.port`
  $
  EOS
  File.write(path, new) if old != new
end
```

Then there are some manual changes:

run-tests.py: It now treats `$HGPORT` in output as glob pattern `*`, since
it does not know the assigned value in tests.

test-bookmarks-pushpull.t, test-https.t: Some `hg pull`s were changed to use
explicit paths instead of relying on `.hgrc` since the test restarts the
server and `.hg/hgrc` having an outdated URL.

test-schemes.t: The test writes `$HGPORT` to `.hgrc` before assigning it.
Changed the order so the correct `$HGPORT` is written.

test-patchbomb-tls.t: Changed `(?) (glob)` to `(glob) (?)`.

Reviewed By: DurhamG

Differential Revision: D6925398

fbshipit-source-id: d5c10476f43ce23f9e99618807580cf8ba92595c
2018-04-13 21:51:07 -07: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
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
Augie Fackler
97036b7a5e tests: make test-highlight code portable to python3
This is easier than trying to do some sort of check-code shenanigans.

Differential Revision: https://phab.mercurial-scm.org/D278
2017-07-25 00:00:14 -04: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
Denis Laxalde
cd2cc3059a hgweb: parameterize the tag name of elements holding followlines selection
While plugging followlines.js into "annotate" view, we'll need to walk a
different DOM structure from that of "filerevision" view. In particular, the
selectable source line element is a <tr> in annotate view (in contrast with a
<span> in filerevision view). So make this tag name a parameter of
followlines.js script by passing its value as a "selectabletag" data attribute
of <pre class="sourcelines"> element.

As <pre class="sourcelines"> tags are getting quite long in templates, rewrite
them on several lines.
2017-06-21 17:07:51 +02:00
Augie Fackler
305e834562 tests: use $PYTHON in #! so we always use the right Python 2017-06-15 14:27:52 -04:00
Augie Fackler
f08a4d8416 tests: remove #! from primes.py in test-highlight.t
It's about to be a source of trouble, but removing it changes a ton of
test lines, so doing this change as a standalone commit.
2017-06-20 08:44:56 -04: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
d141711562 hgweb: do not show "descending" link in followlines UI for filelog heads
When on a filelog head, we are certain that there will be no descendant so the
target of the "descending" link will lead to an empty log result. Do not
display the link in this case.
2017-04-24 10:32:15 +02:00
Denis Laxalde
b2e35d013c hgweb: rename linerangelog.js as followlines.js
So that the file name matches both the feature name and user facing vocabulary
(e.g. the revset function).
2017-04-03 10:02:55 +02:00
Denis Laxalde
c2ed8e445d hgweb: expose a followlines UI in filerevision view
In filerevision view (/file/<rev>/<fname>) we add some event listeners on
mouse clicks of <span> elements in the <pre class="sourcelines"> block.
Those listeners will capture a range of lines selected between two mouse
clicks and a box inviting to follow the history of selected lines will then
show up. Selected lines (i.e. the block of lines) get a CSS class which make
them highlighted. Selection can be cancelled (and restarted) by either
clicking on the cancel ("x") button in the invite box or clicking on any other
source line. Also clicking twice on the same line will abort the selection and
reset event listeners to restart the process.

As a first step, this action is only advertised by the "cursor: cell" CSS rule
on source lines elements as any other mechanisms would make the code
significantly more complicated. This might be improved later.

All JavaScript code lives in a new "linerangelog.js" file, sourced in
filerevision template (only in "paper" style for now).
2017-03-29 22:26:16 +02:00
Yuya Nishihara
8d8a7da758 test-highlight: add normalization rule for Pygments 2.2
The test failed on Debian sid because of new class="vm".
2017-01-30 22:50:20 +09: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
Gregory Szorc
05ec82c913 hgweb: link to raw-file on annotation page (BC)
Every other template has the "raw" link load "raw-file." However,
fileannotate.tmpl's "raw" link loads "raw-annotate." This feels
inconsistent and wrong.

As far as I can tell, linking to the "raw annotate" view has occurred
since 2006.
2016-12-28 15:48:17 -07:00
Anton Shestakov
72f684f821 paper: make different blocks of annotated lines have different colors 2016-07-16 14:49:07 +08:00
Denis Laxalde
349c6778aa hgweb: add a link on node id in annotate hover-box
The link pointing the annotate view at this revision, just like the one in the
left-column but accessible from anywhere.
2016-07-12 15:09:07 +02:00
Denis Laxalde
0986e60532 hgweb: move author information from left-column to hover-box in annotate view
And display the full author information since there is enough space there.
2016-07-12 15:07:37 +02:00
Denis Laxalde
81b6a5375a hgweb: add links to diff and changeset in hover-box on annotate view 2016-06-14 11:01:30 +02: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
2acd032eb6 hgweb: display blamed revision once per block in annotate view
I.e. when a revision blames a block of source lines, only display the
revision link on the first line of the block (this is identified by the
"blockhead" key in annotate context).

This addresses item "Visual grouping of changesets" of the blame improvements
plan (https://www.mercurial-scm.org/wiki/BlamePlan) which states: "Typically
there are block of lines all attributed to the same revision. Instead of
rendering the revision/changeset for every line, we could only render it once
per block."
2016-06-07 12:10:01 +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
Yuya Nishihara
daa7a50011 test-highlight: add normalization rule for Pygments 2.1
It appears that several classes have 'h', '1', '2' suffixes on Pygments 2.1,
which is the current version on Debian sid.
2016-01-26 23:33:53 +09:00
Yuya Nishihara
03e498741f test-highlight: factor out function that normalizes pygments output 2016-01-26 23:27:12 +09:00
Yuya Nishihara
4d7b480bbe test-highlight: unify normalization rule of pygments output
We had two variants for unknown reason, s/mf/mi/g and s/mi/mf/g. This patch
unifies them to s/mf/mi/g so that we can introduce a utility function.
2016-01-26 23:26:05 +09:00
Gregory Szorc
c20551dc4f highlight: add option to prevent content-only based fallback
When Mozilla enabled Pygments on hg.mozilla.org, we got a lot of weirdly
colorized files. Upon further investigation, the hightlight extension
is first attempting a filename+content based match then falling back to a
purely content-driven detection mode in Pygments. Sounds good in theory.

Unfortunately, Pygments' content-driven detection establishes no minimum
threshold for returning a lexer. Furthermore, the detection code for
a number of languages is very liberal. For example, ActionScript 3 will
return a confidence of 0.3 (out of 1.0) if the first 1k of the file
we pass in matches the regex "\w+\s*:\s*\w"! Python matches on
"import ". It's no coincidence that a number of our extension-less files
were getting highlighted improperly.

This patch adds an option to have the highlighter not fall back to
purely content-based detection when filename+content detection failed.
This can be enabled to render unlighted text instead of taking the risk
that unknown file types are highlighted incorrectly. The old behavior is
still the default.
2015-10-14 18:22:16 -07:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Anton Shestakov
7e01618c4d highlight: add highlightfiles config option which takes a fileset (issue3005)
Highlight extension lacked a way to limit files by size, by extension, and/or
by any other part of file path. A good solution would be to use a fileset,
since it can check file path, extension and size (and more) in one expression.
So this change introduces such an option, highlighfiles, which takes a fileset
and on each request decides if the requested file should be highlighted.

The default "size('<5M')" is, in a way, suggested in issue3005.

checkfctx() limits the amount of work to just one file (subset kwarg in
fileset.matchctx()).

Monkey-patching works around issue4568, otherwise using filesets here while
running hgweb in directory mode would say, for example, "Abort: **.py not under
root", but this fix is very local and probably far from ideal. I suspect there
to be a way to fix this for the whole hgweb and resolve the issue, but I don't
know how to do it.
2015-09-16 22:30:36 +08:00
Anton Shestakov
d1c17dc442 hgweb: replace .sourcelast with .bottomline that does the same
In paper and Coal, basically, div.sourcelast was only used to make a 1px border
on the bottom of file source view (and only there). It's better to use
bottomline class, that also exists for the same purpose (visually), but is used
more widely and works without needing an empty <div>.
2015-09-14 18:41:09 +08:00
Anton Shestakov
403857c028 highlight: produce correct markup when there's a blank line just before EOF
Due to how the colorized output from pygments was stripped of <pre> elements,
when there was an empty line at the end of a file, highlight extension produced
an incorrect markup (no closing tags from the fileline/annotateline template).
It wasn't usually noticeable, because browsers were smart enough to see where
the missing tags should've been, but in monoblue style it resulted in the last
line having twice the normal height.

Instead of awkwardly trying to strip outer <pre></pre> tags, let's make the
formatter with nowrap=True, which should do what we need in pygments since at
least 0.5 (2006-10-30).

Example from monoblue style:

Before:

    <div class="source">

<div style="font-family:monospace" class="parity0">
<pre><a class="linenr" href="#l1" id="l1">     1</a> </pre>
</div>
<div style="font-family:monospace" class="parity1">
<pre><a class="linenr" href="#l2" id="l2">     2</a>
    </div>

Now:

    <div class="source">

<div style="font-family:monospace" class="parity0">
<pre><a class="linenr" href="#l1" id="l1">     1</a> </pre>
</div>
<div style="font-family:monospace" class="parity1">
<pre><a class="linenr" href="#l2" id="l2">     2</a> </pre>
</div>
    </div>

(Notice the missing </pre></div> now in place)
2015-07-22 10:19:17 +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
Anton Shestakov
4451d363dd paper: show branch/tags/bookmarks when blaming (issue3559) 2015-05-15 20:04:24 +08:00
Anton Shestakov
c6733e1dd2 paper: show branch/tags/bookmarks when viewing (issue3559) 2015-05-15 20:00:47 +08: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
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
11be5cc27c tests: replace exit 80 with #require 2014-08-06 11:43:59 -05:00
FUJIWARA Katsunori
98201640e7 hgweb: fix lack of "bookmarks" link in "/file" page of "paper" style
This patch also fixes same problem of "coal" style, because it re-uses
"filerevision.tmpl" of "paper" style.

"gitweb" and "monoblue" styles don't have such problems.

"spartan" style doesn't have "bookmarks" page definition itself.
2014-04-17 09:36:08 +09:00
Danek Duvall
4a6ebc20e6 solaris: diff -u emits "No differences encountered"
Solaris diff -u isn't silent when two files are identical, and tests that
don't account for that will fail.  Fix those tests, and introduce a check
that prevents reintroduction.
2014-02-19 13:46:49 -08: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
9e521b740d paper: remove unused occurence of changelogtag in views
This variably isn't passed to these views and it always renders to empty string
for this reason. Other themes don't have this issue.
2013-08-03 00:34:56 +04:00
Alexander Plavin
793ff2d3f8 hgweb: highlight line which is linked to at annotate view 2013-07-14 05:35:04 +04:00
Alexander Plavin
fe02157bda hgweb: make stripes in file annotate view with CSS 2013-07-13 17:43:45 +04:00
Alexander Plavin
0c3cdee1bd hgweb: introduce separate classes for stripey background
Introduce stripes2 and stripes4 classes to support different structure.
They will be useful to implement stripes with pure CSS everywhere instead
of current server-side implementation.
2013-07-12 23:47:56 +04:00