Mercurial > public > mercurial-scm > hg
diff tests/test-highlight.t @ 26249:3166bcc0c538
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 16 Sep 2015 22:30:36 +0800 |
parents | d53212d70893 |
children | 4b0fc75f9403 |
line wrap: on
line diff
--- a/tests/test-highlight.t Fri Sep 04 11:15:02 2015 -0400 +++ b/tests/test-highlight.t Wed Sep 16 22:30:36 2015 +0800 @@ -5,6 +5,7 @@ > highlight = > [web] > pygments_style = friendly + > highlightfiles = **.py and size('<100KB') > EOF $ hg init test $ cd test @@ -590,6 +591,28 @@ errors encountered $ cat errors.log + $ killdaemons.py + +only highlight C source files + + $ cat > .hg/hgrc <<EOF + > [web] + > highlightfiles = **.c + > EOF + +hg serve again + + $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log + $ cat hg.pid >> $DAEMON_PIDS + +test that fileset in highlightfiles works and primes.py is not highlighted + + $ get-with-headers.py localhost:$HGPORT 'file/tip/primes.py' | grep 'id="l11"' + <span id="l11">def primes():</span><a href="#l11"></a> + +errors encountered + + $ cat errors.log $ cd .. $ hg init eucjp $ cd eucjp