comparison help/templates.txt @ 9540:cad36e496640

help: un-indent help topics The help topics are reused in the HTML documentation, and there it looks odd that whole sections are indented. We now only indent it for output on the terminal.
author Martin Geisler <mg@lazybytes.net>
date Sun, 04 Oct 2009 12:18:43 +0200
parents c904e76e3834
children 90e968899c72
comparison
equal deleted inserted replaced
9539:c904e76e3834 9540:cad36e496640
1 Mercurial allows you to customize output of commands through 1 Mercurial allows you to customize output of commands through
2 templates. You can either pass in a template from the command 2 templates. You can either pass in a template from the command
3 line, via the --template option, or select an existing 3 line, via the --template option, or select an existing
4 template-style (--style). 4 template-style (--style).
5 5
6 You can customize output for any "log-like" command: log, 6 You can customize output for any "log-like" command: log,
7 outgoing, incoming, tip, parents, heads and glog. 7 outgoing, incoming, tip, parents, heads and glog.
8 8
9 Three styles are packaged with Mercurial: default (the style used 9 Three styles are packaged with Mercurial: default (the style used
10 when no explicit preference is passed), compact and changelog. 10 when no explicit preference is passed), compact and changelog.
11 Usage:: 11 Usage::
12 12
13 $ hg log -r1 --style changelog 13 $ hg log -r1 --style changelog
14 14
15 A template is a piece of text, with markup to invoke variable 15 A template is a piece of text, with markup to invoke variable
16 expansion:: 16 expansion::
17 17
18 $ hg log -r1 --template "{node}\n" 18 $ hg log -r1 --template "{node}\n"
19 b56ce7b07c52de7d5fd79fb89701ea538af65746 19 b56ce7b07c52de7d5fd79fb89701ea538af65746
20 20
21 Strings in curly braces are called keywords. The availability of 21 Strings in curly braces are called keywords. The availability of
22 keywords depends on the exact context of the templater. These 22 keywords depends on the exact context of the templater. These
23 keywords are usually available for templating a log-like command: 23 keywords are usually available for templating a log-like command:
24 24
25 :author: String. The unmodified author of the changeset. 25 :author: String. The unmodified author of the changeset.
26 :branches: String. The name of the branch on which the changeset 26 :branches: String. The name of the branch on which the changeset
27 was committed. Will be empty if the branch name was 27 was committed. Will be empty if the branch name was
28 default. 28 default.
29 :date: Date information. The date when the changeset was 29 :date: Date information. The date when the changeset was
30 committed. 30 committed.
31 :desc: String. The text of the changeset description. 31 :desc: String. The text of the changeset description.
32 :diffstat: String. Statistics of changes with the following 32 :diffstat: String. Statistics of changes with the following
33 format: "modified files: +added/-removed lines" 33 format: "modified files: +added/-removed lines"
34 :files: List of strings. All files modified, added, or removed 34 :files: List of strings. All files modified, added, or removed
35 by this changeset. 35 by this changeset.
36 :file_adds: List of strings. Files added by this changeset. 36 :file_adds: List of strings. Files added by this changeset.
37 :file_mods: List of strings. Files modified by this changeset. 37 :file_mods: List of strings. Files modified by this changeset.
38 :file_dels: List of strings. Files removed by this changeset. 38 :file_dels: List of strings. Files removed by this changeset.
39 :node: String. The changeset identification hash, as a 39 :node: String. The changeset identification hash, as a
40 40-character hexadecimal string. 40 40-character hexadecimal string.
41 :parents: List of strings. The parents of the changeset. 41 :parents: List of strings. The parents of the changeset.
42 :rev: Integer. The repository-local changeset revision 42 :rev: Integer. The repository-local changeset revision
43 number. 43 number.
44 :tags: List of strings. Any tags associated with the 44 :tags: List of strings. Any tags associated with the
45 changeset. 45 changeset.
46 :latesttag: String. Most recent global tag in the ancestors of this 46 :latesttag: String. Most recent global tag in the ancestors of this
47 changeset. 47 changeset.
48 :latesttagdistance: Integer. Longest path to the latest tag. 48 :latesttagdistance: Integer. Longest path to the latest tag.
49 49
50 The "date" keyword does not produce human-readable output. If you 50 The "date" keyword does not produce human-readable output. If you
51 want to use a date in your output, you can use a filter to process 51 want to use a date in your output, you can use a filter to process
52 it. Filters are functions which return a string based on the input 52 it. Filters are functions which return a string based on the input
53 variable. You can also use a chain of filters to get the desired 53 variable. You can also use a chain of filters to get the desired
54 output:: 54 output::
55 55
56 $ hg tip --template "{date|isodate}\n" 56 $ hg tip --template "{date|isodate}\n"
57 2008-08-21 18:22 +0000 57 2008-08-21 18:22 +0000
58 58
59 List of filters: 59 List of filters:
60 60
61 :addbreaks: Any text. Add an XHTML "<br />" tag before the end of 61 :addbreaks: Any text. Add an XHTML "<br />" tag before the end of
62 every line except the last. 62 every line except the last.
63 :age: Date. Returns a human-readable date/time difference 63 :age: Date. Returns a human-readable date/time difference
64 between the given date/time and the current 64 between the given date/time and the current
65 date/time. 65 date/time.
66 :basename: Any text. Treats the text as a path, and returns the 66 :basename: Any text. Treats the text as a path, and returns the
67 last component of the path after splitting by the 67 last component of the path after splitting by the
68 path separator (ignoring trailing separators). For 68 path separator (ignoring trailing separators). For
69 example, "foo/bar/baz" becomes "baz" and "foo/bar//" 69 example, "foo/bar/baz" becomes "baz" and "foo/bar//"
70 becomes "bar". 70 becomes "bar".
71 :stripdir: Treat the text as path and strip a directory level, 71 :stripdir: Treat the text as path and strip a directory level,
72 if possible. For example, "foo" and "foo/bar" becomes 72 if possible. For example, "foo" and "foo/bar" becomes
73 "foo". 73 "foo".
74 :date: Date. Returns a date in a Unix date format, including 74 :date: Date. Returns a date in a Unix date format, including
75 the timezone: "Mon Sep 04 15:13:13 2006 0700". 75 the timezone: "Mon Sep 04 15:13:13 2006 0700".
76 :domain: Any text. Finds the first string that looks like an 76 :domain: Any text. Finds the first string that looks like an
77 email address, and extracts just the domain 77 email address, and extracts just the domain
78 component. Example: 'User <user@example.com>' becomes 78 component. Example: 'User <user@example.com>' becomes
79 'example.com'. 79 'example.com'.
80 :email: Any text. Extracts the first string that looks like 80 :email: Any text. Extracts the first string that looks like
81 an email address. Example: 'User <user@example.com>' 81 an email address. Example: 'User <user@example.com>'
82 becomes 'user@example.com'. 82 becomes 'user@example.com'.
83 :escape: Any text. Replaces the special XML/XHTML characters 83 :escape: Any text. Replaces the special XML/XHTML characters
84 "&", "<" and ">" with XML entities. 84 "&", "<" and ">" with XML entities.
85 :fill68: Any text. Wraps the text to fit in 68 columns. 85 :fill68: Any text. Wraps the text to fit in 68 columns.
86 :fill76: Any text. Wraps the text to fit in 76 columns. 86 :fill76: Any text. Wraps the text to fit in 76 columns.
87 :firstline: Any text. Returns the first line of text. 87 :firstline: Any text. Returns the first line of text.
88 :nonempty: Any text. Returns '(none)' if the string is empty. 88 :nonempty: Any text. Returns '(none)' if the string is empty.
89 :hgdate: Date. Returns the date as a pair of numbers: 89 :hgdate: Date. Returns the date as a pair of numbers:
90 "1157407993 25200" (Unix timestamp, timezone offset). 90 "1157407993 25200" (Unix timestamp, timezone offset).
91 :isodate: Date. Returns the date in ISO 8601 format: 91 :isodate: Date. Returns the date in ISO 8601 format:
92 "2009-08-18 13:00 +0200". 92 "2009-08-18 13:00 +0200".
93 :isodatesec: Date. Returns the date in ISO 8601 format, including 93 :isodatesec: Date. Returns the date in ISO 8601 format, including
94 seconds: "2009-08-18 13:00:13 +0200". See also the 94 seconds: "2009-08-18 13:00:13 +0200". See also the
95 rfc3339date filter. 95 rfc3339date filter.
96 :localdate: Date. Converts a date to local date. 96 :localdate: Date. Converts a date to local date.
97 :obfuscate: Any text. Returns the input text rendered as a 97 :obfuscate: Any text. Returns the input text rendered as a
98 sequence of XML entities. 98 sequence of XML entities.
99 :person: Any text. Returns the text before an email address. 99 :person: Any text. Returns the text before an email address.
100 :rfc822date: Date. Returns a date using the same format used in 100 :rfc822date: Date. Returns a date using the same format used in
101 email headers: "Tue, 18 Aug 2009 13:00:13 +0200". 101 email headers: "Tue, 18 Aug 2009 13:00:13 +0200".
102 :rfc3339date: Date. Returns a date using the Internet date format 102 :rfc3339date: Date. Returns a date using the Internet date format
103 specified in RFC 3339: "2009-08-18T13:00:13+02:00". 103 specified in RFC 3339: "2009-08-18T13:00:13+02:00".
104 :short: Changeset hash. Returns the short form of a changeset 104 :short: Changeset hash. Returns the short form of a changeset
105 hash, i.e. a 12-byte hexadecimal string. 105 hash, i.e. a 12-byte hexadecimal string.
106 :shortdate: Date. Returns a date like "2006-09-18". 106 :shortdate: Date. Returns a date like "2006-09-18".
107 :strip: Any text. Strips all leading and trailing whitespace. 107 :strip: Any text. Strips all leading and trailing whitespace.
108 :tabindent: Any text. Returns the text, with every line except 108 :tabindent: Any text. Returns the text, with every line except
109 the first starting with a tab character. 109 the first starting with a tab character.
110 :urlescape: Any text. Escapes all "special" characters. For 110 :urlescape: Any text. Escapes all "special" characters. For
111 example, "foo bar" becomes "foo%20bar". 111 example, "foo bar" becomes "foo%20bar".
112 :user: Any text. Returns the user portion of an email 112 :user: Any text. Returns the user portion of an email
113 address. 113 address.