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