##// END OF EJS Templates
help: add a topic about some of the templating features
Alexander Solovyov -
r7677:6a0bc2dc default
parent child Browse files
Show More
@@ -248,4 +248,87 b' PYTHONPATH::'
248 [diff] section of your hgrc. You do not need to set this option when
248 [diff] section of your hgrc. You do not need to set this option when
249 importing diffs in this format or using them in the mq extension.
249 importing diffs in this format or using them in the mq extension.
250 ''')),
250 ''')),
251 (['templating'], _('Usage of templates'),
252 _(r'''
253 Mercurial allows you to customize output of commands through
254 templates. There is command line option for that and additionally
255 styles, which are simply precanned templates that someone wrote.
256
257 You can customize output for any "log-like" command, which currently
258 are: log, outgoing, incoming, tip, parents, heads and glog (if you have
259 graphlog extension enabled).
260
261 There is three styles packaged with Mercurial: default (which is
262 naturally what you see by default), compact and changelog. Usage:
263
264 > hg log -r1 --style changelog
265
266 Template is a piece of text, where parts marked with special syntax
267 are expanded, for example:
268
269 > hg log -r1 --template "{node}\n"
270 b56ce7b07c52de7d5fd79fb89701ea538af65746
271
272 Strings in curly brackets are called keywords and that's their
273 current list:
274
275 - author: String. The unmodified author of the changeset.
276 - branches: String. The name of the branch on which the changeset
277 was committed. Will be empty if the branch name was default.
278 - date: Date information. The date when the changeset was committed.
279 - desc: String. The text of the changeset description.
280 - files: List of strings. All files modified, added, or removed by
281 this changeset.
282 - file_adds: List of strings. Files added by this changeset.
283 - file_dels: List of strings. Files removed by this changeset.
284 - node: String. The changeset identification hash, as a 40-character
285 hexadecimal string.
286 - parents: List of strings. The parents of the changeset.
287 - rev: Integer. The repository-local changeset revision number.
288 - tags: List of strings. Any tags associated with the changeset.
289
290 But "date" keyword does not produce human-readable output, what
291 means that you should use a filter to process it. Filter is a
292 function which modifies the result of expanding a keyword and
293 Mercurial lets you specify a chain of filters:
294
295 > hg tip --template "{date|isodate}\n"
296 2008-08-21 18:22 +0000
297
298 List of filters:
299
300 - addbreaks: Any text. Add an XHTML "<br/>" tag before the end of
301 every line except the last.
302 - age: Date. Render the age of the date.
303 - basename: Any text. Treat the text as a path, and return the
304 basename. For example, "foo/bar/baz" becomes "baz".
305 - date: Date. Render a date in a Unix date command format, but with
306 timezone included: "Mon Sep 04 15:13:13 2006 0700".
307 - domain: Any text. Finds the first string that looks like an email
308 address, and extract just the domain component.
309 - email: Any text. Extract the first string that looks like an email
310 address.
311 - escape: Any text. Replace the special XML/XHTML characters "&",
312 "<" and ">" with XML entities.
313 - fill68: Any text. Wrap the text to fit in 68 columns.
314 - fill76: Any text. Wrap the text to fit in 76 columns.
315 - firstline: Any text. Yield the first line of text.
316 - hgdate: Date. Render the date as a pair of readable numbers:
317 "1157407993 25200".
318 - isodate: Date. Render the date in ISO 8601 format.
319 - obfuscate: Any text. Yield the input text rendered as a sequence
320 of XML entities.
321 - person: Any text. Yield the text before an email address.
322 - rfc822date: date keyword. Render a date using the same format used
323 in email headers.
324 - short: Changeset hash. Yield the short form of a changeset hash,
325 i.e. a 12-byte hexadecimal string.
326 - shortdate: Date. Render date like "2006-09-04".
327 - strip: Any text. Strip all leading and trailing whitespace.
328 - tabindent: Any text. Yield the text, with every line except the
329 first starting with a tab character.
330 - urlescape: Any text. Escape all "special" characters. For example,
331 foo bar becomes foo%20bar.
332 - user: Any text. Return the "user" portion of an email address.
333 ''')),
251 )
334 )
General Comments 0
You need to be logged in to leave comments. Login now