Commit Graph

330 Commits

Author SHA1 Message Date
Bryan O'Sullivan
7c51d9d3e5 templater: fix check-code error 2013-04-08 15:04:17 -07:00
Brendan Cully
1c111a8da8 template: allow unquoted int function arguments 2013-04-07 23:25:50 -07:00
Dan Villiom Podlaski Christiansen
9e387ff40b hgweb: generate HTML documentation
It's generated from the raw ReST source, as returned from help.help_().
2013-02-09 21:51:21 +00:00
Benoit Boissinot
077bafacf4 templater: add get() function to access dict element (e.g. extra) 2013-02-08 23:49:14 +01:00
Sean Farley
3247f202be templater: add no-op template function 'label' 2012-12-22 21:46:26 -06:00
Weiwen
64b5450a1f hgweb: display diff for a changeset against any parents (issue2810)
During merge of branches, it is useful to compare merge results against
the two parents.  This change adds this support to hgweb.  To specify
which parent to compare to, use rev/12300:12345 where 12300 is a
parent changeset number.  Two links are added to changeset web page so
that one can choose which parent to compare to.
2012-11-12 14:05:39 -08:00
Weiwen
75df7d78cd template engine: convert generator-based iterator to list-based iterator
If a template iterator is implemented with generator, the iterator is exhau=
sted
after we use it.  This leads to undesired behavior in template.  This chang=
e
converts a generator-based iterator to list-based iterator when template en=
gine
first detects a generator-based iterator.  All future usages of iterator wi=
ll
use list instead.
2012-11-28 14:55:42 -08:00
FUJIWARA Katsunori
78e9fa90ae i18n: add "i18n" comment to error messages of template functions 2012-10-31 03:59:27 +09:00
Matt Mackall
12037daac2 templater: drop redundant return in _flatten 2012-10-08 16:21:24 -05:00
Matt Mackall
d55a703a7d templater: pull in functions defined in templatefilters 2012-09-24 15:28:04 -05:00
Matt Mackall
e32befe1a7 templater: add if/ifeq conditionals 2012-09-24 15:26:56 -05:00
Matt Mackall
0aa788b5f2 templater: add sub() function 2012-09-24 15:26:17 -05:00
Matt Mackall
07ad449236 templater: correctly deal with r"" strings 2012-09-24 15:24:27 -05:00
Matt Mackall
01ed21300f template: add join function
This allows:

{join(files % "{files}", ", ") }\n

to produce a properly comma-separated list
2012-09-22 13:04:36 -05:00
Matt Mackall
bf4fb1e322 templater: factor out runtemplate method
As a side-effect, this makes the output of runmap non-flattened
2012-09-22 13:02:33 -05:00
Matt Mackall
0dd30183db templating: make new-style templating features work with command line lists 2012-09-21 18:54:00 -05:00
Neil Kodner
68912667a4 templater: abort when a template filter raises an exception (issue2987) 2012-08-17 15:12:01 -07:00
Ross Lagerwall
48a670fcaf templater: handle a missing value correctly
Before, using a broken style such as:
changeset =
would result in a traceback.

This fixes a regression introduced in 47618355ffc8.
2012-08-04 14:37:17 +02:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +02:00
Augie Fackler
2e41c2e64a globally: use safehasattr(x, '__iter__') instead of hasattr(x, '__iter__') 2011-07-25 15:30:19 -05:00
Augie Fackler
fdd2f9d735 globally: use safehasattr(x, '__call__') instead of hasattr(x, '__call__') 2011-07-25 16:24:37 -05:00
Augie Fackler
c1bfd9e71f windows: check util.mainfrozen() instead of ad-hoc checks everywhere 2011-07-25 16:14:02 -05:00
Matt Mackall
4257ca8615 templater: use a global funcs table 2011-07-23 14:33:35 -05:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Bernhard Leiner
baf797018e revset: report a parse error if a revset is not parsed completely (issue2654) 2011-03-16 23:09:14 +01:00
Matt Mackall
a892ad5a23 templater: clarify engine caching 2010-12-22 13:16:03 -06:00
Matt Mackall
0b9296f805 templater: use the parser.py parser to extend the templater syntax 2010-12-20 12:09:00 -06:00
Matt Mackall
39437f5a68 templater: give slightly nicer error for unknown map entries 2010-12-20 12:09:00 -06:00
Wagner Bruna
40109aa29c templater: fix variable name
'format' was renamed to 'parsed' in ec66346c8238
2010-11-18 19:52:58 -02:00
Dan Villiom Podlaski Christiansen
a1632cd61b templater: add a few comments. 2010-09-21 23:55:32 +02:00
Dirkjan Ochtman
64bb18f0dd cleanups: undefined variables 2010-06-08 09:30:45 +02:00
Matt Mackall
bb539b800d templater: drop \ when handling escaped { 2010-04-05 15:25:08 -05:00
Matt Mackall
d5c8978fe3 templater: strip whitespace inside template methods 2010-04-05 15:25:08 -05:00
Matt Mackall
0c19c19e10 templater: drop raw method 2010-04-05 15:25:08 -05:00
Matt Mackall
484c6d04d0 templater: raise nested functions 2010-04-05 15:25:08 -05:00
Matt Mackall
92fd5b132b templater: use recursive flattening
This avoids slow list operations compared to the iterative version
2010-04-05 15:25:08 -05:00
Matt Mackall
7e256edce5 templater: cache self.defaults.get 2010-04-05 15:25:08 -05:00
Matt Mackall
39b48fa1ce templater: privatize class variables 2010-04-05 15:25:08 -05:00
Matt Mackall
8d0693deb8 templater: map -> mapping 2010-04-05 15:25:08 -05:00
Matt Mackall
7834a75f92 templater: extend preparsing
preparse filters and formats and supply functions to apply
2010-04-05 15:25:08 -05:00
Matt Mackall
cefead81fd templater: preparse templates and cache
This breaks templates down into a list of literal and {} groups, with
group types preidentified.
2010-04-05 15:25:08 -05:00
Matt Mackall
7455c67fcd templater: directly parse templates, no regexes 2010-04-05 14:33:41 -05:00
Benoit Boissinot
4371f512b2 fix spaces/identation issues 2010-02-05 18:50:08 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Dirkjan Ochtman
c93b170e46 hgweb: don't choke when an inexistent style is requested (issue1901) 2009-11-12 16:39:11 +01:00
Dirkjan Ochtman
2f2b5e0e4f templater: remove support for ## template variables 2009-08-20 10:41:56 +02:00
Patrick Mezard
f32df1c921 Make {file_copies} usable as a --template key
Before this, to display file copies in templates, you had to write something
like {file_copies%filecopy}. For some reason, the {file_copy} subtemplate was
used by default but not defined by default in changeset_templater, while styles
were already using it. Here we define {file_copy} in changeset_templater, and
change the templater to handle formatting strings like {file_copies%filecopy}
with already expanded keys (in this case {file_copies}), for backward
compatibility.
2009-12-13 18:06:24 +01:00
Martin Geisler
e651951731 templater: lowercase error message
Changing this messages should be safe: automated scripts ought to have
debugged their templates and wont grep for this error message.
2009-05-17 16:25:48 +02:00
Matt Mackall
cfe14089d0 templater: replace eval with closure 2009-05-17 18:17:04 -05:00
Dirkjan Ochtman
140e5350fc templater: keep a cache of Python functions for filter expressions 2009-05-17 16:08:47 +02:00
Dirkjan Ochtman
56f023f70e templater: replace regex complexity by simple str containment checks 2009-05-17 16:06:48 +02:00
Dirkjan Ochtman
f421494a6a templater: clean up the process method, separating code paths 2009-05-17 16:05:50 +02:00
Dirkjan Ochtman
43d9564cff some modernization cleanups, forward compatibility 2009-05-13 14:08:39 +02:00
Dirkjan Ochtman
6f7f8e3dec templater: make the templating engine pluggable to some extent 2009-05-12 12:05:19 +02:00
Dirkjan Ochtman
5c6c43b746 templater: provide the standard template filters by default 2009-05-12 12:04:05 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Dirkjan Ochtman
6bfc24b2af templater: fix little problem from stylemap() changes 2009-04-27 16:26:31 +02:00
Dirkjan Ochtman
388d357896 templater: separate template management and actual string processing 2009-04-06 15:09:54 +02:00
Matt Mackall
86dab18ddb config: getsource -> source 2009-04-26 16:50:43 -05:00
Matt Mackall
581beec905 templater: use new config parser
This gives us the ability to use includes and continuations
2009-04-26 16:50:43 -05:00
Dirkjan Ochtman
23935afdfe templatefilters: strings are iterators, but shouldn't be joined anyway 2009-04-06 16:26:57 +02:00
Dirkjan Ochtman
0b1a57839b templater: move stylemap function from hgweb to templater 2009-04-04 17:46:11 +02:00
Dirkjan Ochtman
d963dd0023 kill some trailing spaces 2008-11-27 16:07:13 +01:00
Brendan Cully
f4cee1477f templater: return data in increasing chunk sizes
Currently hgweb is not streaming its output -- it accumulates the
entire response before sending it. This patch restores streaming
behaviour. To avoid having to synchronously write many tiny fragments,
this patch also adds buffering to the template generator. Local
testing of a fetch of a 100,000 line file with wget produces a slight
slowdown overall (up from 6.5 seconds to 7.2 seconds), but instead of
waiting 6 seconds for headers to arrive, output begins immediately.
2008-11-21 15:51:40 -08:00
Brendan Cully
34868ca5be Allow hgweb to search for templates in more than one path.
This patch is constructed to make it easy for external extensions to
provide their own templates, by updating templater.path.
2008-10-17 11:34:31 -07:00
Dirkjan Ochtman
b79ad5315b templater: make a template a string-only iterator 2008-06-29 13:16:25 +02:00
Matt Mackall
1cca88367c hgweb: minor improvements for new web style
- make renamelink take a context
- pass current node to shortlog page rather than tip
- pass user/desc/date/rename to filediff
- improve template error reporting for foo%bar
2008-03-31 21:49:33 -05:00
Dirkjan Ochtman
c9f3b5991c give better error message on non-existent mapfile (issue813) 2008-03-21 12:05:01 +01:00
Matt Mackall
41e5c79455 templates: move filters to their own module
This eliminates just about all Mercurial dependencies in templater.py
2008-01-31 14:44:19 -06:00
Matt Mackall
a849fab9e4 templater: move email function to util 2008-01-31 14:44:19 -06:00
Matt Mackall
7b0d46c8cd templater: remove node import 2008-01-31 14:44:19 -06:00
Christian Ebert
5c18a69d2e Prefer i in d over d.has_key(i) 2008-01-20 14:39:25 +01:00
Robert Bachmann
ecb337b8cb Added support for the Atom syndication format 2007-08-30 16:42:17 +02:00
Alexis S. L. Carvalho
f9b8c79d22 hgweb: use lrwxrwxrwx as the permissions of a symlink 2007-07-03 03:06:40 -03:00
Matt Mackall
e293a4cd6d Merge with stable 2007-04-10 14:05:15 -05:00
TK Soh
424b1a050d minor typo fix in templater's docstring 2007-04-10 12:24:28 -05:00
Alexis S. L. Carvalho
d725a42fd8 merge with crew-stable 2006-12-16 02:51:16 -02:00
Alexis S. L. Carvalho
2726e242c0 templater.py: fix obfuscate 2006-12-16 02:21:46 -02:00
Matt Mackall
296d6a7cb8 Simplify i18n imports 2006-12-14 20:25:19 -06:00
Matt Mackall
f17a4e1934 Replace demandload with new demandimport 2006-12-13 13:27:09 -06:00
Matt Mackall
2fe74d8035 further simplify stringify 2006-11-15 15:51:58 -06:00
Matt Mackall
c50c09da0a templates: move changeset templating bits to cmdutils 2006-11-13 13:26:57 -06:00
Matt Mackall
6950309cf6 templater: changeset templater reorganization and optimizations 2006-11-13 13:26:57 -06:00
Matt Mackall
e0d8e4b198 templater: speed up changeset writes and stringify 2006-11-13 13:26:57 -06:00
Matt Mackall
9d8ded34e9 changeset_templater: remove changes arg 2006-11-13 13:26:57 -06:00
Matt Mackall
5c95b0e092 templater: simplify parsestring 2006-11-13 13:26:57 -06:00
Matt Mackall
c517977e84 template: fold template() into __call__, minor optimizations
- use non-grouping operator to avoid some extra processing
- avoid copying and updating defaults
- unnest main template body
- avoid returning extra empty string if format
2006-11-13 13:26:57 -06:00
Matt Mackall
6fe92f16bb templater: simplify cache and remove filter argument in __call__ 2006-11-13 13:26:57 -06:00
Matt Mackall
1b0a187e45 templater: simplify template function 2006-11-13 13:26:57 -06:00
Matt Mackall
aceb3199d6 templater: take cStringIO out of indent 2006-11-13 13:26:57 -06:00
Matt Mackall
3c62f52384 templater: remove cStringIO from stringify 2006-11-13 13:26:57 -06:00
Matt Mackall
00715e3a82 templater: remove cStringIO for fill 2006-11-13 13:26:57 -06:00
Matt Mackall
4fe7850499 templater: use str.decode in parse_string 2006-11-13 13:26:57 -06:00
Thomas Arendsen Hein
a67b9554ca Added extra changeset info to templater and map-cmdline.default. 2006-10-18 18:09:32 +02:00
Thomas Arendsen Hein
affb901953 Add new branch info to templater and use it in map-cmdline.default.
The template currently shows old (hg log -b style) branch tags, too,
but not in the same way as the built in changeset_printer.
2006-10-18 17:58:51 +02:00
Thomas Arendsen Hein
9e595ef83b templater: Better exception for errors in foo%bar formatting. 2006-10-11 20:53:02 +02:00
Brendan Cully
b5fb63f535 Templater expects an iterable copies variable (fixes notify). 2006-09-29 18:17:29 -07:00
Brendan Cully
d1c28696d4 Show copies in hg log.
The format is:
copies: destination (source)...
2006-09-29 13:01:19 -07:00
Vadim Gelfer
80d6f2f7c7 remove localrepository.changes.
use localrepository.status instead.
2006-08-12 16:40:12 -07:00
Brendan Cully
86244f1a64 Preserve multibyte UTF-8 characters when obfuscating.
This version uses the unicode 'replace' option, so non-UTF-8
encodings will still be mangled. Luckily, there aren't any
of those.
2006-07-21 02:36:17 +02:00
Brendan Cully
40833b0f4d templater.firstline should handle empty strings 2006-07-04 15:36:05 -07:00
Thomas Arendsen Hein
693aaef4a8 Merged WSGI fixes from http://hg.omnifarious.org/~hopper/webmerc/ 2006-06-30 21:36:45 +02:00
Benoit Boissinot
e2896f54f1 add a new template function 'hgdate'
'hgdate' turns a date into a cset timestamp as printed by 'hg export'
2006-06-30 10:15:18 +02:00
Eric Hopper
cbbc59972c Arrange for old copies of CGI scripts to still work. 2006-06-29 19:06:18 -07:00
Vadim Gelfer
9a0c813fdc use demandload more. 2006-06-20 23:58:21 -07:00
Vadim Gelfer
9a2b3a6303 make templater.stringio a tiny bit more use. 2006-05-04 14:45:57 -07:00
Vadim Gelfer
c40534f466 move stringio class from bugzilla extension into templater module. 2006-05-04 12:02:32 -07:00
Vadim Gelfer
b30de1431a make templater bit more flexible and efficient for external users. 2006-05-03 14:35:17 -07:00
Vadim Gelfer
f6f81d8d37 move changeset_templater into templater module. 2006-05-03 10:25:28 -07:00
Lee Cantey
da54525c97 Windows py2exe version didn't handle names given to templatepath() correctly 2006-03-24 10:33:18 -08:00
Vadim Gelfer
2e0f1be283 add changelog style to command line template.
to use, "hg log --style=changelog".  makes different output with no
flags, -q, -v, --debug.

templater module has new template filters for this.
email - committer email address
fill68 - refill text to 68 colums
fill76 - refill text to 76 colums
tabindent - prefix every not empty line with tab
shortdate - iso 8631 date, no time zone
stringify - turn template iterator into string
2006-03-21 23:29:21 -08:00
Shun-ichi Goto
9730814eb2 Duplicate cache when creating templater. 2006-03-18 09:51:25 -08:00
Vadim Gelfer
d737c6c2b3 fix template bug that made hgweb break.
problem found by Shun-ichi Goto <shunichi.goto@gmail.com>.
this fix tested with command template and hgweb templates.
2006-03-15 11:28:00 -08:00
Shun-ichi GOTO
e268844d18 Fix the py2exe template path problem (issue:152) again.
This patch is same with 1834:d15fc6ce9d87 which is leaved behind by
1897:d8f0b3f8f638.
2006-03-15 06:39:04 +01:00
Vadim Gelfer
49cb97855a make --style=compact look for map-cmdline.compact.
change name of key in map file from changelog to changeset.
rename command map files to start with map-cmdline.
rename ui.logmap to ui.style in hgrc.

now --style=foo does this:
tries to open foo as file.
tries as map-cmdline.foo in template path.
tries as foo in template path.
2006-03-04 15:15:18 -08:00
Vadim Gelfer
5de8501662 fix some things people wanted to be cleaner.
rename --map-file to --style.
no more -t alias for --template.
update docs.
rename template entry in map files to changelog.
if --verbose, use changelog_verbose if there, else changelog.
2006-03-04 12:40:10 -08:00
Vadim Gelfer
8f15689d73 hide some functions behind lambdas, so demandload is useful. 2006-02-28 07:24:54 -08:00
Vadim Gelfer
9640cecf04 add doc comments to template code. 2006-02-27 15:07:25 -08:00
Vadim Gelfer
1a7e33442f add iso date template filter. 2006-02-27 12:50:49 -08:00
Vadim Gelfer
21aff25a2a improve template errors when something is wrong. 2006-02-27 12:41:20 -08:00
Vadim Gelfer
94422c87f2 improve templating.
allow {foo} as well as #foo#.
add new functions for changeset authors.
2006-02-27 11:33:09 -08:00
Vadim Gelfer
957bd7ed50 make parsestring work with strings that do not have quotes. 2006-02-27 11:18:56 -08:00
Vadim Gelfer
e8d01e14ea use safer string parser for template engine. 2006-02-27 09:35:43 -08:00
Vadim Gelfer
41badccf28 move repeated work out of inner loops. 2006-02-27 09:15:59 -08:00
Vadim Gelfer
9f0cbe341c many small changes to templater.
get string code to parse escapes. uses eval now, should parse strings
itself soon.

let caller check if fragment is defined using "in".

make templatepath take optional file name.
2006-02-26 20:53:37 -08:00
Vadim Gelfer
1db1ed4f1f move hgweb.templatepath into templater 2006-02-26 13:09:26 -08:00
Vadim Gelfer
5b07616ef3 move hgweb template code out to templater 2006-02-26 12:59:28 -08:00