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