comparison paste/paste.29213 @ 7970:21888741373f

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