Show More
@@ -1,159 +1,160 b'' | |||||
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 | Four styles are packaged with Mercurial: default (the style used |
|
9 | Four styles are packaged with Mercurial: default (the style used | |
10 | when no explicit preference is passed), compact, changelog, |
|
10 | when no explicit preference is passed), compact, changelog, | |
11 | and xml. |
|
11 | and xml. | |
12 | Usage:: |
|
12 | Usage:: | |
13 |
|
13 | |||
14 | $ hg log -r1 --style changelog |
|
14 | $ hg log -r1 --style changelog | |
15 |
|
15 | |||
16 | A template is a piece of text, with markup to invoke variable |
|
16 | A template is a piece of text, with markup to invoke variable | |
17 | expansion:: |
|
17 | expansion:: | |
18 |
|
18 | |||
19 | $ hg log -r1 --template "{node}\n" |
|
19 | $ hg log -r1 --template "{node}\n" | |
20 | b56ce7b07c52de7d5fd79fb89701ea538af65746 |
|
20 | b56ce7b07c52de7d5fd79fb89701ea538af65746 | |
21 |
|
21 | |||
22 | Strings in curly braces are called keywords. The availability of |
|
22 | Strings in curly braces are called keywords. The availability of | |
23 | keywords depends on the exact context of the templater. These |
|
23 | keywords depends on the exact context of the templater. These | |
24 | keywords are usually available for templating a log-like command: |
|
24 | keywords are usually available for templating a log-like command: | |
25 |
|
25 | |||
26 | :author: String. The unmodified author of the changeset. |
|
26 | :author: String. The unmodified author of the changeset. | |
27 |
|
27 | |||
28 |
:branches: |
|
28 | :branches: List of strings. The name of the branch on which the | |
29 |
committed. Will be empty if the branch name was |
|
29 | changeset was committed. Will be empty if the branch name was | |
|
30 | default. | |||
30 |
|
31 | |||
31 | :children: List of strings. The children of the changeset. |
|
32 | :children: List of strings. The children of the changeset. | |
32 |
|
33 | |||
33 | :date: Date information. The date when the changeset was committed. |
|
34 | :date: Date information. The date when the changeset was committed. | |
34 |
|
35 | |||
35 | :desc: String. The text of the changeset description. |
|
36 | :desc: String. The text of the changeset description. | |
36 |
|
37 | |||
37 | :diffstat: String. Statistics of changes with the following format: |
|
38 | :diffstat: String. Statistics of changes with the following format: | |
38 | "modified files: +added/-removed lines" |
|
39 | "modified files: +added/-removed lines" | |
39 |
|
40 | |||
40 | :files: List of strings. All files modified, added, or removed by this |
|
41 | :files: List of strings. All files modified, added, or removed by this | |
41 | changeset. |
|
42 | changeset. | |
42 |
|
43 | |||
43 | :file_adds: List of strings. Files added by this changeset. |
|
44 | :file_adds: List of strings. Files added by this changeset. | |
44 |
|
45 | |||
45 | :file_copies: List of strings. Files copied in this changeset with |
|
46 | :file_copies: List of strings. Files copied in this changeset with | |
46 | their sources. |
|
47 | their sources. | |
47 |
|
48 | |||
48 | :file_copies_switch: List of strings. Like "file_copies" but displayed |
|
49 | :file_copies_switch: List of strings. Like "file_copies" but displayed | |
49 | only if the --copied switch is set. |
|
50 | only if the --copied switch is set. | |
50 |
|
51 | |||
51 | :file_mods: List of strings. Files modified by this changeset. |
|
52 | :file_mods: List of strings. Files modified by this changeset. | |
52 |
|
53 | |||
53 | :file_dels: List of strings. Files removed by this changeset. |
|
54 | :file_dels: List of strings. Files removed by this changeset. | |
54 |
|
55 | |||
55 | :node: String. The changeset identification hash, as a 40 hexadecimal |
|
56 | :node: String. The changeset identification hash, as a 40 hexadecimal | |
56 | digit string. |
|
57 | digit string. | |
57 |
|
58 | |||
58 | :parents: List of strings. The parents of the changeset. |
|
59 | :parents: List of strings. The parents of the changeset. | |
59 |
|
60 | |||
60 | :rev: Integer. The repository-local changeset revision number. |
|
61 | :rev: Integer. The repository-local changeset revision number. | |
61 |
|
62 | |||
62 | :tags: List of strings. Any tags associated with the changeset. |
|
63 | :tags: List of strings. Any tags associated with the changeset. | |
63 |
|
64 | |||
64 | :latesttag: String. Most recent global tag in the ancestors of this |
|
65 | :latesttag: String. Most recent global tag in the ancestors of this | |
65 | changeset. |
|
66 | changeset. | |
66 |
|
67 | |||
67 | :latesttagdistance: Integer. Longest path to the latest tag. |
|
68 | :latesttagdistance: Integer. Longest path to the latest tag. | |
68 |
|
69 | |||
69 | The "date" keyword does not produce human-readable output. If you |
|
70 | The "date" keyword does not produce human-readable output. If you | |
70 | want to use a date in your output, you can use a filter to process |
|
71 | want to use a date in your output, you can use a filter to process | |
71 | it. Filters are functions which return a string based on the input |
|
72 | it. Filters are functions which return a string based on the input | |
72 | variable. Be sure to use the stringify filter first when you're |
|
73 | variable. Be sure to use the stringify filter first when you're | |
73 | applying a string-input filter to a list-like input variable. |
|
74 | applying a string-input filter to a list-like input variable. | |
74 | You can also use a chain of filters to get the desired output:: |
|
75 | You can also use a chain of filters to get the desired output:: | |
75 |
|
76 | |||
76 | $ hg tip --template "{date|isodate}\n" |
|
77 | $ hg tip --template "{date|isodate}\n" | |
77 | 2008-08-21 18:22 +0000 |
|
78 | 2008-08-21 18:22 +0000 | |
78 |
|
79 | |||
79 | List of filters: |
|
80 | List of filters: | |
80 |
|
81 | |||
81 | :addbreaks: Any text. Add an XHTML "<br />" tag before the end of |
|
82 | :addbreaks: Any text. Add an XHTML "<br />" tag before the end of | |
82 | every line except the last. |
|
83 | every line except the last. | |
83 |
|
84 | |||
84 | :age: Date. Returns a human-readable date/time difference between the |
|
85 | :age: Date. Returns a human-readable date/time difference between the | |
85 | given date/time and the current date/time. |
|
86 | given date/time and the current date/time. | |
86 |
|
87 | |||
87 | :basename: Any text. Treats the text as a path, and returns the last |
|
88 | :basename: Any text. Treats the text as a path, and returns the last | |
88 | component of the path after splitting by the path separator |
|
89 | component of the path after splitting by the path separator | |
89 | (ignoring trailing separators). For example, "foo/bar/baz" becomes |
|
90 | (ignoring trailing separators). For example, "foo/bar/baz" becomes | |
90 | "baz" and "foo/bar//" becomes "bar". |
|
91 | "baz" and "foo/bar//" becomes "bar". | |
91 |
|
92 | |||
92 | :stripdir: Treat the text as path and strip a directory level, if |
|
93 | :stripdir: Treat the text as path and strip a directory level, if | |
93 | possible. For example, "foo" and "foo/bar" becomes "foo". |
|
94 | possible. For example, "foo" and "foo/bar" becomes "foo". | |
94 |
|
95 | |||
95 | :date: Date. Returns a date in a Unix date format, including the |
|
96 | :date: Date. Returns a date in a Unix date format, including the | |
96 | timezone: "Mon Sep 04 15:13:13 2006 0700". |
|
97 | timezone: "Mon Sep 04 15:13:13 2006 0700". | |
97 |
|
98 | |||
98 | :domain: Any text. Finds the first string that looks like an email |
|
99 | :domain: Any text. Finds the first string that looks like an email | |
99 | address, and extracts just the domain component. Example: ``User |
|
100 | address, and extracts just the domain component. Example: ``User | |
100 | <user@example.com>`` becomes ``example.com``. |
|
101 | <user@example.com>`` becomes ``example.com``. | |
101 |
|
102 | |||
102 | :email: Any text. Extracts the first string that looks like an email |
|
103 | :email: Any text. Extracts the first string that looks like an email | |
103 | address. Example: ``User <user@example.com>`` becomes |
|
104 | address. Example: ``User <user@example.com>`` becomes | |
104 | ``user@example.com``. |
|
105 | ``user@example.com``. | |
105 |
|
106 | |||
106 | :escape: Any text. Replaces the special XML/XHTML characters "&", "<" |
|
107 | :escape: Any text. Replaces the special XML/XHTML characters "&", "<" | |
107 | and ">" with XML entities. |
|
108 | and ">" with XML entities. | |
108 |
|
109 | |||
109 | :hex: Any text. Convert a binary Mercurial node identifier into |
|
110 | :hex: Any text. Convert a binary Mercurial node identifier into | |
110 | its long hexadecimal representation. |
|
111 | its long hexadecimal representation. | |
111 |
|
112 | |||
112 | :fill68: Any text. Wraps the text to fit in 68 columns. |
|
113 | :fill68: Any text. Wraps the text to fit in 68 columns. | |
113 |
|
114 | |||
114 | :fill76: Any text. Wraps the text to fit in 76 columns. |
|
115 | :fill76: Any text. Wraps the text to fit in 76 columns. | |
115 |
|
116 | |||
116 | :firstline: Any text. Returns the first line of text. |
|
117 | :firstline: Any text. Returns the first line of text. | |
117 |
|
118 | |||
118 | :nonempty: Any text. Returns '(none)' if the string is empty. |
|
119 | :nonempty: Any text. Returns '(none)' if the string is empty. | |
119 |
|
120 | |||
120 | :hgdate: Date. Returns the date as a pair of numbers: "1157407993 |
|
121 | :hgdate: Date. Returns the date as a pair of numbers: "1157407993 | |
121 | 25200" (Unix timestamp, timezone offset). |
|
122 | 25200" (Unix timestamp, timezone offset). | |
122 |
|
123 | |||
123 | :isodate: Date. Returns the date in ISO 8601 format: "2009-08-18 13:00 |
|
124 | :isodate: Date. Returns the date in ISO 8601 format: "2009-08-18 13:00 | |
124 | +0200". |
|
125 | +0200". | |
125 |
|
126 | |||
126 | :isodatesec: Date. Returns the date in ISO 8601 format, including |
|
127 | :isodatesec: Date. Returns the date in ISO 8601 format, including | |
127 | seconds: "2009-08-18 13:00:13 +0200". See also the rfc3339date |
|
128 | seconds: "2009-08-18 13:00:13 +0200". See also the rfc3339date | |
128 | filter. |
|
129 | filter. | |
129 |
|
130 | |||
130 | :localdate: Date. Converts a date to local date. |
|
131 | :localdate: Date. Converts a date to local date. | |
131 |
|
132 | |||
132 | :obfuscate: Any text. Returns the input text rendered as a sequence of |
|
133 | :obfuscate: Any text. Returns the input text rendered as a sequence of | |
133 | XML entities. |
|
134 | XML entities. | |
134 |
|
135 | |||
135 | :person: Any text. Returns the text before an email address. |
|
136 | :person: Any text. Returns the text before an email address. | |
136 |
|
137 | |||
137 | :rfc822date: Date. Returns a date using the same format used in email |
|
138 | :rfc822date: Date. Returns a date using the same format used in email | |
138 | headers: "Tue, 18 Aug 2009 13:00:13 +0200". |
|
139 | headers: "Tue, 18 Aug 2009 13:00:13 +0200". | |
139 |
|
140 | |||
140 | :rfc3339date: Date. Returns a date using the Internet date format |
|
141 | :rfc3339date: Date. Returns a date using the Internet date format | |
141 | specified in RFC 3339: "2009-08-18T13:00:13+02:00". |
|
142 | specified in RFC 3339: "2009-08-18T13:00:13+02:00". | |
142 |
|
143 | |||
143 | :short: Changeset hash. Returns the short form of a changeset hash, |
|
144 | :short: Changeset hash. Returns the short form of a changeset hash, | |
144 | i.e. a 12 hexadecimal digit string. |
|
145 | i.e. a 12 hexadecimal digit string. | |
145 |
|
146 | |||
146 | :shortdate: Date. Returns a date like "2006-09-18". |
|
147 | :shortdate: Date. Returns a date like "2006-09-18". | |
147 |
|
148 | |||
148 | :stringify: Any type. Turns the value into text by converting values into |
|
149 | :stringify: Any type. Turns the value into text by converting values into | |
149 | text and concatenating them. |
|
150 | text and concatenating them. | |
150 |
|
151 | |||
151 | :strip: Any text. Strips all leading and trailing whitespace. |
|
152 | :strip: Any text. Strips all leading and trailing whitespace. | |
152 |
|
153 | |||
153 | :tabindent: Any text. Returns the text, with every line except the |
|
154 | :tabindent: Any text. Returns the text, with every line except the | |
154 | first starting with a tab character. |
|
155 | first starting with a tab character. | |
155 |
|
156 | |||
156 | :urlescape: Any text. Escapes all "special" characters. For example, |
|
157 | :urlescape: Any text. Escapes all "special" characters. For example, | |
157 | "foo bar" becomes "foo%20bar". |
|
158 | "foo bar" becomes "foo%20bar". | |
158 |
|
159 | |||
159 | :user: Any text. Returns the user portion of an email address. |
|
160 | :user: Any text. Returns the user portion of an email address. |
General Comments 0
You need to be logged in to leave comments.
Login now