Commit Graph

17 Commits

Author SHA1 Message Date
Martin Geisler
5b8443bcff Merge with stable 2010-01-16 02:40:00 +01:00
Jim Hague
ab2b905e27 Work around AIX shell builtin printf not handling \NNN.
On AIX, ksh builtin printf does not understand \NNN. Some tests use this
to generate test data, and so fail on AIX. Rework these tests to use python
to generate the correct characters. This fixes the tests on AIX and should
be more generally portable.
2010-01-06 18:03:33 +00:00
Martin Geisler
3ad361f96f test-highlight: remove redundant test
Changeset 6c87ffe1c40d is testing how a EUC-JP encoded Japanese file
is treated in different encodings, so the ISO-8859-1 encoded German
file is no longer needed.
2009-09-04 23:45:13 +02:00
Yuya Nishihara
c7c32653ef highlight: fixes garbled text in non-UTF-8 environment
This patch treats all files inside repository as encoded by
locale's encoding when pygmentize.

We can assume that most files are written in locale's encoding,
but current implementation treats them as UTF-8.
So there's no way to specify the encoding of files.

Current implementation, e2f3244d5179 (issue1341):
1. Convert original `text`, which is treated as UTF-8, to locale's encoding.
   `encoding.tolocal()` is the method to convert from internal UTF-8 to local.
   If original `text` is not UTF-8, e.g. Japanese EUC-JP, some characters
   become garbled here.
2. pygmentize, with no UnicodeDecodeError.

This patch:
1. Convert original `text`, which is treated as locale's encoding, to unicode.
   Pygments prefers unicode object than raw str. [1]_
   If original `text` is not encoded by locale's encoding, some characters
   become garbled here.
2. pygmentize, also with no UnicodeDecodeError :)
3. Convert unicode back to raw str, which is encoded by locale's.

.. [1] http://pygments.org/docs/unicode/
2009-08-29 15:24:15 +09:00
Christian Ebert
d7ec6a9f9d tests highlight, keyword: load extensions with "ext =" 2009-12-23 17:46:48 +00:00
Martin Geisler
f51ce71d96 test-highlight: decouple test from get-with-headers.py
The test copied get-with-headers.py from $TESTDIR and committed it to
a test repository. The test output therefore depended unnecessarily on
the exact content of get-with-headers.py. It has now been replaced
with another small Python script.
2009-05-17 21:47:24 +02:00
Christian Ebert
510a4bc8a5 test-highlight: adapt output to latest pygments keeping backwards compatibility 2009-04-19 13:27:03 +01:00
Christian Ebert
3849a2cc57 tests: guess lexer by filename for recent pygments
Recent pygments guess AntlrJavaLexer for the isolatin text, converted to ascii
by util.tolocal, which yields class="err". Guess lexer by extension instead.
2009-04-04 15:14:36 +02:00
Dirkjan Ochtman
e53eace7ea tests: use killdaemons.py in test-highlight 2009-01-12 09:57:52 +01:00
Gilles Moris
9b7deb4420 test-hgweb-*: replace "XX years ago" by a fixed string in get-with-headers.py
Note that other sed replacement commands are also filtering get-with-headers.py,
but they seem to be more test specific, hence not handled here.
2008-12-25 17:49:08 +01:00
Christian Ebert
5cbc9e210a highlight: convert text to local before passing to pygmentize (issue1341)
Example case:
Display file written in iso-8859-1 with current HGENCODING utf-8.
At the moment only an Error page appears because pygmentize
chokes on the replacement chars.

Alternatives:
1) Turn off highlighting and avoid UnicodeDecodeError
   for files that are not in HGENCODING.
2) [this patch] use util.tolocal to display these files.

Alternative 2) seems ok, as this only concerns display and
readability.

See also: c5f1a58b8b9a, apparently put aside during refactor of
highlight.

Add test for UnicodeDecodeError with iso-8859-1 file contents.
2008-10-17 12:12:33 +02:00
Dirkjan Ochtman
0aa08a7ed8 merge with crew-stable 2008-09-17 11:34:37 +02:00
Dirkjan Ochtman
87abdc361c tests: fix test-highlight for compatiblity with newer Pygments 2008-09-17 11:14:06 +02:00
Rocco Rutte
cc79439de6 highlight: only pygmentize for HTML mimetypes
For non-html mimetypes it doesn't make much sense. This also fixes the
issue that highlight unconditionally adds a <link/> tag for its CSS to
the template's header (which is pointless in text/plain output).
2008-09-05 10:39:57 +02:00
Brendan Cully
a6d56747f2 Fix intermittent broken pipe in test-highlight 2008-08-06 15:08:18 -07:00
Isaac Jurado
ec51524d45 highlight: Generate pygments style sheet dynamically
This patch allows a per-repository (for example, within a hgwebdir) selection
of pygments_style web option.  No static .css files required.

Test edited by pmezard (compatibility fixes)
2008-04-05 21:29:02 +02:00
Dirkjan Ochtman
a3c9e25c1e tests: add highlight extension tests 2008-03-22 20:16:30 +01:00