Show More
@@ -1,214 +1,215 | |||
|
1 | 1 | Mercurial allows you to customize output of commands through |
|
2 | 2 | templates. You can either pass in a template or select an existing |
|
3 | 3 | template-style from the command line, via the --template option. |
|
4 | 4 | |
|
5 | 5 | You can customize output for any "log-like" command: log, |
|
6 | 6 | outgoing, incoming, tip, parents, and heads. |
|
7 | 7 | |
|
8 | 8 | Some built-in styles are packaged with Mercurial. These can be listed |
|
9 | 9 | with :hg:`log --template list`. Example usage:: |
|
10 | 10 | |
|
11 | 11 | $ hg log -r1.0::1.1 --template changelog |
|
12 | 12 | |
|
13 | 13 | A template is a piece of text, with markup to invoke variable |
|
14 | 14 | expansion:: |
|
15 | 15 | |
|
16 | 16 | $ hg log -r1 --template "{node}\n" |
|
17 | 17 | b56ce7b07c52de7d5fd79fb89701ea538af65746 |
|
18 | 18 | |
|
19 | 19 | Keywords |
|
20 | 20 | ======== |
|
21 | 21 | |
|
22 | 22 | Strings in curly braces are called keywords. The availability of |
|
23 | 23 | keywords depends on the exact context of the templater. These |
|
24 | 24 | keywords are usually available for templating a log-like command: |
|
25 | 25 | |
|
26 | 26 | .. keywordsmarker |
|
27 | 27 | |
|
28 | 28 | The "date" keyword does not produce human-readable output. If you |
|
29 | 29 | want to use a date in your output, you can use a filter to process |
|
30 | 30 | it. Filters are functions which return a string based on the input |
|
31 | 31 | variable. Be sure to use the stringify filter first when you're |
|
32 | 32 | applying a string-input filter to a list-like input variable. |
|
33 | 33 | You can also use a chain of filters to get the desired output:: |
|
34 | 34 | |
|
35 | 35 | $ hg tip --template "{date|isodate}\n" |
|
36 | 36 | 2008-08-21 18:22 +0000 |
|
37 | 37 | |
|
38 | 38 | Filters |
|
39 | 39 | ======= |
|
40 | 40 | |
|
41 | 41 | List of filters: |
|
42 | 42 | |
|
43 | 43 | .. filtersmarker |
|
44 | 44 | |
|
45 | 45 | Note that a filter is nothing more than a function call, i.e. |
|
46 | 46 | ``expr|filter`` is equivalent to ``filter(expr)``. |
|
47 | 47 | |
|
48 | 48 | Functions |
|
49 | 49 | ========= |
|
50 | 50 | |
|
51 | 51 | In addition to filters, there are some basic built-in functions: |
|
52 | 52 | |
|
53 | 53 | .. functionsmarker |
|
54 | 54 | |
|
55 | 55 | Operators |
|
56 | 56 | ========= |
|
57 | 57 | |
|
58 | 58 | We provide a limited set of infix arithmetic operations on integers:: |
|
59 | 59 | |
|
60 | 60 | + for addition |
|
61 | 61 | - for subtraction |
|
62 | 62 | * for multiplication |
|
63 | 63 | / for floor division (division rounded to integer nearest -infinity) |
|
64 | 64 | |
|
65 | 65 | Division fulfills the law x = x / y + mod(x, y). |
|
66 | 66 | |
|
67 | 67 | Also, for any expression that returns a list, there is a list operator:: |
|
68 | 68 | |
|
69 | 69 | expr % "{template}" |
|
70 | 70 | |
|
71 | 71 | As seen in the above example, ``{template}`` is interpreted as a template. |
|
72 | 72 | To prevent it from being interpreted, you can use an escape character ``\{`` |
|
73 | 73 | or a raw string prefix, ``r'...'``. |
|
74 | 74 | |
|
75 | 75 | The dot operator can be used as a shorthand for accessing a sub item: |
|
76 | 76 | |
|
77 | 77 | - ``expr.member`` is roughly equivalent to ``expr % "{member}"`` if ``expr`` |
|
78 | 78 | returns a non-list/dict. The returned value is not stringified. |
|
79 | - ``dict.key`` is identical to ``get(dict, "key")``. | |
|
79 | 80 | |
|
80 | 81 | Aliases |
|
81 | 82 | ======= |
|
82 | 83 | |
|
83 | 84 | New keywords and functions can be defined in the ``templatealias`` section of |
|
84 | 85 | a Mercurial configuration file:: |
|
85 | 86 | |
|
86 | 87 | <alias> = <definition> |
|
87 | 88 | |
|
88 | 89 | Arguments of the form `a1`, `a2`, etc. are substituted from the alias into |
|
89 | 90 | the definition. |
|
90 | 91 | |
|
91 | 92 | For example, |
|
92 | 93 | |
|
93 | 94 | :: |
|
94 | 95 | |
|
95 | 96 | [templatealias] |
|
96 | 97 | r = rev |
|
97 | 98 | rn = "{r}:{node|short}" |
|
98 | 99 | leftpad(s, w) = pad(s, w, ' ', True) |
|
99 | 100 | |
|
100 | 101 | defines two symbol aliases, ``r`` and ``rn``, and a function alias |
|
101 | 102 | ``leftpad()``. |
|
102 | 103 | |
|
103 | 104 | It's also possible to specify complete template strings, using the |
|
104 | 105 | ``templates`` section. The syntax used is the general template string syntax. |
|
105 | 106 | |
|
106 | 107 | For example, |
|
107 | 108 | |
|
108 | 109 | :: |
|
109 | 110 | |
|
110 | 111 | [templates] |
|
111 | 112 | nodedate = "{node|short}: {date(date, "%Y-%m-%d")}\n" |
|
112 | 113 | |
|
113 | 114 | defines a template, ``nodedate``, which can be called like:: |
|
114 | 115 | |
|
115 | 116 | $ hg log -r . -Tnodedate |
|
116 | 117 | |
|
117 | 118 | A template defined in ``templates`` section can also be referenced from |
|
118 | 119 | another template:: |
|
119 | 120 | |
|
120 | 121 | $ hg log -r . -T "{rev} {nodedate}" |
|
121 | 122 | |
|
122 | 123 | but be aware that the keywords cannot be overridden by templates. For example, |
|
123 | 124 | a template defined as ``templates.rev`` cannot be referenced as ``{rev}``. |
|
124 | 125 | |
|
125 | 126 | A template defined in ``templates`` section may have sub templates which |
|
126 | 127 | are inserted before/after/between items:: |
|
127 | 128 | |
|
128 | 129 | [templates] |
|
129 | 130 | myjson = ' {dict(rev, node|short)|json}' |
|
130 | 131 | myjson:docheader = '\{\n' |
|
131 | 132 | myjson:docfooter = '\n}\n' |
|
132 | 133 | myjson:separator = ',\n' |
|
133 | 134 | |
|
134 | 135 | Examples |
|
135 | 136 | ======== |
|
136 | 137 | |
|
137 | 138 | Some sample command line templates: |
|
138 | 139 | |
|
139 | 140 | - Format lists, e.g. files:: |
|
140 | 141 | |
|
141 | 142 | $ hg log -r 0 --template "files:\n{files % ' {file}\n'}" |
|
142 | 143 | |
|
143 | 144 | - Join the list of files with a ", ":: |
|
144 | 145 | |
|
145 | 146 | $ hg log -r 0 --template "files: {join(files, ', ')}\n" |
|
146 | 147 | |
|
147 | 148 | - Join the list of files ending with ".py" with a ", ":: |
|
148 | 149 | |
|
149 | 150 | $ hg log -r 0 --template "pythonfiles: {join(files('**.py'), ', ')}\n" |
|
150 | 151 | |
|
151 | 152 | - Separate non-empty arguments by a " ":: |
|
152 | 153 | |
|
153 | 154 | $ hg log -r 0 --template "{separate(' ', node, bookmarks, tags}\n" |
|
154 | 155 | |
|
155 | 156 | - Modify each line of a commit description:: |
|
156 | 157 | |
|
157 | 158 | $ hg log --template "{splitlines(desc) % '**** {line}\n'}" |
|
158 | 159 | |
|
159 | 160 | - Format date:: |
|
160 | 161 | |
|
161 | 162 | $ hg log -r 0 --template "{date(date, '%Y')}\n" |
|
162 | 163 | |
|
163 | 164 | - Display date in UTC:: |
|
164 | 165 | |
|
165 | 166 | $ hg log -r 0 --template "{localdate(date, 'UTC')|date}\n" |
|
166 | 167 | |
|
167 | 168 | - Output the description set to a fill-width of 30:: |
|
168 | 169 | |
|
169 | 170 | $ hg log -r 0 --template "{fill(desc, 30)}" |
|
170 | 171 | |
|
171 | 172 | - Use a conditional to test for the default branch:: |
|
172 | 173 | |
|
173 | 174 | $ hg log -r 0 --template "{ifeq(branch, 'default', 'on the main branch', |
|
174 | 175 | 'on branch {branch}')}\n" |
|
175 | 176 | |
|
176 | 177 | - Append a newline if not empty:: |
|
177 | 178 | |
|
178 | 179 | $ hg tip --template "{if(author, '{author}\n')}" |
|
179 | 180 | |
|
180 | 181 | - Label the output for use with the color extension:: |
|
181 | 182 | |
|
182 | 183 | $ hg log -r 0 --template "{label('changeset.{phase}', node|short)}\n" |
|
183 | 184 | |
|
184 | 185 | - Invert the firstline filter, i.e. everything but the first line:: |
|
185 | 186 | |
|
186 | 187 | $ hg log -r 0 --template "{sub(r'^.*\n?\n?', '', desc)}\n" |
|
187 | 188 | |
|
188 | 189 | - Display the contents of the 'extra' field, one per line:: |
|
189 | 190 | |
|
190 | 191 | $ hg log -r 0 --template "{join(extras, '\n')}\n" |
|
191 | 192 | |
|
192 | 193 | - Mark the active bookmark with '*':: |
|
193 | 194 | |
|
194 | 195 | $ hg log --template "{bookmarks % '{bookmark}{ifeq(bookmark, active, '*')} '}\n" |
|
195 | 196 | |
|
196 | 197 | - Find the previous release candidate tag, the distance and changes since the tag:: |
|
197 | 198 | |
|
198 | 199 | $ hg log -r . --template "{latesttag('re:^.*-rc$') % '{tag}, {changes}, {distance}'}\n" |
|
199 | 200 | |
|
200 | 201 | - Mark the working copy parent with '@':: |
|
201 | 202 | |
|
202 | 203 | $ hg log --template "{ifcontains(rev, revset('.'), '@')}\n" |
|
203 | 204 | |
|
204 | 205 | - Show details of parent revisions:: |
|
205 | 206 | |
|
206 | 207 | $ hg log --template "{revset('parents(%d)', rev) % '{desc|firstline}\n'}" |
|
207 | 208 | |
|
208 | 209 | - Show only commit descriptions that start with "template":: |
|
209 | 210 | |
|
210 | 211 | $ hg log --template "{startswith('template', firstline(desc))}\n" |
|
211 | 212 | |
|
212 | 213 | - Print the first word of each line of a commit message:: |
|
213 | 214 | |
|
214 | 215 | $ hg log --template "{word(0, desc)}\n" |
@@ -1,1495 +1,1499 | |||
|
1 | 1 | # templater.py - template expansion for output |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import, print_function |
|
9 | 9 | |
|
10 | 10 | import os |
|
11 | 11 | import re |
|
12 | 12 | import types |
|
13 | 13 | |
|
14 | 14 | from .i18n import _ |
|
15 | 15 | from . import ( |
|
16 | 16 | color, |
|
17 | 17 | config, |
|
18 | 18 | encoding, |
|
19 | 19 | error, |
|
20 | 20 | minirst, |
|
21 | 21 | obsutil, |
|
22 | 22 | parser, |
|
23 | 23 | pycompat, |
|
24 | 24 | registrar, |
|
25 | 25 | revset as revsetmod, |
|
26 | 26 | revsetlang, |
|
27 | 27 | scmutil, |
|
28 | 28 | templatefilters, |
|
29 | 29 | templatekw, |
|
30 | 30 | util, |
|
31 | 31 | ) |
|
32 | 32 | |
|
33 | 33 | # template parsing |
|
34 | 34 | |
|
35 | 35 | elements = { |
|
36 | 36 | # token-type: binding-strength, primary, prefix, infix, suffix |
|
37 | 37 | "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None), |
|
38 | 38 | ".": (18, None, None, (".", 18), None), |
|
39 | 39 | "%": (15, None, None, ("%", 15), None), |
|
40 | 40 | "|": (15, None, None, ("|", 15), None), |
|
41 | 41 | "*": (5, None, None, ("*", 5), None), |
|
42 | 42 | "/": (5, None, None, ("/", 5), None), |
|
43 | 43 | "+": (4, None, None, ("+", 4), None), |
|
44 | 44 | "-": (4, None, ("negate", 19), ("-", 4), None), |
|
45 | 45 | "=": (3, None, None, ("keyvalue", 3), None), |
|
46 | 46 | ",": (2, None, None, ("list", 2), None), |
|
47 | 47 | ")": (0, None, None, None, None), |
|
48 | 48 | "integer": (0, "integer", None, None, None), |
|
49 | 49 | "symbol": (0, "symbol", None, None, None), |
|
50 | 50 | "string": (0, "string", None, None, None), |
|
51 | 51 | "template": (0, "template", None, None, None), |
|
52 | 52 | "end": (0, None, None, None, None), |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | def tokenize(program, start, end, term=None): |
|
56 | 56 | """Parse a template expression into a stream of tokens, which must end |
|
57 | 57 | with term if specified""" |
|
58 | 58 | pos = start |
|
59 | 59 | program = pycompat.bytestr(program) |
|
60 | 60 | while pos < end: |
|
61 | 61 | c = program[pos] |
|
62 | 62 | if c.isspace(): # skip inter-token whitespace |
|
63 | 63 | pass |
|
64 | 64 | elif c in "(=,).%|+-*/": # handle simple operators |
|
65 | 65 | yield (c, None, pos) |
|
66 | 66 | elif c in '"\'': # handle quoted templates |
|
67 | 67 | s = pos + 1 |
|
68 | 68 | data, pos = _parsetemplate(program, s, end, c) |
|
69 | 69 | yield ('template', data, s) |
|
70 | 70 | pos -= 1 |
|
71 | 71 | elif c == 'r' and program[pos:pos + 2] in ("r'", 'r"'): |
|
72 | 72 | # handle quoted strings |
|
73 | 73 | c = program[pos + 1] |
|
74 | 74 | s = pos = pos + 2 |
|
75 | 75 | while pos < end: # find closing quote |
|
76 | 76 | d = program[pos] |
|
77 | 77 | if d == '\\': # skip over escaped characters |
|
78 | 78 | pos += 2 |
|
79 | 79 | continue |
|
80 | 80 | if d == c: |
|
81 | 81 | yield ('string', program[s:pos], s) |
|
82 | 82 | break |
|
83 | 83 | pos += 1 |
|
84 | 84 | else: |
|
85 | 85 | raise error.ParseError(_("unterminated string"), s) |
|
86 | 86 | elif c.isdigit(): |
|
87 | 87 | s = pos |
|
88 | 88 | while pos < end: |
|
89 | 89 | d = program[pos] |
|
90 | 90 | if not d.isdigit(): |
|
91 | 91 | break |
|
92 | 92 | pos += 1 |
|
93 | 93 | yield ('integer', program[s:pos], s) |
|
94 | 94 | pos -= 1 |
|
95 | 95 | elif (c == '\\' and program[pos:pos + 2] in (r"\'", r'\"') |
|
96 | 96 | or c == 'r' and program[pos:pos + 3] in (r"r\'", r'r\"')): |
|
97 | 97 | # handle escaped quoted strings for compatibility with 2.9.2-3.4, |
|
98 | 98 | # where some of nested templates were preprocessed as strings and |
|
99 | 99 | # then compiled. therefore, \"...\" was allowed. (issue4733) |
|
100 | 100 | # |
|
101 | 101 | # processing flow of _evalifliteral() at 5ab28a2e9962: |
|
102 | 102 | # outer template string -> stringify() -> compiletemplate() |
|
103 | 103 | # ------------------------ ------------ ------------------ |
|
104 | 104 | # {f("\\\\ {g(\"\\\"\")}"} \\ {g("\"")} [r'\\', {g("\"")}] |
|
105 | 105 | # ~~~~~~~~ |
|
106 | 106 | # escaped quoted string |
|
107 | 107 | if c == 'r': |
|
108 | 108 | pos += 1 |
|
109 | 109 | token = 'string' |
|
110 | 110 | else: |
|
111 | 111 | token = 'template' |
|
112 | 112 | quote = program[pos:pos + 2] |
|
113 | 113 | s = pos = pos + 2 |
|
114 | 114 | while pos < end: # find closing escaped quote |
|
115 | 115 | if program.startswith('\\\\\\', pos, end): |
|
116 | 116 | pos += 4 # skip over double escaped characters |
|
117 | 117 | continue |
|
118 | 118 | if program.startswith(quote, pos, end): |
|
119 | 119 | # interpret as if it were a part of an outer string |
|
120 | 120 | data = parser.unescapestr(program[s:pos]) |
|
121 | 121 | if token == 'template': |
|
122 | 122 | data = _parsetemplate(data, 0, len(data))[0] |
|
123 | 123 | yield (token, data, s) |
|
124 | 124 | pos += 1 |
|
125 | 125 | break |
|
126 | 126 | pos += 1 |
|
127 | 127 | else: |
|
128 | 128 | raise error.ParseError(_("unterminated string"), s) |
|
129 | 129 | elif c.isalnum() or c in '_': |
|
130 | 130 | s = pos |
|
131 | 131 | pos += 1 |
|
132 | 132 | while pos < end: # find end of symbol |
|
133 | 133 | d = program[pos] |
|
134 | 134 | if not (d.isalnum() or d == "_"): |
|
135 | 135 | break |
|
136 | 136 | pos += 1 |
|
137 | 137 | sym = program[s:pos] |
|
138 | 138 | yield ('symbol', sym, s) |
|
139 | 139 | pos -= 1 |
|
140 | 140 | elif c == term: |
|
141 | 141 | yield ('end', None, pos + 1) |
|
142 | 142 | return |
|
143 | 143 | else: |
|
144 | 144 | raise error.ParseError(_("syntax error"), pos) |
|
145 | 145 | pos += 1 |
|
146 | 146 | if term: |
|
147 | 147 | raise error.ParseError(_("unterminated template expansion"), start) |
|
148 | 148 | yield ('end', None, pos) |
|
149 | 149 | |
|
150 | 150 | def _parsetemplate(tmpl, start, stop, quote=''): |
|
151 | 151 | r""" |
|
152 | 152 | >>> _parsetemplate(b'foo{bar}"baz', 0, 12) |
|
153 | 153 | ([('string', 'foo'), ('symbol', 'bar'), ('string', '"baz')], 12) |
|
154 | 154 | >>> _parsetemplate(b'foo{bar}"baz', 0, 12, quote=b'"') |
|
155 | 155 | ([('string', 'foo'), ('symbol', 'bar')], 9) |
|
156 | 156 | >>> _parsetemplate(b'foo"{bar}', 0, 9, quote=b'"') |
|
157 | 157 | ([('string', 'foo')], 4) |
|
158 | 158 | >>> _parsetemplate(br'foo\"bar"baz', 0, 12, quote=b'"') |
|
159 | 159 | ([('string', 'foo"'), ('string', 'bar')], 9) |
|
160 | 160 | >>> _parsetemplate(br'foo\\"bar', 0, 10, quote=b'"') |
|
161 | 161 | ([('string', 'foo\\')], 6) |
|
162 | 162 | """ |
|
163 | 163 | parsed = [] |
|
164 | 164 | sepchars = '{' + quote |
|
165 | 165 | pos = start |
|
166 | 166 | p = parser.parser(elements) |
|
167 | 167 | while pos < stop: |
|
168 | 168 | n = min((tmpl.find(c, pos, stop) for c in sepchars), |
|
169 | 169 | key=lambda n: (n < 0, n)) |
|
170 | 170 | if n < 0: |
|
171 | 171 | parsed.append(('string', parser.unescapestr(tmpl[pos:stop]))) |
|
172 | 172 | pos = stop |
|
173 | 173 | break |
|
174 | 174 | c = tmpl[n:n + 1] |
|
175 | 175 | bs = (n - pos) - len(tmpl[pos:n].rstrip('\\')) |
|
176 | 176 | if bs % 2 == 1: |
|
177 | 177 | # escaped (e.g. '\{', '\\\{', but not '\\{') |
|
178 | 178 | parsed.append(('string', parser.unescapestr(tmpl[pos:n - 1]) + c)) |
|
179 | 179 | pos = n + 1 |
|
180 | 180 | continue |
|
181 | 181 | if n > pos: |
|
182 | 182 | parsed.append(('string', parser.unescapestr(tmpl[pos:n]))) |
|
183 | 183 | if c == quote: |
|
184 | 184 | return parsed, n + 1 |
|
185 | 185 | |
|
186 | 186 | parseres, pos = p.parse(tokenize(tmpl, n + 1, stop, '}')) |
|
187 | 187 | parsed.append(parseres) |
|
188 | 188 | |
|
189 | 189 | if quote: |
|
190 | 190 | raise error.ParseError(_("unterminated string"), start) |
|
191 | 191 | return parsed, pos |
|
192 | 192 | |
|
193 | 193 | def _unnesttemplatelist(tree): |
|
194 | 194 | """Expand list of templates to node tuple |
|
195 | 195 | |
|
196 | 196 | >>> def f(tree): |
|
197 | 197 | ... print(pycompat.sysstr(prettyformat(_unnesttemplatelist(tree)))) |
|
198 | 198 | >>> f((b'template', [])) |
|
199 | 199 | (string '') |
|
200 | 200 | >>> f((b'template', [(b'string', b'foo')])) |
|
201 | 201 | (string 'foo') |
|
202 | 202 | >>> f((b'template', [(b'string', b'foo'), (b'symbol', b'rev')])) |
|
203 | 203 | (template |
|
204 | 204 | (string 'foo') |
|
205 | 205 | (symbol 'rev')) |
|
206 | 206 | >>> f((b'template', [(b'symbol', b'rev')])) # template(rev) -> str |
|
207 | 207 | (template |
|
208 | 208 | (symbol 'rev')) |
|
209 | 209 | >>> f((b'template', [(b'template', [(b'string', b'foo')])])) |
|
210 | 210 | (string 'foo') |
|
211 | 211 | """ |
|
212 | 212 | if not isinstance(tree, tuple): |
|
213 | 213 | return tree |
|
214 | 214 | op = tree[0] |
|
215 | 215 | if op != 'template': |
|
216 | 216 | return (op,) + tuple(_unnesttemplatelist(x) for x in tree[1:]) |
|
217 | 217 | |
|
218 | 218 | assert len(tree) == 2 |
|
219 | 219 | xs = tuple(_unnesttemplatelist(x) for x in tree[1]) |
|
220 | 220 | if not xs: |
|
221 | 221 | return ('string', '') # empty template "" |
|
222 | 222 | elif len(xs) == 1 and xs[0][0] == 'string': |
|
223 | 223 | return xs[0] # fast path for string with no template fragment "x" |
|
224 | 224 | else: |
|
225 | 225 | return (op,) + xs |
|
226 | 226 | |
|
227 | 227 | def parse(tmpl): |
|
228 | 228 | """Parse template string into tree""" |
|
229 | 229 | parsed, pos = _parsetemplate(tmpl, 0, len(tmpl)) |
|
230 | 230 | assert pos == len(tmpl), 'unquoted template should be consumed' |
|
231 | 231 | return _unnesttemplatelist(('template', parsed)) |
|
232 | 232 | |
|
233 | 233 | def _parseexpr(expr): |
|
234 | 234 | """Parse a template expression into tree |
|
235 | 235 | |
|
236 | 236 | >>> _parseexpr(b'"foo"') |
|
237 | 237 | ('string', 'foo') |
|
238 | 238 | >>> _parseexpr(b'foo(bar)') |
|
239 | 239 | ('func', ('symbol', 'foo'), ('symbol', 'bar')) |
|
240 | 240 | >>> _parseexpr(b'foo(') |
|
241 | 241 | Traceback (most recent call last): |
|
242 | 242 | ... |
|
243 | 243 | ParseError: ('not a prefix: end', 4) |
|
244 | 244 | >>> _parseexpr(b'"foo" "bar"') |
|
245 | 245 | Traceback (most recent call last): |
|
246 | 246 | ... |
|
247 | 247 | ParseError: ('invalid token', 7) |
|
248 | 248 | """ |
|
249 | 249 | p = parser.parser(elements) |
|
250 | 250 | tree, pos = p.parse(tokenize(expr, 0, len(expr))) |
|
251 | 251 | if pos != len(expr): |
|
252 | 252 | raise error.ParseError(_('invalid token'), pos) |
|
253 | 253 | return _unnesttemplatelist(tree) |
|
254 | 254 | |
|
255 | 255 | def prettyformat(tree): |
|
256 | 256 | return parser.prettyformat(tree, ('integer', 'string', 'symbol')) |
|
257 | 257 | |
|
258 | 258 | def compileexp(exp, context, curmethods): |
|
259 | 259 | """Compile parsed template tree to (func, data) pair""" |
|
260 | 260 | t = exp[0] |
|
261 | 261 | if t in curmethods: |
|
262 | 262 | return curmethods[t](exp, context) |
|
263 | 263 | raise error.ParseError(_("unknown method '%s'") % t) |
|
264 | 264 | |
|
265 | 265 | # template evaluation |
|
266 | 266 | |
|
267 | 267 | def getsymbol(exp): |
|
268 | 268 | if exp[0] == 'symbol': |
|
269 | 269 | return exp[1] |
|
270 | 270 | raise error.ParseError(_("expected a symbol, got '%s'") % exp[0]) |
|
271 | 271 | |
|
272 | 272 | def getlist(x): |
|
273 | 273 | if not x: |
|
274 | 274 | return [] |
|
275 | 275 | if x[0] == 'list': |
|
276 | 276 | return getlist(x[1]) + [x[2]] |
|
277 | 277 | return [x] |
|
278 | 278 | |
|
279 | 279 | def gettemplate(exp, context): |
|
280 | 280 | """Compile given template tree or load named template from map file; |
|
281 | 281 | returns (func, data) pair""" |
|
282 | 282 | if exp[0] in ('template', 'string'): |
|
283 | 283 | return compileexp(exp, context, methods) |
|
284 | 284 | if exp[0] == 'symbol': |
|
285 | 285 | # unlike runsymbol(), here 'symbol' is always taken as template name |
|
286 | 286 | # even if it exists in mapping. this allows us to override mapping |
|
287 | 287 | # by web templates, e.g. 'changelogtag' is redefined in map file. |
|
288 | 288 | return context._load(exp[1]) |
|
289 | 289 | raise error.ParseError(_("expected template specifier")) |
|
290 | 290 | |
|
291 | 291 | def findsymbolicname(arg): |
|
292 | 292 | """Find symbolic name for the given compiled expression; returns None |
|
293 | 293 | if nothing found reliably""" |
|
294 | 294 | while True: |
|
295 | 295 | func, data = arg |
|
296 | 296 | if func is runsymbol: |
|
297 | 297 | return data |
|
298 | 298 | elif func is runfilter: |
|
299 | 299 | arg = data[0] |
|
300 | 300 | else: |
|
301 | 301 | return None |
|
302 | 302 | |
|
303 | 303 | def evalrawexp(context, mapping, arg): |
|
304 | 304 | """Evaluate given argument as a bare template object which may require |
|
305 | 305 | further processing (such as folding generator of strings)""" |
|
306 | 306 | func, data = arg |
|
307 | 307 | return func(context, mapping, data) |
|
308 | 308 | |
|
309 | 309 | def evalfuncarg(context, mapping, arg): |
|
310 | 310 | """Evaluate given argument as value type""" |
|
311 | 311 | thing = evalrawexp(context, mapping, arg) |
|
312 | 312 | thing = templatekw.unwrapvalue(thing) |
|
313 | 313 | # evalrawexp() may return string, generator of strings or arbitrary object |
|
314 | 314 | # such as date tuple, but filter does not want generator. |
|
315 | 315 | if isinstance(thing, types.GeneratorType): |
|
316 | 316 | thing = stringify(thing) |
|
317 | 317 | return thing |
|
318 | 318 | |
|
319 | 319 | def evalboolean(context, mapping, arg): |
|
320 | 320 | """Evaluate given argument as boolean, but also takes boolean literals""" |
|
321 | 321 | func, data = arg |
|
322 | 322 | if func is runsymbol: |
|
323 | 323 | thing = func(context, mapping, data, default=None) |
|
324 | 324 | if thing is None: |
|
325 | 325 | # not a template keyword, takes as a boolean literal |
|
326 | 326 | thing = util.parsebool(data) |
|
327 | 327 | else: |
|
328 | 328 | thing = func(context, mapping, data) |
|
329 | 329 | thing = templatekw.unwrapvalue(thing) |
|
330 | 330 | if isinstance(thing, bool): |
|
331 | 331 | return thing |
|
332 | 332 | # other objects are evaluated as strings, which means 0 is True, but |
|
333 | 333 | # empty dict/list should be False as they are expected to be '' |
|
334 | 334 | return bool(stringify(thing)) |
|
335 | 335 | |
|
336 | 336 | def evalinteger(context, mapping, arg, err): |
|
337 | 337 | v = evalfuncarg(context, mapping, arg) |
|
338 | 338 | try: |
|
339 | 339 | return int(v) |
|
340 | 340 | except (TypeError, ValueError): |
|
341 | 341 | raise error.ParseError(err) |
|
342 | 342 | |
|
343 | 343 | def evalstring(context, mapping, arg): |
|
344 | 344 | return stringify(evalrawexp(context, mapping, arg)) |
|
345 | 345 | |
|
346 | 346 | def evalstringliteral(context, mapping, arg): |
|
347 | 347 | """Evaluate given argument as string template, but returns symbol name |
|
348 | 348 | if it is unknown""" |
|
349 | 349 | func, data = arg |
|
350 | 350 | if func is runsymbol: |
|
351 | 351 | thing = func(context, mapping, data, default=data) |
|
352 | 352 | else: |
|
353 | 353 | thing = func(context, mapping, data) |
|
354 | 354 | return stringify(thing) |
|
355 | 355 | |
|
356 | 356 | def runinteger(context, mapping, data): |
|
357 | 357 | return int(data) |
|
358 | 358 | |
|
359 | 359 | def runstring(context, mapping, data): |
|
360 | 360 | return data |
|
361 | 361 | |
|
362 | 362 | def _recursivesymbolblocker(key): |
|
363 | 363 | def showrecursion(**args): |
|
364 | 364 | raise error.Abort(_("recursive reference '%s' in template") % key) |
|
365 | 365 | return showrecursion |
|
366 | 366 | |
|
367 | 367 | def _runrecursivesymbol(context, mapping, key): |
|
368 | 368 | raise error.Abort(_("recursive reference '%s' in template") % key) |
|
369 | 369 | |
|
370 | 370 | def runsymbol(context, mapping, key, default=''): |
|
371 | 371 | v = mapping.get(key) |
|
372 | 372 | if v is None: |
|
373 | 373 | v = context._defaults.get(key) |
|
374 | 374 | if v is None: |
|
375 | 375 | # put poison to cut recursion. we can't move this to parsing phase |
|
376 | 376 | # because "x = {x}" is allowed if "x" is a keyword. (issue4758) |
|
377 | 377 | safemapping = mapping.copy() |
|
378 | 378 | safemapping[key] = _recursivesymbolblocker(key) |
|
379 | 379 | try: |
|
380 | 380 | v = context.process(key, safemapping) |
|
381 | 381 | except TemplateNotFound: |
|
382 | 382 | v = default |
|
383 | 383 | if callable(v): |
|
384 | 384 | return v(**pycompat.strkwargs(mapping)) |
|
385 | 385 | return v |
|
386 | 386 | |
|
387 | 387 | def buildtemplate(exp, context): |
|
388 | 388 | ctmpl = [compileexp(e, context, methods) for e in exp[1:]] |
|
389 | 389 | return (runtemplate, ctmpl) |
|
390 | 390 | |
|
391 | 391 | def runtemplate(context, mapping, template): |
|
392 | 392 | for arg in template: |
|
393 | 393 | yield evalrawexp(context, mapping, arg) |
|
394 | 394 | |
|
395 | 395 | def buildfilter(exp, context): |
|
396 | 396 | n = getsymbol(exp[2]) |
|
397 | 397 | if n in context._filters: |
|
398 | 398 | filt = context._filters[n] |
|
399 | 399 | arg = compileexp(exp[1], context, methods) |
|
400 | 400 | return (runfilter, (arg, filt)) |
|
401 | 401 | if n in funcs: |
|
402 | 402 | f = funcs[n] |
|
403 | 403 | args = _buildfuncargs(exp[1], context, methods, n, f._argspec) |
|
404 | 404 | return (f, args) |
|
405 | 405 | raise error.ParseError(_("unknown function '%s'") % n) |
|
406 | 406 | |
|
407 | 407 | def runfilter(context, mapping, data): |
|
408 | 408 | arg, filt = data |
|
409 | 409 | thing = evalfuncarg(context, mapping, arg) |
|
410 | 410 | try: |
|
411 | 411 | return filt(thing) |
|
412 | 412 | except (ValueError, AttributeError, TypeError): |
|
413 | 413 | sym = findsymbolicname(arg) |
|
414 | 414 | if sym: |
|
415 | 415 | msg = (_("template filter '%s' is not compatible with keyword '%s'") |
|
416 | 416 | % (filt.func_name, sym)) |
|
417 | 417 | else: |
|
418 | 418 | msg = _("incompatible use of template filter '%s'") % filt.func_name |
|
419 | 419 | raise error.Abort(msg) |
|
420 | 420 | |
|
421 | 421 | def buildmap(exp, context): |
|
422 | 422 | darg = compileexp(exp[1], context, methods) |
|
423 | 423 | targ = gettemplate(exp[2], context) |
|
424 | 424 | return (runmap, (darg, targ)) |
|
425 | 425 | |
|
426 | 426 | def runmap(context, mapping, data): |
|
427 | 427 | darg, targ = data |
|
428 | 428 | d = evalrawexp(context, mapping, darg) |
|
429 | 429 | if util.safehasattr(d, 'itermaps'): |
|
430 | 430 | diter = d.itermaps() |
|
431 | 431 | else: |
|
432 | 432 | try: |
|
433 | 433 | diter = iter(d) |
|
434 | 434 | except TypeError: |
|
435 | 435 | sym = findsymbolicname(darg) |
|
436 | 436 | if sym: |
|
437 | 437 | raise error.ParseError(_("keyword '%s' is not iterable") % sym) |
|
438 | 438 | else: |
|
439 | 439 | raise error.ParseError(_("%r is not iterable") % d) |
|
440 | 440 | |
|
441 | 441 | for i, v in enumerate(diter): |
|
442 | 442 | lm = mapping.copy() |
|
443 | 443 | lm['index'] = i |
|
444 | 444 | if isinstance(v, dict): |
|
445 | 445 | lm.update(v) |
|
446 | 446 | lm['originalnode'] = mapping.get('node') |
|
447 | 447 | yield evalrawexp(context, lm, targ) |
|
448 | 448 | else: |
|
449 | 449 | # v is not an iterable of dicts, this happen when 'key' |
|
450 | 450 | # has been fully expanded already and format is useless. |
|
451 | 451 | # If so, return the expanded value. |
|
452 | 452 | yield v |
|
453 | 453 | |
|
454 | 454 | def buildmember(exp, context): |
|
455 | 455 | darg = compileexp(exp[1], context, methods) |
|
456 | 456 | memb = getsymbol(exp[2]) |
|
457 | 457 | return (runmember, (darg, memb)) |
|
458 | 458 | |
|
459 | 459 | def runmember(context, mapping, data): |
|
460 | 460 | darg, memb = data |
|
461 | 461 | d = evalrawexp(context, mapping, darg) |
|
462 | 462 | if util.safehasattr(d, 'tomap'): |
|
463 | 463 | lm = mapping.copy() |
|
464 | 464 | lm.update(d.tomap()) |
|
465 | 465 | return runsymbol(context, lm, memb) |
|
466 | # TODO: d.get(memb) if dict-like? | |
|
466 | if util.safehasattr(d, 'get'): | |
|
467 | return _getdictitem(d, memb) | |
|
467 | 468 | |
|
468 | 469 | sym = findsymbolicname(darg) |
|
469 | 470 | if sym: |
|
470 | 471 | raise error.ParseError(_("keyword '%s' has no member") % sym) |
|
471 | 472 | else: |
|
472 | 473 | raise error.ParseError(_("%r has no member") % d) |
|
473 | 474 | |
|
474 | 475 | def buildnegate(exp, context): |
|
475 | 476 | arg = compileexp(exp[1], context, exprmethods) |
|
476 | 477 | return (runnegate, arg) |
|
477 | 478 | |
|
478 | 479 | def runnegate(context, mapping, data): |
|
479 | 480 | data = evalinteger(context, mapping, data, |
|
480 | 481 | _('negation needs an integer argument')) |
|
481 | 482 | return -data |
|
482 | 483 | |
|
483 | 484 | def buildarithmetic(exp, context, func): |
|
484 | 485 | left = compileexp(exp[1], context, exprmethods) |
|
485 | 486 | right = compileexp(exp[2], context, exprmethods) |
|
486 | 487 | return (runarithmetic, (func, left, right)) |
|
487 | 488 | |
|
488 | 489 | def runarithmetic(context, mapping, data): |
|
489 | 490 | func, left, right = data |
|
490 | 491 | left = evalinteger(context, mapping, left, |
|
491 | 492 | _('arithmetic only defined on integers')) |
|
492 | 493 | right = evalinteger(context, mapping, right, |
|
493 | 494 | _('arithmetic only defined on integers')) |
|
494 | 495 | try: |
|
495 | 496 | return func(left, right) |
|
496 | 497 | except ZeroDivisionError: |
|
497 | 498 | raise error.Abort(_('division by zero is not defined')) |
|
498 | 499 | |
|
499 | 500 | def buildfunc(exp, context): |
|
500 | 501 | n = getsymbol(exp[1]) |
|
501 | 502 | if n in funcs: |
|
502 | 503 | f = funcs[n] |
|
503 | 504 | args = _buildfuncargs(exp[2], context, exprmethods, n, f._argspec) |
|
504 | 505 | return (f, args) |
|
505 | 506 | if n in context._filters: |
|
506 | 507 | args = _buildfuncargs(exp[2], context, exprmethods, n, argspec=None) |
|
507 | 508 | if len(args) != 1: |
|
508 | 509 | raise error.ParseError(_("filter %s expects one argument") % n) |
|
509 | 510 | f = context._filters[n] |
|
510 | 511 | return (runfilter, (args[0], f)) |
|
511 | 512 | raise error.ParseError(_("unknown function '%s'") % n) |
|
512 | 513 | |
|
513 | 514 | def _buildfuncargs(exp, context, curmethods, funcname, argspec): |
|
514 | 515 | """Compile parsed tree of function arguments into list or dict of |
|
515 | 516 | (func, data) pairs |
|
516 | 517 | |
|
517 | 518 | >>> context = engine(lambda t: (runsymbol, t)) |
|
518 | 519 | >>> def fargs(expr, argspec): |
|
519 | 520 | ... x = _parseexpr(expr) |
|
520 | 521 | ... n = getsymbol(x[1]) |
|
521 | 522 | ... return _buildfuncargs(x[2], context, exprmethods, n, argspec) |
|
522 | 523 | >>> list(fargs(b'a(l=1, k=2)', b'k l m').keys()) |
|
523 | 524 | ['l', 'k'] |
|
524 | 525 | >>> args = fargs(b'a(opts=1, k=2)', b'**opts') |
|
525 | 526 | >>> list(args.keys()), list(args[b'opts'].keys()) |
|
526 | 527 | (['opts'], ['opts', 'k']) |
|
527 | 528 | """ |
|
528 | 529 | def compiledict(xs): |
|
529 | 530 | return util.sortdict((k, compileexp(x, context, curmethods)) |
|
530 | 531 | for k, x in xs.iteritems()) |
|
531 | 532 | def compilelist(xs): |
|
532 | 533 | return [compileexp(x, context, curmethods) for x in xs] |
|
533 | 534 | |
|
534 | 535 | if not argspec: |
|
535 | 536 | # filter or function with no argspec: return list of positional args |
|
536 | 537 | return compilelist(getlist(exp)) |
|
537 | 538 | |
|
538 | 539 | # function with argspec: return dict of named args |
|
539 | 540 | _poskeys, varkey, _keys, optkey = argspec = parser.splitargspec(argspec) |
|
540 | 541 | treeargs = parser.buildargsdict(getlist(exp), funcname, argspec, |
|
541 | 542 | keyvaluenode='keyvalue', keynode='symbol') |
|
542 | 543 | compargs = util.sortdict() |
|
543 | 544 | if varkey: |
|
544 | 545 | compargs[varkey] = compilelist(treeargs.pop(varkey)) |
|
545 | 546 | if optkey: |
|
546 | 547 | compargs[optkey] = compiledict(treeargs.pop(optkey)) |
|
547 | 548 | compargs.update(compiledict(treeargs)) |
|
548 | 549 | return compargs |
|
549 | 550 | |
|
550 | 551 | def buildkeyvaluepair(exp, content): |
|
551 | 552 | raise error.ParseError(_("can't use a key-value pair in this context")) |
|
552 | 553 | |
|
553 | 554 | # dict of template built-in functions |
|
554 | 555 | funcs = {} |
|
555 | 556 | |
|
556 | 557 | templatefunc = registrar.templatefunc(funcs) |
|
557 | 558 | |
|
558 | 559 | @templatefunc('date(date[, fmt])') |
|
559 | 560 | def date(context, mapping, args): |
|
560 | 561 | """Format a date. See :hg:`help dates` for formatting |
|
561 | 562 | strings. The default is a Unix date format, including the timezone: |
|
562 | 563 | "Mon Sep 04 15:13:13 2006 0700".""" |
|
563 | 564 | if not (1 <= len(args) <= 2): |
|
564 | 565 | # i18n: "date" is a keyword |
|
565 | 566 | raise error.ParseError(_("date expects one or two arguments")) |
|
566 | 567 | |
|
567 | 568 | date = evalfuncarg(context, mapping, args[0]) |
|
568 | 569 | fmt = None |
|
569 | 570 | if len(args) == 2: |
|
570 | 571 | fmt = evalstring(context, mapping, args[1]) |
|
571 | 572 | try: |
|
572 | 573 | if fmt is None: |
|
573 | 574 | return util.datestr(date) |
|
574 | 575 | else: |
|
575 | 576 | return util.datestr(date, fmt) |
|
576 | 577 | except (TypeError, ValueError): |
|
577 | 578 | # i18n: "date" is a keyword |
|
578 | 579 | raise error.ParseError(_("date expects a date information")) |
|
579 | 580 | |
|
580 | 581 | @templatefunc('dict([[key=]value...])', argspec='*args **kwargs') |
|
581 | 582 | def dict_(context, mapping, args): |
|
582 | 583 | """Construct a dict from key-value pairs. A key may be omitted if |
|
583 | 584 | a value expression can provide an unambiguous name.""" |
|
584 | 585 | data = util.sortdict() |
|
585 | 586 | |
|
586 | 587 | for v in args['args']: |
|
587 | 588 | k = findsymbolicname(v) |
|
588 | 589 | if not k: |
|
589 | 590 | raise error.ParseError(_('dict key cannot be inferred')) |
|
590 | 591 | if k in data or k in args['kwargs']: |
|
591 | 592 | raise error.ParseError(_("duplicated dict key '%s' inferred") % k) |
|
592 | 593 | data[k] = evalfuncarg(context, mapping, v) |
|
593 | 594 | |
|
594 | 595 | data.update((k, evalfuncarg(context, mapping, v)) |
|
595 | 596 | for k, v in args['kwargs'].iteritems()) |
|
596 | 597 | return templatekw.hybriddict(data) |
|
597 | 598 | |
|
598 | 599 | @templatefunc('diff([includepattern [, excludepattern]])') |
|
599 | 600 | def diff(context, mapping, args): |
|
600 | 601 | """Show a diff, optionally |
|
601 | 602 | specifying files to include or exclude.""" |
|
602 | 603 | if len(args) > 2: |
|
603 | 604 | # i18n: "diff" is a keyword |
|
604 | 605 | raise error.ParseError(_("diff expects zero, one, or two arguments")) |
|
605 | 606 | |
|
606 | 607 | def getpatterns(i): |
|
607 | 608 | if i < len(args): |
|
608 | 609 | s = evalstring(context, mapping, args[i]).strip() |
|
609 | 610 | if s: |
|
610 | 611 | return [s] |
|
611 | 612 | return [] |
|
612 | 613 | |
|
613 | 614 | ctx = mapping['ctx'] |
|
614 | 615 | chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1))) |
|
615 | 616 | |
|
616 | 617 | return ''.join(chunks) |
|
617 | 618 | |
|
618 | 619 | @templatefunc('extdata(source)', argspec='source') |
|
619 | 620 | def extdata(context, mapping, args): |
|
620 | 621 | """Show a text read from the specified extdata source. (EXPERIMENTAL)""" |
|
621 | 622 | if 'source' not in args: |
|
622 | 623 | # i18n: "extdata" is a keyword |
|
623 | 624 | raise error.ParseError(_('extdata expects one argument')) |
|
624 | 625 | |
|
625 | 626 | source = evalstring(context, mapping, args['source']) |
|
626 | 627 | cache = mapping['cache'].setdefault('extdata', {}) |
|
627 | 628 | ctx = mapping['ctx'] |
|
628 | 629 | if source in cache: |
|
629 | 630 | data = cache[source] |
|
630 | 631 | else: |
|
631 | 632 | data = cache[source] = scmutil.extdatasource(ctx.repo(), source) |
|
632 | 633 | return data.get(ctx.rev(), '') |
|
633 | 634 | |
|
634 | 635 | @templatefunc('files(pattern)') |
|
635 | 636 | def files(context, mapping, args): |
|
636 | 637 | """All files of the current changeset matching the pattern. See |
|
637 | 638 | :hg:`help patterns`.""" |
|
638 | 639 | if not len(args) == 1: |
|
639 | 640 | # i18n: "files" is a keyword |
|
640 | 641 | raise error.ParseError(_("files expects one argument")) |
|
641 | 642 | |
|
642 | 643 | raw = evalstring(context, mapping, args[0]) |
|
643 | 644 | ctx = mapping['ctx'] |
|
644 | 645 | m = ctx.match([raw]) |
|
645 | 646 | files = list(ctx.matches(m)) |
|
646 | 647 | return templatekw.showlist("file", files, mapping) |
|
647 | 648 | |
|
648 | 649 | @templatefunc('fill(text[, width[, initialident[, hangindent]]])') |
|
649 | 650 | def fill(context, mapping, args): |
|
650 | 651 | """Fill many |
|
651 | 652 | paragraphs with optional indentation. See the "fill" filter.""" |
|
652 | 653 | if not (1 <= len(args) <= 4): |
|
653 | 654 | # i18n: "fill" is a keyword |
|
654 | 655 | raise error.ParseError(_("fill expects one to four arguments")) |
|
655 | 656 | |
|
656 | 657 | text = evalstring(context, mapping, args[0]) |
|
657 | 658 | width = 76 |
|
658 | 659 | initindent = '' |
|
659 | 660 | hangindent = '' |
|
660 | 661 | if 2 <= len(args) <= 4: |
|
661 | 662 | width = evalinteger(context, mapping, args[1], |
|
662 | 663 | # i18n: "fill" is a keyword |
|
663 | 664 | _("fill expects an integer width")) |
|
664 | 665 | try: |
|
665 | 666 | initindent = evalstring(context, mapping, args[2]) |
|
666 | 667 | hangindent = evalstring(context, mapping, args[3]) |
|
667 | 668 | except IndexError: |
|
668 | 669 | pass |
|
669 | 670 | |
|
670 | 671 | return templatefilters.fill(text, width, initindent, hangindent) |
|
671 | 672 | |
|
672 | 673 | @templatefunc('formatnode(node)') |
|
673 | 674 | def formatnode(context, mapping, args): |
|
674 | 675 | """Obtain the preferred form of a changeset hash. (DEPRECATED)""" |
|
675 | 676 | if len(args) != 1: |
|
676 | 677 | # i18n: "formatnode" is a keyword |
|
677 | 678 | raise error.ParseError(_("formatnode expects one argument")) |
|
678 | 679 | |
|
679 | 680 | ui = mapping['ui'] |
|
680 | 681 | node = evalstring(context, mapping, args[0]) |
|
681 | 682 | if ui.debugflag: |
|
682 | 683 | return node |
|
683 | 684 | return templatefilters.short(node) |
|
684 | 685 | |
|
685 | 686 | @templatefunc('pad(text, width[, fillchar=\' \'[, left=False]])', |
|
686 | 687 | argspec='text width fillchar left') |
|
687 | 688 | def pad(context, mapping, args): |
|
688 | 689 | """Pad text with a |
|
689 | 690 | fill character.""" |
|
690 | 691 | if 'text' not in args or 'width' not in args: |
|
691 | 692 | # i18n: "pad" is a keyword |
|
692 | 693 | raise error.ParseError(_("pad() expects two to four arguments")) |
|
693 | 694 | |
|
694 | 695 | width = evalinteger(context, mapping, args['width'], |
|
695 | 696 | # i18n: "pad" is a keyword |
|
696 | 697 | _("pad() expects an integer width")) |
|
697 | 698 | |
|
698 | 699 | text = evalstring(context, mapping, args['text']) |
|
699 | 700 | |
|
700 | 701 | left = False |
|
701 | 702 | fillchar = ' ' |
|
702 | 703 | if 'fillchar' in args: |
|
703 | 704 | fillchar = evalstring(context, mapping, args['fillchar']) |
|
704 | 705 | if len(color.stripeffects(fillchar)) != 1: |
|
705 | 706 | # i18n: "pad" is a keyword |
|
706 | 707 | raise error.ParseError(_("pad() expects a single fill character")) |
|
707 | 708 | if 'left' in args: |
|
708 | 709 | left = evalboolean(context, mapping, args['left']) |
|
709 | 710 | |
|
710 | 711 | fillwidth = width - encoding.colwidth(color.stripeffects(text)) |
|
711 | 712 | if fillwidth <= 0: |
|
712 | 713 | return text |
|
713 | 714 | if left: |
|
714 | 715 | return fillchar * fillwidth + text |
|
715 | 716 | else: |
|
716 | 717 | return text + fillchar * fillwidth |
|
717 | 718 | |
|
718 | 719 | @templatefunc('indent(text, indentchars[, firstline])') |
|
719 | 720 | def indent(context, mapping, args): |
|
720 | 721 | """Indents all non-empty lines |
|
721 | 722 | with the characters given in the indentchars string. An optional |
|
722 | 723 | third parameter will override the indent for the first line only |
|
723 | 724 | if present.""" |
|
724 | 725 | if not (2 <= len(args) <= 3): |
|
725 | 726 | # i18n: "indent" is a keyword |
|
726 | 727 | raise error.ParseError(_("indent() expects two or three arguments")) |
|
727 | 728 | |
|
728 | 729 | text = evalstring(context, mapping, args[0]) |
|
729 | 730 | indent = evalstring(context, mapping, args[1]) |
|
730 | 731 | |
|
731 | 732 | if len(args) == 3: |
|
732 | 733 | firstline = evalstring(context, mapping, args[2]) |
|
733 | 734 | else: |
|
734 | 735 | firstline = indent |
|
735 | 736 | |
|
736 | 737 | # the indent function doesn't indent the first line, so we do it here |
|
737 | 738 | return templatefilters.indent(firstline + text, indent) |
|
738 | 739 | |
|
739 | 740 | @templatefunc('get(dict, key)') |
|
740 | 741 | def get(context, mapping, args): |
|
741 | 742 | """Get an attribute/key from an object. Some keywords |
|
742 | 743 | are complex types. This function allows you to obtain the value of an |
|
743 | 744 | attribute on these types.""" |
|
744 | 745 | if len(args) != 2: |
|
745 | 746 | # i18n: "get" is a keyword |
|
746 | 747 | raise error.ParseError(_("get() expects two arguments")) |
|
747 | 748 | |
|
748 | 749 | dictarg = evalfuncarg(context, mapping, args[0]) |
|
749 | 750 | if not util.safehasattr(dictarg, 'get'): |
|
750 | 751 | # i18n: "get" is a keyword |
|
751 | 752 | raise error.ParseError(_("get() expects a dict as first argument")) |
|
752 | 753 | |
|
753 | 754 | key = evalfuncarg(context, mapping, args[1]) |
|
755 | return _getdictitem(dictarg, key) | |
|
756 | ||
|
757 | def _getdictitem(dictarg, key): | |
|
754 | 758 | val = dictarg.get(key) |
|
755 | 759 | if val is None: |
|
756 | 760 | return |
|
757 | 761 | return templatekw.wraphybridvalue(dictarg, key, val) |
|
758 | 762 | |
|
759 | 763 | @templatefunc('if(expr, then[, else])') |
|
760 | 764 | def if_(context, mapping, args): |
|
761 | 765 | """Conditionally execute based on the result of |
|
762 | 766 | an expression.""" |
|
763 | 767 | if not (2 <= len(args) <= 3): |
|
764 | 768 | # i18n: "if" is a keyword |
|
765 | 769 | raise error.ParseError(_("if expects two or three arguments")) |
|
766 | 770 | |
|
767 | 771 | test = evalboolean(context, mapping, args[0]) |
|
768 | 772 | if test: |
|
769 | 773 | yield evalrawexp(context, mapping, args[1]) |
|
770 | 774 | elif len(args) == 3: |
|
771 | 775 | yield evalrawexp(context, mapping, args[2]) |
|
772 | 776 | |
|
773 | 777 | @templatefunc('ifcontains(needle, haystack, then[, else])') |
|
774 | 778 | def ifcontains(context, mapping, args): |
|
775 | 779 | """Conditionally execute based |
|
776 | 780 | on whether the item "needle" is in "haystack".""" |
|
777 | 781 | if not (3 <= len(args) <= 4): |
|
778 | 782 | # i18n: "ifcontains" is a keyword |
|
779 | 783 | raise error.ParseError(_("ifcontains expects three or four arguments")) |
|
780 | 784 | |
|
781 | 785 | needle = evalstring(context, mapping, args[0]) |
|
782 | 786 | haystack = evalfuncarg(context, mapping, args[1]) |
|
783 | 787 | |
|
784 | 788 | if needle in haystack: |
|
785 | 789 | yield evalrawexp(context, mapping, args[2]) |
|
786 | 790 | elif len(args) == 4: |
|
787 | 791 | yield evalrawexp(context, mapping, args[3]) |
|
788 | 792 | |
|
789 | 793 | @templatefunc('ifeq(expr1, expr2, then[, else])') |
|
790 | 794 | def ifeq(context, mapping, args): |
|
791 | 795 | """Conditionally execute based on |
|
792 | 796 | whether 2 items are equivalent.""" |
|
793 | 797 | if not (3 <= len(args) <= 4): |
|
794 | 798 | # i18n: "ifeq" is a keyword |
|
795 | 799 | raise error.ParseError(_("ifeq expects three or four arguments")) |
|
796 | 800 | |
|
797 | 801 | test = evalstring(context, mapping, args[0]) |
|
798 | 802 | match = evalstring(context, mapping, args[1]) |
|
799 | 803 | if test == match: |
|
800 | 804 | yield evalrawexp(context, mapping, args[2]) |
|
801 | 805 | elif len(args) == 4: |
|
802 | 806 | yield evalrawexp(context, mapping, args[3]) |
|
803 | 807 | |
|
804 | 808 | @templatefunc('join(list, sep)') |
|
805 | 809 | def join(context, mapping, args): |
|
806 | 810 | """Join items in a list with a delimiter.""" |
|
807 | 811 | if not (1 <= len(args) <= 2): |
|
808 | 812 | # i18n: "join" is a keyword |
|
809 | 813 | raise error.ParseError(_("join expects one or two arguments")) |
|
810 | 814 | |
|
811 | 815 | # TODO: perhaps this should be evalfuncarg(), but it can't because hgweb |
|
812 | 816 | # abuses generator as a keyword that returns a list of dicts. |
|
813 | 817 | joinset = evalrawexp(context, mapping, args[0]) |
|
814 | 818 | joinset = templatekw.unwrapvalue(joinset) |
|
815 | 819 | joinfmt = getattr(joinset, 'joinfmt', pycompat.identity) |
|
816 | 820 | joiner = " " |
|
817 | 821 | if len(args) > 1: |
|
818 | 822 | joiner = evalstring(context, mapping, args[1]) |
|
819 | 823 | |
|
820 | 824 | first = True |
|
821 | 825 | for x in joinset: |
|
822 | 826 | if first: |
|
823 | 827 | first = False |
|
824 | 828 | else: |
|
825 | 829 | yield joiner |
|
826 | 830 | yield joinfmt(x) |
|
827 | 831 | |
|
828 | 832 | @templatefunc('label(label, expr)') |
|
829 | 833 | def label(context, mapping, args): |
|
830 | 834 | """Apply a label to generated content. Content with |
|
831 | 835 | a label applied can result in additional post-processing, such as |
|
832 | 836 | automatic colorization.""" |
|
833 | 837 | if len(args) != 2: |
|
834 | 838 | # i18n: "label" is a keyword |
|
835 | 839 | raise error.ParseError(_("label expects two arguments")) |
|
836 | 840 | |
|
837 | 841 | ui = mapping['ui'] |
|
838 | 842 | thing = evalstring(context, mapping, args[1]) |
|
839 | 843 | # preserve unknown symbol as literal so effects like 'red', 'bold', |
|
840 | 844 | # etc. don't need to be quoted |
|
841 | 845 | label = evalstringliteral(context, mapping, args[0]) |
|
842 | 846 | |
|
843 | 847 | return ui.label(thing, label) |
|
844 | 848 | |
|
845 | 849 | @templatefunc('latesttag([pattern])') |
|
846 | 850 | def latesttag(context, mapping, args): |
|
847 | 851 | """The global tags matching the given pattern on the |
|
848 | 852 | most recent globally tagged ancestor of this changeset. |
|
849 | 853 | If no such tags exist, the "{tag}" template resolves to |
|
850 | 854 | the string "null".""" |
|
851 | 855 | if len(args) > 1: |
|
852 | 856 | # i18n: "latesttag" is a keyword |
|
853 | 857 | raise error.ParseError(_("latesttag expects at most one argument")) |
|
854 | 858 | |
|
855 | 859 | pattern = None |
|
856 | 860 | if len(args) == 1: |
|
857 | 861 | pattern = evalstring(context, mapping, args[0]) |
|
858 | 862 | |
|
859 | 863 | return templatekw.showlatesttags(pattern, **mapping) |
|
860 | 864 | |
|
861 | 865 | @templatefunc('localdate(date[, tz])') |
|
862 | 866 | def localdate(context, mapping, args): |
|
863 | 867 | """Converts a date to the specified timezone. |
|
864 | 868 | The default is local date.""" |
|
865 | 869 | if not (1 <= len(args) <= 2): |
|
866 | 870 | # i18n: "localdate" is a keyword |
|
867 | 871 | raise error.ParseError(_("localdate expects one or two arguments")) |
|
868 | 872 | |
|
869 | 873 | date = evalfuncarg(context, mapping, args[0]) |
|
870 | 874 | try: |
|
871 | 875 | date = util.parsedate(date) |
|
872 | 876 | except AttributeError: # not str nor date tuple |
|
873 | 877 | # i18n: "localdate" is a keyword |
|
874 | 878 | raise error.ParseError(_("localdate expects a date information")) |
|
875 | 879 | if len(args) >= 2: |
|
876 | 880 | tzoffset = None |
|
877 | 881 | tz = evalfuncarg(context, mapping, args[1]) |
|
878 | 882 | if isinstance(tz, str): |
|
879 | 883 | tzoffset, remainder = util.parsetimezone(tz) |
|
880 | 884 | if remainder: |
|
881 | 885 | tzoffset = None |
|
882 | 886 | if tzoffset is None: |
|
883 | 887 | try: |
|
884 | 888 | tzoffset = int(tz) |
|
885 | 889 | except (TypeError, ValueError): |
|
886 | 890 | # i18n: "localdate" is a keyword |
|
887 | 891 | raise error.ParseError(_("localdate expects a timezone")) |
|
888 | 892 | else: |
|
889 | 893 | tzoffset = util.makedate()[1] |
|
890 | 894 | return (date[0], tzoffset) |
|
891 | 895 | |
|
892 | 896 | @templatefunc('max(iterable)') |
|
893 | 897 | def max_(context, mapping, args, **kwargs): |
|
894 | 898 | """Return the max of an iterable""" |
|
895 | 899 | if len(args) != 1: |
|
896 | 900 | # i18n: "max" is a keyword |
|
897 | 901 | raise error.ParseError(_("max expects one arguments")) |
|
898 | 902 | |
|
899 | 903 | iterable = evalfuncarg(context, mapping, args[0]) |
|
900 | 904 | try: |
|
901 | 905 | x = max(iterable) |
|
902 | 906 | except (TypeError, ValueError): |
|
903 | 907 | # i18n: "max" is a keyword |
|
904 | 908 | raise error.ParseError(_("max first argument should be an iterable")) |
|
905 | 909 | return templatekw.wraphybridvalue(iterable, x, x) |
|
906 | 910 | |
|
907 | 911 | @templatefunc('min(iterable)') |
|
908 | 912 | def min_(context, mapping, args, **kwargs): |
|
909 | 913 | """Return the min of an iterable""" |
|
910 | 914 | if len(args) != 1: |
|
911 | 915 | # i18n: "min" is a keyword |
|
912 | 916 | raise error.ParseError(_("min expects one arguments")) |
|
913 | 917 | |
|
914 | 918 | iterable = evalfuncarg(context, mapping, args[0]) |
|
915 | 919 | try: |
|
916 | 920 | x = min(iterable) |
|
917 | 921 | except (TypeError, ValueError): |
|
918 | 922 | # i18n: "min" is a keyword |
|
919 | 923 | raise error.ParseError(_("min first argument should be an iterable")) |
|
920 | 924 | return templatekw.wraphybridvalue(iterable, x, x) |
|
921 | 925 | |
|
922 | 926 | @templatefunc('mod(a, b)') |
|
923 | 927 | def mod(context, mapping, args): |
|
924 | 928 | """Calculate a mod b such that a / b + a mod b == a""" |
|
925 | 929 | if not len(args) == 2: |
|
926 | 930 | # i18n: "mod" is a keyword |
|
927 | 931 | raise error.ParseError(_("mod expects two arguments")) |
|
928 | 932 | |
|
929 | 933 | func = lambda a, b: a % b |
|
930 | 934 | return runarithmetic(context, mapping, (func, args[0], args[1])) |
|
931 | 935 | |
|
932 | 936 | @templatefunc('obsfateoperations(markers)') |
|
933 | 937 | def obsfateoperations(context, mapping, args): |
|
934 | 938 | """Compute obsfate related information based on markers (EXPERIMENTAL)""" |
|
935 | 939 | if len(args) != 1: |
|
936 | 940 | # i18n: "obsfateoperations" is a keyword |
|
937 | 941 | raise error.ParseError(_("obsfateoperations expects one arguments")) |
|
938 | 942 | |
|
939 | 943 | markers = evalfuncarg(context, mapping, args[0]) |
|
940 | 944 | |
|
941 | 945 | try: |
|
942 | 946 | data = obsutil.markersoperations(markers) |
|
943 | 947 | return templatekw.hybridlist(data, name='operation') |
|
944 | 948 | except (TypeError, KeyError): |
|
945 | 949 | # i18n: "obsfateoperations" is a keyword |
|
946 | 950 | errmsg = _("obsfateoperations first argument should be an iterable") |
|
947 | 951 | raise error.ParseError(errmsg) |
|
948 | 952 | |
|
949 | 953 | @templatefunc('obsfatedate(markers)') |
|
950 | 954 | def obsfatedate(context, mapping, args): |
|
951 | 955 | """Compute obsfate related information based on markers (EXPERIMENTAL)""" |
|
952 | 956 | if len(args) != 1: |
|
953 | 957 | # i18n: "obsfatedate" is a keyword |
|
954 | 958 | raise error.ParseError(_("obsfatedate expects one arguments")) |
|
955 | 959 | |
|
956 | 960 | markers = evalfuncarg(context, mapping, args[0]) |
|
957 | 961 | |
|
958 | 962 | try: |
|
959 | 963 | data = obsutil.markersdates(markers) |
|
960 | 964 | return templatekw.hybridlist(data, name='date', fmt='%d %d') |
|
961 | 965 | except (TypeError, KeyError): |
|
962 | 966 | # i18n: "obsfatedate" is a keyword |
|
963 | 967 | errmsg = _("obsfatedate first argument should be an iterable") |
|
964 | 968 | raise error.ParseError(errmsg) |
|
965 | 969 | |
|
966 | 970 | @templatefunc('obsfateusers(markers)') |
|
967 | 971 | def obsfateusers(context, mapping, args): |
|
968 | 972 | """Compute obsfate related information based on markers (EXPERIMENTAL)""" |
|
969 | 973 | if len(args) != 1: |
|
970 | 974 | # i18n: "obsfateusers" is a keyword |
|
971 | 975 | raise error.ParseError(_("obsfateusers expects one arguments")) |
|
972 | 976 | |
|
973 | 977 | markers = evalfuncarg(context, mapping, args[0]) |
|
974 | 978 | |
|
975 | 979 | try: |
|
976 | 980 | data = obsutil.markersusers(markers) |
|
977 | 981 | return templatekw.hybridlist(data, name='user') |
|
978 | 982 | except (TypeError, KeyError, ValueError): |
|
979 | 983 | # i18n: "obsfateusers" is a keyword |
|
980 | 984 | msg = _("obsfateusers first argument should be an iterable of " |
|
981 | 985 | "obsmakers") |
|
982 | 986 | raise error.ParseError(msg) |
|
983 | 987 | |
|
984 | 988 | @templatefunc('obsfateverb(successors)') |
|
985 | 989 | def obsfateverb(context, mapping, args): |
|
986 | 990 | """Compute obsfate related information based on successors (EXPERIMENTAL)""" |
|
987 | 991 | if len(args) != 1: |
|
988 | 992 | # i18n: "obsfateverb" is a keyword |
|
989 | 993 | raise error.ParseError(_("obsfateverb expects one arguments")) |
|
990 | 994 | |
|
991 | 995 | successors = evalfuncarg(context, mapping, args[0]) |
|
992 | 996 | |
|
993 | 997 | try: |
|
994 | 998 | return obsutil.successorsetverb(successors) |
|
995 | 999 | except TypeError: |
|
996 | 1000 | # i18n: "obsfateverb" is a keyword |
|
997 | 1001 | errmsg = _("obsfateverb first argument should be countable") |
|
998 | 1002 | raise error.ParseError(errmsg) |
|
999 | 1003 | |
|
1000 | 1004 | @templatefunc('relpath(path)') |
|
1001 | 1005 | def relpath(context, mapping, args): |
|
1002 | 1006 | """Convert a repository-absolute path into a filesystem path relative to |
|
1003 | 1007 | the current working directory.""" |
|
1004 | 1008 | if len(args) != 1: |
|
1005 | 1009 | # i18n: "relpath" is a keyword |
|
1006 | 1010 | raise error.ParseError(_("relpath expects one argument")) |
|
1007 | 1011 | |
|
1008 | 1012 | repo = mapping['ctx'].repo() |
|
1009 | 1013 | path = evalstring(context, mapping, args[0]) |
|
1010 | 1014 | return repo.pathto(path) |
|
1011 | 1015 | |
|
1012 | 1016 | @templatefunc('revset(query[, formatargs...])') |
|
1013 | 1017 | def revset(context, mapping, args): |
|
1014 | 1018 | """Execute a revision set query. See |
|
1015 | 1019 | :hg:`help revset`.""" |
|
1016 | 1020 | if not len(args) > 0: |
|
1017 | 1021 | # i18n: "revset" is a keyword |
|
1018 | 1022 | raise error.ParseError(_("revset expects one or more arguments")) |
|
1019 | 1023 | |
|
1020 | 1024 | raw = evalstring(context, mapping, args[0]) |
|
1021 | 1025 | ctx = mapping['ctx'] |
|
1022 | 1026 | repo = ctx.repo() |
|
1023 | 1027 | |
|
1024 | 1028 | def query(expr): |
|
1025 | 1029 | m = revsetmod.match(repo.ui, expr, repo=repo) |
|
1026 | 1030 | return m(repo) |
|
1027 | 1031 | |
|
1028 | 1032 | if len(args) > 1: |
|
1029 | 1033 | formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]] |
|
1030 | 1034 | revs = query(revsetlang.formatspec(raw, *formatargs)) |
|
1031 | 1035 | revs = list(revs) |
|
1032 | 1036 | else: |
|
1033 | 1037 | revsetcache = mapping['cache'].setdefault("revsetcache", {}) |
|
1034 | 1038 | if raw in revsetcache: |
|
1035 | 1039 | revs = revsetcache[raw] |
|
1036 | 1040 | else: |
|
1037 | 1041 | revs = query(raw) |
|
1038 | 1042 | revs = list(revs) |
|
1039 | 1043 | revsetcache[raw] = revs |
|
1040 | 1044 | |
|
1041 | 1045 | return templatekw.showrevslist("revision", revs, **mapping) |
|
1042 | 1046 | |
|
1043 | 1047 | @templatefunc('rstdoc(text, style)') |
|
1044 | 1048 | def rstdoc(context, mapping, args): |
|
1045 | 1049 | """Format reStructuredText.""" |
|
1046 | 1050 | if len(args) != 2: |
|
1047 | 1051 | # i18n: "rstdoc" is a keyword |
|
1048 | 1052 | raise error.ParseError(_("rstdoc expects two arguments")) |
|
1049 | 1053 | |
|
1050 | 1054 | text = evalstring(context, mapping, args[0]) |
|
1051 | 1055 | style = evalstring(context, mapping, args[1]) |
|
1052 | 1056 | |
|
1053 | 1057 | return minirst.format(text, style=style, keep=['verbose']) |
|
1054 | 1058 | |
|
1055 | 1059 | @templatefunc('separate(sep, args)', argspec='sep *args') |
|
1056 | 1060 | def separate(context, mapping, args): |
|
1057 | 1061 | """Add a separator between non-empty arguments.""" |
|
1058 | 1062 | if 'sep' not in args: |
|
1059 | 1063 | # i18n: "separate" is a keyword |
|
1060 | 1064 | raise error.ParseError(_("separate expects at least one argument")) |
|
1061 | 1065 | |
|
1062 | 1066 | sep = evalstring(context, mapping, args['sep']) |
|
1063 | 1067 | first = True |
|
1064 | 1068 | for arg in args['args']: |
|
1065 | 1069 | argstr = evalstring(context, mapping, arg) |
|
1066 | 1070 | if not argstr: |
|
1067 | 1071 | continue |
|
1068 | 1072 | if first: |
|
1069 | 1073 | first = False |
|
1070 | 1074 | else: |
|
1071 | 1075 | yield sep |
|
1072 | 1076 | yield argstr |
|
1073 | 1077 | |
|
1074 | 1078 | @templatefunc('shortest(node, minlength=4)') |
|
1075 | 1079 | def shortest(context, mapping, args): |
|
1076 | 1080 | """Obtain the shortest representation of |
|
1077 | 1081 | a node.""" |
|
1078 | 1082 | if not (1 <= len(args) <= 2): |
|
1079 | 1083 | # i18n: "shortest" is a keyword |
|
1080 | 1084 | raise error.ParseError(_("shortest() expects one or two arguments")) |
|
1081 | 1085 | |
|
1082 | 1086 | node = evalstring(context, mapping, args[0]) |
|
1083 | 1087 | |
|
1084 | 1088 | minlength = 4 |
|
1085 | 1089 | if len(args) > 1: |
|
1086 | 1090 | minlength = evalinteger(context, mapping, args[1], |
|
1087 | 1091 | # i18n: "shortest" is a keyword |
|
1088 | 1092 | _("shortest() expects an integer minlength")) |
|
1089 | 1093 | |
|
1090 | 1094 | # _partialmatch() of filtered changelog could take O(len(repo)) time, |
|
1091 | 1095 | # which would be unacceptably slow. so we look for hash collision in |
|
1092 | 1096 | # unfiltered space, which means some hashes may be slightly longer. |
|
1093 | 1097 | cl = mapping['ctx']._repo.unfiltered().changelog |
|
1094 | 1098 | return cl.shortest(node, minlength) |
|
1095 | 1099 | |
|
1096 | 1100 | @templatefunc('strip(text[, chars])') |
|
1097 | 1101 | def strip(context, mapping, args): |
|
1098 | 1102 | """Strip characters from a string. By default, |
|
1099 | 1103 | strips all leading and trailing whitespace.""" |
|
1100 | 1104 | if not (1 <= len(args) <= 2): |
|
1101 | 1105 | # i18n: "strip" is a keyword |
|
1102 | 1106 | raise error.ParseError(_("strip expects one or two arguments")) |
|
1103 | 1107 | |
|
1104 | 1108 | text = evalstring(context, mapping, args[0]) |
|
1105 | 1109 | if len(args) == 2: |
|
1106 | 1110 | chars = evalstring(context, mapping, args[1]) |
|
1107 | 1111 | return text.strip(chars) |
|
1108 | 1112 | return text.strip() |
|
1109 | 1113 | |
|
1110 | 1114 | @templatefunc('sub(pattern, replacement, expression)') |
|
1111 | 1115 | def sub(context, mapping, args): |
|
1112 | 1116 | """Perform text substitution |
|
1113 | 1117 | using regular expressions.""" |
|
1114 | 1118 | if len(args) != 3: |
|
1115 | 1119 | # i18n: "sub" is a keyword |
|
1116 | 1120 | raise error.ParseError(_("sub expects three arguments")) |
|
1117 | 1121 | |
|
1118 | 1122 | pat = evalstring(context, mapping, args[0]) |
|
1119 | 1123 | rpl = evalstring(context, mapping, args[1]) |
|
1120 | 1124 | src = evalstring(context, mapping, args[2]) |
|
1121 | 1125 | try: |
|
1122 | 1126 | patre = re.compile(pat) |
|
1123 | 1127 | except re.error: |
|
1124 | 1128 | # i18n: "sub" is a keyword |
|
1125 | 1129 | raise error.ParseError(_("sub got an invalid pattern: %s") % pat) |
|
1126 | 1130 | try: |
|
1127 | 1131 | yield patre.sub(rpl, src) |
|
1128 | 1132 | except re.error: |
|
1129 | 1133 | # i18n: "sub" is a keyword |
|
1130 | 1134 | raise error.ParseError(_("sub got an invalid replacement: %s") % rpl) |
|
1131 | 1135 | |
|
1132 | 1136 | @templatefunc('startswith(pattern, text)') |
|
1133 | 1137 | def startswith(context, mapping, args): |
|
1134 | 1138 | """Returns the value from the "text" argument |
|
1135 | 1139 | if it begins with the content from the "pattern" argument.""" |
|
1136 | 1140 | if len(args) != 2: |
|
1137 | 1141 | # i18n: "startswith" is a keyword |
|
1138 | 1142 | raise error.ParseError(_("startswith expects two arguments")) |
|
1139 | 1143 | |
|
1140 | 1144 | patn = evalstring(context, mapping, args[0]) |
|
1141 | 1145 | text = evalstring(context, mapping, args[1]) |
|
1142 | 1146 | if text.startswith(patn): |
|
1143 | 1147 | return text |
|
1144 | 1148 | return '' |
|
1145 | 1149 | |
|
1146 | 1150 | @templatefunc('word(number, text[, separator])') |
|
1147 | 1151 | def word(context, mapping, args): |
|
1148 | 1152 | """Return the nth word from a string.""" |
|
1149 | 1153 | if not (2 <= len(args) <= 3): |
|
1150 | 1154 | # i18n: "word" is a keyword |
|
1151 | 1155 | raise error.ParseError(_("word expects two or three arguments, got %d") |
|
1152 | 1156 | % len(args)) |
|
1153 | 1157 | |
|
1154 | 1158 | num = evalinteger(context, mapping, args[0], |
|
1155 | 1159 | # i18n: "word" is a keyword |
|
1156 | 1160 | _("word expects an integer index")) |
|
1157 | 1161 | text = evalstring(context, mapping, args[1]) |
|
1158 | 1162 | if len(args) == 3: |
|
1159 | 1163 | splitter = evalstring(context, mapping, args[2]) |
|
1160 | 1164 | else: |
|
1161 | 1165 | splitter = None |
|
1162 | 1166 | |
|
1163 | 1167 | tokens = text.split(splitter) |
|
1164 | 1168 | if num >= len(tokens) or num < -len(tokens): |
|
1165 | 1169 | return '' |
|
1166 | 1170 | else: |
|
1167 | 1171 | return tokens[num] |
|
1168 | 1172 | |
|
1169 | 1173 | # methods to interpret function arguments or inner expressions (e.g. {_(x)}) |
|
1170 | 1174 | exprmethods = { |
|
1171 | 1175 | "integer": lambda e, c: (runinteger, e[1]), |
|
1172 | 1176 | "string": lambda e, c: (runstring, e[1]), |
|
1173 | 1177 | "symbol": lambda e, c: (runsymbol, e[1]), |
|
1174 | 1178 | "template": buildtemplate, |
|
1175 | 1179 | "group": lambda e, c: compileexp(e[1], c, exprmethods), |
|
1176 | 1180 | ".": buildmember, |
|
1177 | 1181 | "|": buildfilter, |
|
1178 | 1182 | "%": buildmap, |
|
1179 | 1183 | "func": buildfunc, |
|
1180 | 1184 | "keyvalue": buildkeyvaluepair, |
|
1181 | 1185 | "+": lambda e, c: buildarithmetic(e, c, lambda a, b: a + b), |
|
1182 | 1186 | "-": lambda e, c: buildarithmetic(e, c, lambda a, b: a - b), |
|
1183 | 1187 | "negate": buildnegate, |
|
1184 | 1188 | "*": lambda e, c: buildarithmetic(e, c, lambda a, b: a * b), |
|
1185 | 1189 | "/": lambda e, c: buildarithmetic(e, c, lambda a, b: a // b), |
|
1186 | 1190 | } |
|
1187 | 1191 | |
|
1188 | 1192 | # methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"}) |
|
1189 | 1193 | methods = exprmethods.copy() |
|
1190 | 1194 | methods["integer"] = exprmethods["symbol"] # '{1}' as variable |
|
1191 | 1195 | |
|
1192 | 1196 | class _aliasrules(parser.basealiasrules): |
|
1193 | 1197 | """Parsing and expansion rule set of template aliases""" |
|
1194 | 1198 | _section = _('template alias') |
|
1195 | 1199 | _parse = staticmethod(_parseexpr) |
|
1196 | 1200 | |
|
1197 | 1201 | @staticmethod |
|
1198 | 1202 | def _trygetfunc(tree): |
|
1199 | 1203 | """Return (name, args) if tree is func(...) or ...|filter; otherwise |
|
1200 | 1204 | None""" |
|
1201 | 1205 | if tree[0] == 'func' and tree[1][0] == 'symbol': |
|
1202 | 1206 | return tree[1][1], getlist(tree[2]) |
|
1203 | 1207 | if tree[0] == '|' and tree[2][0] == 'symbol': |
|
1204 | 1208 | return tree[2][1], [tree[1]] |
|
1205 | 1209 | |
|
1206 | 1210 | def expandaliases(tree, aliases): |
|
1207 | 1211 | """Return new tree of aliases are expanded""" |
|
1208 | 1212 | aliasmap = _aliasrules.buildmap(aliases) |
|
1209 | 1213 | return _aliasrules.expand(aliasmap, tree) |
|
1210 | 1214 | |
|
1211 | 1215 | # template engine |
|
1212 | 1216 | |
|
1213 | 1217 | stringify = templatefilters.stringify |
|
1214 | 1218 | |
|
1215 | 1219 | def _flatten(thing): |
|
1216 | 1220 | '''yield a single stream from a possibly nested set of iterators''' |
|
1217 | 1221 | thing = templatekw.unwraphybrid(thing) |
|
1218 | 1222 | if isinstance(thing, bytes): |
|
1219 | 1223 | yield thing |
|
1220 | 1224 | elif thing is None: |
|
1221 | 1225 | pass |
|
1222 | 1226 | elif not util.safehasattr(thing, '__iter__'): |
|
1223 | 1227 | yield pycompat.bytestr(thing) |
|
1224 | 1228 | else: |
|
1225 | 1229 | for i in thing: |
|
1226 | 1230 | i = templatekw.unwraphybrid(i) |
|
1227 | 1231 | if isinstance(i, bytes): |
|
1228 | 1232 | yield i |
|
1229 | 1233 | elif i is None: |
|
1230 | 1234 | pass |
|
1231 | 1235 | elif not util.safehasattr(i, '__iter__'): |
|
1232 | 1236 | yield pycompat.bytestr(i) |
|
1233 | 1237 | else: |
|
1234 | 1238 | for j in _flatten(i): |
|
1235 | 1239 | yield j |
|
1236 | 1240 | |
|
1237 | 1241 | def unquotestring(s): |
|
1238 | 1242 | '''unwrap quotes if any; otherwise returns unmodified string''' |
|
1239 | 1243 | if len(s) < 2 or s[0] not in "'\"" or s[0] != s[-1]: |
|
1240 | 1244 | return s |
|
1241 | 1245 | return s[1:-1] |
|
1242 | 1246 | |
|
1243 | 1247 | class engine(object): |
|
1244 | 1248 | '''template expansion engine. |
|
1245 | 1249 | |
|
1246 | 1250 | template expansion works like this. a map file contains key=value |
|
1247 | 1251 | pairs. if value is quoted, it is treated as string. otherwise, it |
|
1248 | 1252 | is treated as name of template file. |
|
1249 | 1253 | |
|
1250 | 1254 | templater is asked to expand a key in map. it looks up key, and |
|
1251 | 1255 | looks for strings like this: {foo}. it expands {foo} by looking up |
|
1252 | 1256 | foo in map, and substituting it. expansion is recursive: it stops |
|
1253 | 1257 | when there is no more {foo} to replace. |
|
1254 | 1258 | |
|
1255 | 1259 | expansion also allows formatting and filtering. |
|
1256 | 1260 | |
|
1257 | 1261 | format uses key to expand each item in list. syntax is |
|
1258 | 1262 | {key%format}. |
|
1259 | 1263 | |
|
1260 | 1264 | filter uses function to transform value. syntax is |
|
1261 | 1265 | {key|filter1|filter2|...}.''' |
|
1262 | 1266 | |
|
1263 | 1267 | def __init__(self, loader, filters=None, defaults=None, aliases=()): |
|
1264 | 1268 | self._loader = loader |
|
1265 | 1269 | if filters is None: |
|
1266 | 1270 | filters = {} |
|
1267 | 1271 | self._filters = filters |
|
1268 | 1272 | if defaults is None: |
|
1269 | 1273 | defaults = {} |
|
1270 | 1274 | self._defaults = defaults |
|
1271 | 1275 | self._aliasmap = _aliasrules.buildmap(aliases) |
|
1272 | 1276 | self._cache = {} # key: (func, data) |
|
1273 | 1277 | |
|
1274 | 1278 | def _load(self, t): |
|
1275 | 1279 | '''load, parse, and cache a template''' |
|
1276 | 1280 | if t not in self._cache: |
|
1277 | 1281 | # put poison to cut recursion while compiling 't' |
|
1278 | 1282 | self._cache[t] = (_runrecursivesymbol, t) |
|
1279 | 1283 | try: |
|
1280 | 1284 | x = parse(self._loader(t)) |
|
1281 | 1285 | if self._aliasmap: |
|
1282 | 1286 | x = _aliasrules.expand(self._aliasmap, x) |
|
1283 | 1287 | self._cache[t] = compileexp(x, self, methods) |
|
1284 | 1288 | except: # re-raises |
|
1285 | 1289 | del self._cache[t] |
|
1286 | 1290 | raise |
|
1287 | 1291 | return self._cache[t] |
|
1288 | 1292 | |
|
1289 | 1293 | def process(self, t, mapping): |
|
1290 | 1294 | '''Perform expansion. t is name of map element to expand. |
|
1291 | 1295 | mapping contains added elements for use during expansion. Is a |
|
1292 | 1296 | generator.''' |
|
1293 | 1297 | func, data = self._load(t) |
|
1294 | 1298 | return _flatten(func(self, mapping, data)) |
|
1295 | 1299 | |
|
1296 | 1300 | engines = {'default': engine} |
|
1297 | 1301 | |
|
1298 | 1302 | def stylelist(): |
|
1299 | 1303 | paths = templatepaths() |
|
1300 | 1304 | if not paths: |
|
1301 | 1305 | return _('no templates found, try `hg debuginstall` for more info') |
|
1302 | 1306 | dirlist = os.listdir(paths[0]) |
|
1303 | 1307 | stylelist = [] |
|
1304 | 1308 | for file in dirlist: |
|
1305 | 1309 | split = file.split(".") |
|
1306 | 1310 | if split[-1] in ('orig', 'rej'): |
|
1307 | 1311 | continue |
|
1308 | 1312 | if split[0] == "map-cmdline": |
|
1309 | 1313 | stylelist.append(split[1]) |
|
1310 | 1314 | return ", ".join(sorted(stylelist)) |
|
1311 | 1315 | |
|
1312 | 1316 | def _readmapfile(mapfile): |
|
1313 | 1317 | """Load template elements from the given map file""" |
|
1314 | 1318 | if not os.path.exists(mapfile): |
|
1315 | 1319 | raise error.Abort(_("style '%s' not found") % mapfile, |
|
1316 | 1320 | hint=_("available styles: %s") % stylelist()) |
|
1317 | 1321 | |
|
1318 | 1322 | base = os.path.dirname(mapfile) |
|
1319 | 1323 | conf = config.config(includepaths=templatepaths()) |
|
1320 | 1324 | conf.read(mapfile) |
|
1321 | 1325 | |
|
1322 | 1326 | cache = {} |
|
1323 | 1327 | tmap = {} |
|
1324 | 1328 | for key, val in conf[''].items(): |
|
1325 | 1329 | if not val: |
|
1326 | 1330 | raise error.ParseError(_('missing value'), conf.source('', key)) |
|
1327 | 1331 | if val[0] in "'\"": |
|
1328 | 1332 | if val[0] != val[-1]: |
|
1329 | 1333 | raise error.ParseError(_('unmatched quotes'), |
|
1330 | 1334 | conf.source('', key)) |
|
1331 | 1335 | cache[key] = unquotestring(val) |
|
1332 | 1336 | elif key == "__base__": |
|
1333 | 1337 | # treat as a pointer to a base class for this style |
|
1334 | 1338 | path = util.normpath(os.path.join(base, val)) |
|
1335 | 1339 | |
|
1336 | 1340 | # fallback check in template paths |
|
1337 | 1341 | if not os.path.exists(path): |
|
1338 | 1342 | for p in templatepaths(): |
|
1339 | 1343 | p2 = util.normpath(os.path.join(p, val)) |
|
1340 | 1344 | if os.path.isfile(p2): |
|
1341 | 1345 | path = p2 |
|
1342 | 1346 | break |
|
1343 | 1347 | p3 = util.normpath(os.path.join(p2, "map")) |
|
1344 | 1348 | if os.path.isfile(p3): |
|
1345 | 1349 | path = p3 |
|
1346 | 1350 | break |
|
1347 | 1351 | |
|
1348 | 1352 | bcache, btmap = _readmapfile(path) |
|
1349 | 1353 | for k in bcache: |
|
1350 | 1354 | if k not in cache: |
|
1351 | 1355 | cache[k] = bcache[k] |
|
1352 | 1356 | for k in btmap: |
|
1353 | 1357 | if k not in tmap: |
|
1354 | 1358 | tmap[k] = btmap[k] |
|
1355 | 1359 | else: |
|
1356 | 1360 | val = 'default', val |
|
1357 | 1361 | if ':' in val[1]: |
|
1358 | 1362 | val = val[1].split(':', 1) |
|
1359 | 1363 | tmap[key] = val[0], os.path.join(base, val[1]) |
|
1360 | 1364 | return cache, tmap |
|
1361 | 1365 | |
|
1362 | 1366 | class TemplateNotFound(error.Abort): |
|
1363 | 1367 | pass |
|
1364 | 1368 | |
|
1365 | 1369 | class templater(object): |
|
1366 | 1370 | |
|
1367 | 1371 | def __init__(self, filters=None, defaults=None, cache=None, aliases=(), |
|
1368 | 1372 | minchunk=1024, maxchunk=65536): |
|
1369 | 1373 | '''set up template engine. |
|
1370 | 1374 | filters is dict of functions. each transforms a value into another. |
|
1371 | 1375 | defaults is dict of default map definitions. |
|
1372 | 1376 | aliases is list of alias (name, replacement) pairs. |
|
1373 | 1377 | ''' |
|
1374 | 1378 | if filters is None: |
|
1375 | 1379 | filters = {} |
|
1376 | 1380 | if defaults is None: |
|
1377 | 1381 | defaults = {} |
|
1378 | 1382 | if cache is None: |
|
1379 | 1383 | cache = {} |
|
1380 | 1384 | self.cache = cache.copy() |
|
1381 | 1385 | self.map = {} |
|
1382 | 1386 | self.filters = templatefilters.filters.copy() |
|
1383 | 1387 | self.filters.update(filters) |
|
1384 | 1388 | self.defaults = defaults |
|
1385 | 1389 | self._aliases = aliases |
|
1386 | 1390 | self.minchunk, self.maxchunk = minchunk, maxchunk |
|
1387 | 1391 | self.ecache = {} |
|
1388 | 1392 | |
|
1389 | 1393 | @classmethod |
|
1390 | 1394 | def frommapfile(cls, mapfile, filters=None, defaults=None, cache=None, |
|
1391 | 1395 | minchunk=1024, maxchunk=65536): |
|
1392 | 1396 | """Create templater from the specified map file""" |
|
1393 | 1397 | t = cls(filters, defaults, cache, [], minchunk, maxchunk) |
|
1394 | 1398 | cache, tmap = _readmapfile(mapfile) |
|
1395 | 1399 | t.cache.update(cache) |
|
1396 | 1400 | t.map = tmap |
|
1397 | 1401 | return t |
|
1398 | 1402 | |
|
1399 | 1403 | def __contains__(self, key): |
|
1400 | 1404 | return key in self.cache or key in self.map |
|
1401 | 1405 | |
|
1402 | 1406 | def load(self, t): |
|
1403 | 1407 | '''Get the template for the given template name. Use a local cache.''' |
|
1404 | 1408 | if t not in self.cache: |
|
1405 | 1409 | try: |
|
1406 | 1410 | self.cache[t] = util.readfile(self.map[t][1]) |
|
1407 | 1411 | except KeyError as inst: |
|
1408 | 1412 | raise TemplateNotFound(_('"%s" not in template map') % |
|
1409 | 1413 | inst.args[0]) |
|
1410 | 1414 | except IOError as inst: |
|
1411 | 1415 | raise IOError(inst.args[0], _('template file %s: %s') % |
|
1412 | 1416 | (self.map[t][1], inst.args[1])) |
|
1413 | 1417 | return self.cache[t] |
|
1414 | 1418 | |
|
1415 | 1419 | def render(self, mapping): |
|
1416 | 1420 | """Render the default unnamed template and return result as string""" |
|
1417 | 1421 | mapping = pycompat.strkwargs(mapping) |
|
1418 | 1422 | return stringify(self('', **mapping)) |
|
1419 | 1423 | |
|
1420 | 1424 | def __call__(self, t, **mapping): |
|
1421 | 1425 | mapping = pycompat.byteskwargs(mapping) |
|
1422 | 1426 | ttype = t in self.map and self.map[t][0] or 'default' |
|
1423 | 1427 | if ttype not in self.ecache: |
|
1424 | 1428 | try: |
|
1425 | 1429 | ecls = engines[ttype] |
|
1426 | 1430 | except KeyError: |
|
1427 | 1431 | raise error.Abort(_('invalid template engine: %s') % ttype) |
|
1428 | 1432 | self.ecache[ttype] = ecls(self.load, self.filters, self.defaults, |
|
1429 | 1433 | self._aliases) |
|
1430 | 1434 | proc = self.ecache[ttype] |
|
1431 | 1435 | |
|
1432 | 1436 | stream = proc.process(t, mapping) |
|
1433 | 1437 | if self.minchunk: |
|
1434 | 1438 | stream = util.increasingchunks(stream, min=self.minchunk, |
|
1435 | 1439 | max=self.maxchunk) |
|
1436 | 1440 | return stream |
|
1437 | 1441 | |
|
1438 | 1442 | def templatepaths(): |
|
1439 | 1443 | '''return locations used for template files.''' |
|
1440 | 1444 | pathsrel = ['templates'] |
|
1441 | 1445 | paths = [os.path.normpath(os.path.join(util.datapath, f)) |
|
1442 | 1446 | for f in pathsrel] |
|
1443 | 1447 | return [p for p in paths if os.path.isdir(p)] |
|
1444 | 1448 | |
|
1445 | 1449 | def templatepath(name): |
|
1446 | 1450 | '''return location of template file. returns None if not found.''' |
|
1447 | 1451 | for p in templatepaths(): |
|
1448 | 1452 | f = os.path.join(p, name) |
|
1449 | 1453 | if os.path.exists(f): |
|
1450 | 1454 | return f |
|
1451 | 1455 | return None |
|
1452 | 1456 | |
|
1453 | 1457 | def stylemap(styles, paths=None): |
|
1454 | 1458 | """Return path to mapfile for a given style. |
|
1455 | 1459 | |
|
1456 | 1460 | Searches mapfile in the following locations: |
|
1457 | 1461 | 1. templatepath/style/map |
|
1458 | 1462 | 2. templatepath/map-style |
|
1459 | 1463 | 3. templatepath/map |
|
1460 | 1464 | """ |
|
1461 | 1465 | |
|
1462 | 1466 | if paths is None: |
|
1463 | 1467 | paths = templatepaths() |
|
1464 | 1468 | elif isinstance(paths, str): |
|
1465 | 1469 | paths = [paths] |
|
1466 | 1470 | |
|
1467 | 1471 | if isinstance(styles, str): |
|
1468 | 1472 | styles = [styles] |
|
1469 | 1473 | |
|
1470 | 1474 | for style in styles: |
|
1471 | 1475 | # only plain name is allowed to honor template paths |
|
1472 | 1476 | if (not style |
|
1473 | 1477 | or style in (os.curdir, os.pardir) |
|
1474 | 1478 | or pycompat.ossep in style |
|
1475 | 1479 | or pycompat.osaltsep and pycompat.osaltsep in style): |
|
1476 | 1480 | continue |
|
1477 | 1481 | locations = [os.path.join(style, 'map'), 'map-' + style] |
|
1478 | 1482 | locations.append('map') |
|
1479 | 1483 | |
|
1480 | 1484 | for path in paths: |
|
1481 | 1485 | for location in locations: |
|
1482 | 1486 | mapfile = os.path.join(path, location) |
|
1483 | 1487 | if os.path.isfile(mapfile): |
|
1484 | 1488 | return style, mapfile |
|
1485 | 1489 | |
|
1486 | 1490 | raise RuntimeError("No hgweb templates found in %r" % paths) |
|
1487 | 1491 | |
|
1488 | 1492 | def loadfunction(ui, extname, registrarobj): |
|
1489 | 1493 | """Load template function from specified registrarobj |
|
1490 | 1494 | """ |
|
1491 | 1495 | for name, func in registrarobj._table.iteritems(): |
|
1492 | 1496 | funcs[name] = func |
|
1493 | 1497 | |
|
1494 | 1498 | # tell hggettext to extract docstrings from these functions: |
|
1495 | 1499 | i18nfunctions = funcs.values() |
@@ -1,4658 +1,4660 | |||
|
1 | 1 | $ hg init a |
|
2 | 2 | $ cd a |
|
3 | 3 | $ echo a > a |
|
4 | 4 | $ hg add a |
|
5 | 5 | $ echo line 1 > b |
|
6 | 6 | $ echo line 2 >> b |
|
7 | 7 | $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>' |
|
8 | 8 | |
|
9 | 9 | $ hg add b |
|
10 | 10 | $ echo other 1 > c |
|
11 | 11 | $ echo other 2 >> c |
|
12 | 12 | $ echo >> c |
|
13 | 13 | $ echo other 3 >> c |
|
14 | 14 | $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>' |
|
15 | 15 | |
|
16 | 16 | $ hg add c |
|
17 | 17 | $ hg commit -m 'no person' -d '1200000 0' -u 'other@place' |
|
18 | 18 | $ echo c >> c |
|
19 | 19 | $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person' |
|
20 | 20 | |
|
21 | 21 | $ echo foo > .hg/branch |
|
22 | 22 | $ hg commit -m 'new branch' -d '1400000 0' -u 'person' |
|
23 | 23 | |
|
24 | 24 | $ hg co -q 3 |
|
25 | 25 | $ echo other 4 >> d |
|
26 | 26 | $ hg add d |
|
27 | 27 | $ hg commit -m 'new head' -d '1500000 0' -u 'person' |
|
28 | 28 | |
|
29 | 29 | $ hg merge -q foo |
|
30 | 30 | $ hg commit -m 'merge' -d '1500001 0' -u 'person' |
|
31 | 31 | |
|
32 | 32 | Test arithmetic operators have the right precedence: |
|
33 | 33 | |
|
34 | 34 | $ hg log -l 1 -T '{date(date, "%Y") + 5 * 10} {date(date, "%Y") - 2 * 3}\n' |
|
35 | 35 | 2020 1964 |
|
36 | 36 | $ hg log -l 1 -T '{date(date, "%Y") * 5 + 10} {date(date, "%Y") * 3 - 2}\n' |
|
37 | 37 | 9860 5908 |
|
38 | 38 | |
|
39 | 39 | Test division: |
|
40 | 40 | |
|
41 | 41 | $ hg debugtemplate -r0 -v '{5 / 2} {mod(5, 2)}\n' |
|
42 | 42 | (template |
|
43 | 43 | (/ |
|
44 | 44 | (integer '5') |
|
45 | 45 | (integer '2')) |
|
46 | 46 | (string ' ') |
|
47 | 47 | (func |
|
48 | 48 | (symbol 'mod') |
|
49 | 49 | (list |
|
50 | 50 | (integer '5') |
|
51 | 51 | (integer '2'))) |
|
52 | 52 | (string '\n')) |
|
53 | 53 | 2 1 |
|
54 | 54 | $ hg debugtemplate -r0 -v '{5 / -2} {mod(5, -2)}\n' |
|
55 | 55 | (template |
|
56 | 56 | (/ |
|
57 | 57 | (integer '5') |
|
58 | 58 | (negate |
|
59 | 59 | (integer '2'))) |
|
60 | 60 | (string ' ') |
|
61 | 61 | (func |
|
62 | 62 | (symbol 'mod') |
|
63 | 63 | (list |
|
64 | 64 | (integer '5') |
|
65 | 65 | (negate |
|
66 | 66 | (integer '2')))) |
|
67 | 67 | (string '\n')) |
|
68 | 68 | -3 -1 |
|
69 | 69 | $ hg debugtemplate -r0 -v '{-5 / 2} {mod(-5, 2)}\n' |
|
70 | 70 | (template |
|
71 | 71 | (/ |
|
72 | 72 | (negate |
|
73 | 73 | (integer '5')) |
|
74 | 74 | (integer '2')) |
|
75 | 75 | (string ' ') |
|
76 | 76 | (func |
|
77 | 77 | (symbol 'mod') |
|
78 | 78 | (list |
|
79 | 79 | (negate |
|
80 | 80 | (integer '5')) |
|
81 | 81 | (integer '2'))) |
|
82 | 82 | (string '\n')) |
|
83 | 83 | -3 1 |
|
84 | 84 | $ hg debugtemplate -r0 -v '{-5 / -2} {mod(-5, -2)}\n' |
|
85 | 85 | (template |
|
86 | 86 | (/ |
|
87 | 87 | (negate |
|
88 | 88 | (integer '5')) |
|
89 | 89 | (negate |
|
90 | 90 | (integer '2'))) |
|
91 | 91 | (string ' ') |
|
92 | 92 | (func |
|
93 | 93 | (symbol 'mod') |
|
94 | 94 | (list |
|
95 | 95 | (negate |
|
96 | 96 | (integer '5')) |
|
97 | 97 | (negate |
|
98 | 98 | (integer '2')))) |
|
99 | 99 | (string '\n')) |
|
100 | 100 | 2 -1 |
|
101 | 101 | |
|
102 | 102 | Filters bind closer than arithmetic: |
|
103 | 103 | |
|
104 | 104 | $ hg debugtemplate -r0 -v '{revset(".")|count - 1}\n' |
|
105 | 105 | (template |
|
106 | 106 | (- |
|
107 | 107 | (| |
|
108 | 108 | (func |
|
109 | 109 | (symbol 'revset') |
|
110 | 110 | (string '.')) |
|
111 | 111 | (symbol 'count')) |
|
112 | 112 | (integer '1')) |
|
113 | 113 | (string '\n')) |
|
114 | 114 | 0 |
|
115 | 115 | |
|
116 | 116 | But negate binds closer still: |
|
117 | 117 | |
|
118 | 118 | $ hg debugtemplate -r0 -v '{1-3|stringify}\n' |
|
119 | 119 | (template |
|
120 | 120 | (- |
|
121 | 121 | (integer '1') |
|
122 | 122 | (| |
|
123 | 123 | (integer '3') |
|
124 | 124 | (symbol 'stringify'))) |
|
125 | 125 | (string '\n')) |
|
126 | 126 | hg: parse error: arithmetic only defined on integers |
|
127 | 127 | [255] |
|
128 | 128 | $ hg debugtemplate -r0 -v '{-3|stringify}\n' |
|
129 | 129 | (template |
|
130 | 130 | (| |
|
131 | 131 | (negate |
|
132 | 132 | (integer '3')) |
|
133 | 133 | (symbol 'stringify')) |
|
134 | 134 | (string '\n')) |
|
135 | 135 | -3 |
|
136 | 136 | |
|
137 | 137 | Filters bind as close as map operator: |
|
138 | 138 | |
|
139 | 139 | $ hg debugtemplate -r0 -v '{desc|splitlines % "{line}\n"}' |
|
140 | 140 | (template |
|
141 | 141 | (% |
|
142 | 142 | (| |
|
143 | 143 | (symbol 'desc') |
|
144 | 144 | (symbol 'splitlines')) |
|
145 | 145 | (template |
|
146 | 146 | (symbol 'line') |
|
147 | 147 | (string '\n')))) |
|
148 | 148 | line 1 |
|
149 | 149 | line 2 |
|
150 | 150 | |
|
151 | 151 | Keyword arguments: |
|
152 | 152 | |
|
153 | 153 | $ hg debugtemplate -r0 -v '{foo=bar|baz}' |
|
154 | 154 | (template |
|
155 | 155 | (keyvalue |
|
156 | 156 | (symbol 'foo') |
|
157 | 157 | (| |
|
158 | 158 | (symbol 'bar') |
|
159 | 159 | (symbol 'baz')))) |
|
160 | 160 | hg: parse error: can't use a key-value pair in this context |
|
161 | 161 | [255] |
|
162 | 162 | |
|
163 | 163 | $ hg debugtemplate '{pad("foo", width=10, left=true)}\n' |
|
164 | 164 | foo |
|
165 | 165 | |
|
166 | 166 | Call function which takes named arguments by filter syntax: |
|
167 | 167 | |
|
168 | 168 | $ hg debugtemplate '{" "|separate}' |
|
169 | 169 | $ hg debugtemplate '{("not", "an", "argument", "list")|separate}' |
|
170 | 170 | hg: parse error: unknown method 'list' |
|
171 | 171 | [255] |
|
172 | 172 | |
|
173 | 173 | Second branch starting at nullrev: |
|
174 | 174 | |
|
175 | 175 | $ hg update null |
|
176 | 176 | 0 files updated, 0 files merged, 4 files removed, 0 files unresolved |
|
177 | 177 | $ echo second > second |
|
178 | 178 | $ hg add second |
|
179 | 179 | $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>' |
|
180 | 180 | created new head |
|
181 | 181 | |
|
182 | 182 | $ echo third > third |
|
183 | 183 | $ hg add third |
|
184 | 184 | $ hg mv second fourth |
|
185 | 185 | $ hg commit -m third -d "2020-01-01 10:01" |
|
186 | 186 | |
|
187 | 187 | $ hg log --template '{join(file_copies, ",\n")}\n' -r . |
|
188 | 188 | fourth (second) |
|
189 | 189 | $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r . |
|
190 | 190 | second -> fourth |
|
191 | 191 | $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7 |
|
192 | 192 | 8 t |
|
193 | 193 | 7 f |
|
194 | 194 | |
|
195 | 195 | Working-directory revision has special identifiers, though they are still |
|
196 | 196 | experimental: |
|
197 | 197 | |
|
198 | 198 | $ hg log -r 'wdir()' -T '{rev}:{node}\n' |
|
199 | 199 | 2147483647:ffffffffffffffffffffffffffffffffffffffff |
|
200 | 200 | |
|
201 | 201 | Some keywords are invalid for working-directory revision, but they should |
|
202 | 202 | never cause crash: |
|
203 | 203 | |
|
204 | 204 | $ hg log -r 'wdir()' -T '{manifest}\n' |
|
205 | 205 | |
|
206 | 206 | |
|
207 | 207 | Quoting for ui.logtemplate |
|
208 | 208 | |
|
209 | 209 | $ hg tip --config "ui.logtemplate={rev}\n" |
|
210 | 210 | 8 |
|
211 | 211 | $ hg tip --config "ui.logtemplate='{rev}\n'" |
|
212 | 212 | 8 |
|
213 | 213 | $ hg tip --config 'ui.logtemplate="{rev}\n"' |
|
214 | 214 | 8 |
|
215 | 215 | $ hg tip --config 'ui.logtemplate=n{rev}\n' |
|
216 | 216 | n8 |
|
217 | 217 | |
|
218 | 218 | Make sure user/global hgrc does not affect tests |
|
219 | 219 | |
|
220 | 220 | $ echo '[ui]' > .hg/hgrc |
|
221 | 221 | $ echo 'logtemplate =' >> .hg/hgrc |
|
222 | 222 | $ echo 'style =' >> .hg/hgrc |
|
223 | 223 | |
|
224 | 224 | Add some simple styles to settings |
|
225 | 225 | |
|
226 | 226 | $ cat <<'EOF' >> .hg/hgrc |
|
227 | 227 | > [templates] |
|
228 | 228 | > simple = "{rev}\n" |
|
229 | 229 | > simple2 = {rev}\n |
|
230 | 230 | > rev = "should not precede {rev} keyword\n" |
|
231 | 231 | > EOF |
|
232 | 232 | |
|
233 | 233 | $ hg log -l1 -Tsimple |
|
234 | 234 | 8 |
|
235 | 235 | $ hg log -l1 -Tsimple2 |
|
236 | 236 | 8 |
|
237 | 237 | $ hg log -l1 -Trev |
|
238 | 238 | should not precede 8 keyword |
|
239 | 239 | $ hg log -l1 -T '{simple}' |
|
240 | 240 | 8 |
|
241 | 241 | |
|
242 | 242 | Map file shouldn't see user templates: |
|
243 | 243 | |
|
244 | 244 | $ cat <<EOF > tmpl |
|
245 | 245 | > changeset = 'nothing expanded:{simple}\n' |
|
246 | 246 | > EOF |
|
247 | 247 | $ hg log -l1 --style ./tmpl |
|
248 | 248 | nothing expanded: |
|
249 | 249 | |
|
250 | 250 | Test templates and style maps in files: |
|
251 | 251 | |
|
252 | 252 | $ echo "{rev}" > tmpl |
|
253 | 253 | $ hg log -l1 -T./tmpl |
|
254 | 254 | 8 |
|
255 | 255 | $ hg log -l1 -Tblah/blah |
|
256 | 256 | blah/blah (no-eol) |
|
257 | 257 | |
|
258 | 258 | $ printf 'changeset = "{rev}\\n"\n' > map-simple |
|
259 | 259 | $ hg log -l1 -T./map-simple |
|
260 | 260 | 8 |
|
261 | 261 | |
|
262 | 262 | Test template map inheritance |
|
263 | 263 | |
|
264 | 264 | $ echo "__base__ = map-cmdline.default" > map-simple |
|
265 | 265 | $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple |
|
266 | 266 | $ hg log -l1 -T./map-simple |
|
267 | 267 | changeset: ***8*** |
|
268 | 268 | tag: tip |
|
269 | 269 | user: test |
|
270 | 270 | date: Wed Jan 01 10:01:00 2020 +0000 |
|
271 | 271 | summary: third |
|
272 | 272 | |
|
273 | 273 | |
|
274 | 274 | Test docheader, docfooter and separator in template map |
|
275 | 275 | |
|
276 | 276 | $ cat <<'EOF' > map-myjson |
|
277 | 277 | > docheader = '\{\n' |
|
278 | 278 | > docfooter = '\n}\n' |
|
279 | 279 | > separator = ',\n' |
|
280 | 280 | > changeset = ' {dict(rev, node|short)|json}' |
|
281 | 281 | > EOF |
|
282 | 282 | $ hg log -l2 -T./map-myjson |
|
283 | 283 | { |
|
284 | 284 | {"node": "95c24699272e", "rev": 8}, |
|
285 | 285 | {"node": "29114dbae42b", "rev": 7} |
|
286 | 286 | } |
|
287 | 287 | |
|
288 | 288 | Test docheader, docfooter and separator in [templates] section |
|
289 | 289 | |
|
290 | 290 | $ cat <<'EOF' >> .hg/hgrc |
|
291 | 291 | > [templates] |
|
292 | 292 | > myjson = ' {dict(rev, node|short)|json}' |
|
293 | 293 | > myjson:docheader = '\{\n' |
|
294 | 294 | > myjson:docfooter = '\n}\n' |
|
295 | 295 | > myjson:separator = ',\n' |
|
296 | 296 | > :docheader = 'should not be selected as a docheader for literal templates\n' |
|
297 | 297 | > EOF |
|
298 | 298 | $ hg log -l2 -Tmyjson |
|
299 | 299 | { |
|
300 | 300 | {"node": "95c24699272e", "rev": 8}, |
|
301 | 301 | {"node": "29114dbae42b", "rev": 7} |
|
302 | 302 | } |
|
303 | 303 | $ hg log -l1 -T'{rev}\n' |
|
304 | 304 | 8 |
|
305 | 305 | |
|
306 | 306 | Template should precede style option |
|
307 | 307 | |
|
308 | 308 | $ hg log -l1 --style default -T '{rev}\n' |
|
309 | 309 | 8 |
|
310 | 310 | |
|
311 | 311 | Add a commit with empty description, to ensure that the templates |
|
312 | 312 | below will omit the description line. |
|
313 | 313 | |
|
314 | 314 | $ echo c >> c |
|
315 | 315 | $ hg add c |
|
316 | 316 | $ hg commit -qm ' ' |
|
317 | 317 | |
|
318 | 318 | Default style is like normal output. Phases style should be the same |
|
319 | 319 | as default style, except for extra phase lines. |
|
320 | 320 | |
|
321 | 321 | $ hg log > log.out |
|
322 | 322 | $ hg log --style default > style.out |
|
323 | 323 | $ cmp log.out style.out || diff -u log.out style.out |
|
324 | 324 | $ hg log -T phases > phases.out |
|
325 | 325 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
326 | 326 | +phase: draft |
|
327 | 327 | +phase: draft |
|
328 | 328 | +phase: draft |
|
329 | 329 | +phase: draft |
|
330 | 330 | +phase: draft |
|
331 | 331 | +phase: draft |
|
332 | 332 | +phase: draft |
|
333 | 333 | +phase: draft |
|
334 | 334 | +phase: draft |
|
335 | 335 | +phase: draft |
|
336 | 336 | |
|
337 | 337 | $ hg log -v > log.out |
|
338 | 338 | $ hg log -v --style default > style.out |
|
339 | 339 | $ cmp log.out style.out || diff -u log.out style.out |
|
340 | 340 | $ hg log -v -T phases > phases.out |
|
341 | 341 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
342 | 342 | +phase: draft |
|
343 | 343 | +phase: draft |
|
344 | 344 | +phase: draft |
|
345 | 345 | +phase: draft |
|
346 | 346 | +phase: draft |
|
347 | 347 | +phase: draft |
|
348 | 348 | +phase: draft |
|
349 | 349 | +phase: draft |
|
350 | 350 | +phase: draft |
|
351 | 351 | +phase: draft |
|
352 | 352 | |
|
353 | 353 | $ hg log -q > log.out |
|
354 | 354 | $ hg log -q --style default > style.out |
|
355 | 355 | $ cmp log.out style.out || diff -u log.out style.out |
|
356 | 356 | $ hg log -q -T phases > phases.out |
|
357 | 357 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
358 | 358 | |
|
359 | 359 | $ hg log --debug > log.out |
|
360 | 360 | $ hg log --debug --style default > style.out |
|
361 | 361 | $ cmp log.out style.out || diff -u log.out style.out |
|
362 | 362 | $ hg log --debug -T phases > phases.out |
|
363 | 363 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
364 | 364 | |
|
365 | 365 | Default style of working-directory revision should also be the same (but |
|
366 | 366 | date may change while running tests): |
|
367 | 367 | |
|
368 | 368 | $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out |
|
369 | 369 | $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out |
|
370 | 370 | $ cmp log.out style.out || diff -u log.out style.out |
|
371 | 371 | |
|
372 | 372 | $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out |
|
373 | 373 | $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out |
|
374 | 374 | $ cmp log.out style.out || diff -u log.out style.out |
|
375 | 375 | |
|
376 | 376 | $ hg log -r 'wdir()' -q > log.out |
|
377 | 377 | $ hg log -r 'wdir()' -q --style default > style.out |
|
378 | 378 | $ cmp log.out style.out || diff -u log.out style.out |
|
379 | 379 | |
|
380 | 380 | $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out |
|
381 | 381 | $ hg log -r 'wdir()' --debug --style default \ |
|
382 | 382 | > | sed 's|^date:.*|date:|' > style.out |
|
383 | 383 | $ cmp log.out style.out || diff -u log.out style.out |
|
384 | 384 | |
|
385 | 385 | Default style should also preserve color information (issue2866): |
|
386 | 386 | |
|
387 | 387 | $ cp $HGRCPATH $HGRCPATH-bak |
|
388 | 388 | $ cat <<EOF >> $HGRCPATH |
|
389 | 389 | > [extensions] |
|
390 | 390 | > color= |
|
391 | 391 | > EOF |
|
392 | 392 | |
|
393 | 393 | $ hg --color=debug log > log.out |
|
394 | 394 | $ hg --color=debug log --style default > style.out |
|
395 | 395 | $ cmp log.out style.out || diff -u log.out style.out |
|
396 | 396 | $ hg --color=debug log -T phases > phases.out |
|
397 | 397 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
398 | 398 | +[log.phase|phase: draft] |
|
399 | 399 | +[log.phase|phase: draft] |
|
400 | 400 | +[log.phase|phase: draft] |
|
401 | 401 | +[log.phase|phase: draft] |
|
402 | 402 | +[log.phase|phase: draft] |
|
403 | 403 | +[log.phase|phase: draft] |
|
404 | 404 | +[log.phase|phase: draft] |
|
405 | 405 | +[log.phase|phase: draft] |
|
406 | 406 | +[log.phase|phase: draft] |
|
407 | 407 | +[log.phase|phase: draft] |
|
408 | 408 | |
|
409 | 409 | $ hg --color=debug -v log > log.out |
|
410 | 410 | $ hg --color=debug -v log --style default > style.out |
|
411 | 411 | $ cmp log.out style.out || diff -u log.out style.out |
|
412 | 412 | $ hg --color=debug -v log -T phases > phases.out |
|
413 | 413 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
414 | 414 | +[log.phase|phase: draft] |
|
415 | 415 | +[log.phase|phase: draft] |
|
416 | 416 | +[log.phase|phase: draft] |
|
417 | 417 | +[log.phase|phase: draft] |
|
418 | 418 | +[log.phase|phase: draft] |
|
419 | 419 | +[log.phase|phase: draft] |
|
420 | 420 | +[log.phase|phase: draft] |
|
421 | 421 | +[log.phase|phase: draft] |
|
422 | 422 | +[log.phase|phase: draft] |
|
423 | 423 | +[log.phase|phase: draft] |
|
424 | 424 | |
|
425 | 425 | $ hg --color=debug -q log > log.out |
|
426 | 426 | $ hg --color=debug -q log --style default > style.out |
|
427 | 427 | $ cmp log.out style.out || diff -u log.out style.out |
|
428 | 428 | $ hg --color=debug -q log -T phases > phases.out |
|
429 | 429 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
430 | 430 | |
|
431 | 431 | $ hg --color=debug --debug log > log.out |
|
432 | 432 | $ hg --color=debug --debug log --style default > style.out |
|
433 | 433 | $ cmp log.out style.out || diff -u log.out style.out |
|
434 | 434 | $ hg --color=debug --debug log -T phases > phases.out |
|
435 | 435 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
436 | 436 | |
|
437 | 437 | $ mv $HGRCPATH-bak $HGRCPATH |
|
438 | 438 | |
|
439 | 439 | Remove commit with empty commit message, so as to not pollute further |
|
440 | 440 | tests. |
|
441 | 441 | |
|
442 | 442 | $ hg --config extensions.strip= strip -q . |
|
443 | 443 | |
|
444 | 444 | Revision with no copies (used to print a traceback): |
|
445 | 445 | |
|
446 | 446 | $ hg tip -v --template '\n' |
|
447 | 447 | |
|
448 | 448 | |
|
449 | 449 | Compact style works: |
|
450 | 450 | |
|
451 | 451 | $ hg log -Tcompact |
|
452 | 452 | 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test |
|
453 | 453 | third |
|
454 | 454 | |
|
455 | 455 | 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user |
|
456 | 456 | second |
|
457 | 457 | |
|
458 | 458 | 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person |
|
459 | 459 | merge |
|
460 | 460 | |
|
461 | 461 | 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person |
|
462 | 462 | new head |
|
463 | 463 | |
|
464 | 464 | 4 bbe44766e73d 1970-01-17 04:53 +0000 person |
|
465 | 465 | new branch |
|
466 | 466 | |
|
467 | 467 | 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person |
|
468 | 468 | no user, no domain |
|
469 | 469 | |
|
470 | 470 | 2 97054abb4ab8 1970-01-14 21:20 +0000 other |
|
471 | 471 | no person |
|
472 | 472 | |
|
473 | 473 | 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other |
|
474 | 474 | other 1 |
|
475 | 475 | |
|
476 | 476 | 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user |
|
477 | 477 | line 1 |
|
478 | 478 | |
|
479 | 479 | |
|
480 | 480 | $ hg log -v --style compact |
|
481 | 481 | 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test |
|
482 | 482 | third |
|
483 | 483 | |
|
484 | 484 | 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
485 | 485 | second |
|
486 | 486 | |
|
487 | 487 | 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person |
|
488 | 488 | merge |
|
489 | 489 | |
|
490 | 490 | 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person |
|
491 | 491 | new head |
|
492 | 492 | |
|
493 | 493 | 4 bbe44766e73d 1970-01-17 04:53 +0000 person |
|
494 | 494 | new branch |
|
495 | 495 | |
|
496 | 496 | 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person |
|
497 | 497 | no user, no domain |
|
498 | 498 | |
|
499 | 499 | 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place |
|
500 | 500 | no person |
|
501 | 501 | |
|
502 | 502 | 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place> |
|
503 | 503 | other 1 |
|
504 | 504 | other 2 |
|
505 | 505 | |
|
506 | 506 | other 3 |
|
507 | 507 | |
|
508 | 508 | 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
509 | 509 | line 1 |
|
510 | 510 | line 2 |
|
511 | 511 | |
|
512 | 512 | |
|
513 | 513 | $ hg log --debug --style compact |
|
514 | 514 | 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test |
|
515 | 515 | third |
|
516 | 516 | |
|
517 | 517 | 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
518 | 518 | second |
|
519 | 519 | |
|
520 | 520 | 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person |
|
521 | 521 | merge |
|
522 | 522 | |
|
523 | 523 | 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person |
|
524 | 524 | new head |
|
525 | 525 | |
|
526 | 526 | 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person |
|
527 | 527 | new branch |
|
528 | 528 | |
|
529 | 529 | 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person |
|
530 | 530 | no user, no domain |
|
531 | 531 | |
|
532 | 532 | 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place |
|
533 | 533 | no person |
|
534 | 534 | |
|
535 | 535 | 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place> |
|
536 | 536 | other 1 |
|
537 | 537 | other 2 |
|
538 | 538 | |
|
539 | 539 | other 3 |
|
540 | 540 | |
|
541 | 541 | 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
542 | 542 | line 1 |
|
543 | 543 | line 2 |
|
544 | 544 | |
|
545 | 545 | |
|
546 | 546 | Test xml styles: |
|
547 | 547 | |
|
548 | 548 | $ hg log --style xml -r 'not all()' |
|
549 | 549 | <?xml version="1.0"?> |
|
550 | 550 | <log> |
|
551 | 551 | </log> |
|
552 | 552 | |
|
553 | 553 | $ hg log --style xml |
|
554 | 554 | <?xml version="1.0"?> |
|
555 | 555 | <log> |
|
556 | 556 | <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a"> |
|
557 | 557 | <tag>tip</tag> |
|
558 | 558 | <author email="test">test</author> |
|
559 | 559 | <date>2020-01-01T10:01:00+00:00</date> |
|
560 | 560 | <msg xml:space="preserve">third</msg> |
|
561 | 561 | </logentry> |
|
562 | 562 | <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453"> |
|
563 | 563 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
564 | 564 | <author email="user@hostname">User Name</author> |
|
565 | 565 | <date>1970-01-12T13:46:40+00:00</date> |
|
566 | 566 | <msg xml:space="preserve">second</msg> |
|
567 | 567 | </logentry> |
|
568 | 568 | <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b"> |
|
569 | 569 | <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" /> |
|
570 | 570 | <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" /> |
|
571 | 571 | <author email="person">person</author> |
|
572 | 572 | <date>1970-01-18T08:40:01+00:00</date> |
|
573 | 573 | <msg xml:space="preserve">merge</msg> |
|
574 | 574 | </logentry> |
|
575 | 575 | <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f"> |
|
576 | 576 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
577 | 577 | <author email="person">person</author> |
|
578 | 578 | <date>1970-01-18T08:40:00+00:00</date> |
|
579 | 579 | <msg xml:space="preserve">new head</msg> |
|
580 | 580 | </logentry> |
|
581 | 581 | <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74"> |
|
582 | 582 | <branch>foo</branch> |
|
583 | 583 | <author email="person">person</author> |
|
584 | 584 | <date>1970-01-17T04:53:20+00:00</date> |
|
585 | 585 | <msg xml:space="preserve">new branch</msg> |
|
586 | 586 | </logentry> |
|
587 | 587 | <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47"> |
|
588 | 588 | <author email="person">person</author> |
|
589 | 589 | <date>1970-01-16T01:06:40+00:00</date> |
|
590 | 590 | <msg xml:space="preserve">no user, no domain</msg> |
|
591 | 591 | </logentry> |
|
592 | 592 | <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465"> |
|
593 | 593 | <author email="other@place">other</author> |
|
594 | 594 | <date>1970-01-14T21:20:00+00:00</date> |
|
595 | 595 | <msg xml:space="preserve">no person</msg> |
|
596 | 596 | </logentry> |
|
597 | 597 | <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965"> |
|
598 | 598 | <author email="other@place">A. N. Other</author> |
|
599 | 599 | <date>1970-01-13T17:33:20+00:00</date> |
|
600 | 600 | <msg xml:space="preserve">other 1 |
|
601 | 601 | other 2 |
|
602 | 602 | |
|
603 | 603 | other 3</msg> |
|
604 | 604 | </logentry> |
|
605 | 605 | <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f"> |
|
606 | 606 | <author email="user@hostname">User Name</author> |
|
607 | 607 | <date>1970-01-12T13:46:40+00:00</date> |
|
608 | 608 | <msg xml:space="preserve">line 1 |
|
609 | 609 | line 2</msg> |
|
610 | 610 | </logentry> |
|
611 | 611 | </log> |
|
612 | 612 | |
|
613 | 613 | $ hg log -v --style xml |
|
614 | 614 | <?xml version="1.0"?> |
|
615 | 615 | <log> |
|
616 | 616 | <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a"> |
|
617 | 617 | <tag>tip</tag> |
|
618 | 618 | <author email="test">test</author> |
|
619 | 619 | <date>2020-01-01T10:01:00+00:00</date> |
|
620 | 620 | <msg xml:space="preserve">third</msg> |
|
621 | 621 | <paths> |
|
622 | 622 | <path action="A">fourth</path> |
|
623 | 623 | <path action="A">third</path> |
|
624 | 624 | <path action="R">second</path> |
|
625 | 625 | </paths> |
|
626 | 626 | <copies> |
|
627 | 627 | <copy source="second">fourth</copy> |
|
628 | 628 | </copies> |
|
629 | 629 | </logentry> |
|
630 | 630 | <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453"> |
|
631 | 631 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
632 | 632 | <author email="user@hostname">User Name</author> |
|
633 | 633 | <date>1970-01-12T13:46:40+00:00</date> |
|
634 | 634 | <msg xml:space="preserve">second</msg> |
|
635 | 635 | <paths> |
|
636 | 636 | <path action="A">second</path> |
|
637 | 637 | </paths> |
|
638 | 638 | </logentry> |
|
639 | 639 | <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b"> |
|
640 | 640 | <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" /> |
|
641 | 641 | <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" /> |
|
642 | 642 | <author email="person">person</author> |
|
643 | 643 | <date>1970-01-18T08:40:01+00:00</date> |
|
644 | 644 | <msg xml:space="preserve">merge</msg> |
|
645 | 645 | <paths> |
|
646 | 646 | </paths> |
|
647 | 647 | </logentry> |
|
648 | 648 | <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f"> |
|
649 | 649 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
650 | 650 | <author email="person">person</author> |
|
651 | 651 | <date>1970-01-18T08:40:00+00:00</date> |
|
652 | 652 | <msg xml:space="preserve">new head</msg> |
|
653 | 653 | <paths> |
|
654 | 654 | <path action="A">d</path> |
|
655 | 655 | </paths> |
|
656 | 656 | </logentry> |
|
657 | 657 | <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74"> |
|
658 | 658 | <branch>foo</branch> |
|
659 | 659 | <author email="person">person</author> |
|
660 | 660 | <date>1970-01-17T04:53:20+00:00</date> |
|
661 | 661 | <msg xml:space="preserve">new branch</msg> |
|
662 | 662 | <paths> |
|
663 | 663 | </paths> |
|
664 | 664 | </logentry> |
|
665 | 665 | <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47"> |
|
666 | 666 | <author email="person">person</author> |
|
667 | 667 | <date>1970-01-16T01:06:40+00:00</date> |
|
668 | 668 | <msg xml:space="preserve">no user, no domain</msg> |
|
669 | 669 | <paths> |
|
670 | 670 | <path action="M">c</path> |
|
671 | 671 | </paths> |
|
672 | 672 | </logentry> |
|
673 | 673 | <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465"> |
|
674 | 674 | <author email="other@place">other</author> |
|
675 | 675 | <date>1970-01-14T21:20:00+00:00</date> |
|
676 | 676 | <msg xml:space="preserve">no person</msg> |
|
677 | 677 | <paths> |
|
678 | 678 | <path action="A">c</path> |
|
679 | 679 | </paths> |
|
680 | 680 | </logentry> |
|
681 | 681 | <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965"> |
|
682 | 682 | <author email="other@place">A. N. Other</author> |
|
683 | 683 | <date>1970-01-13T17:33:20+00:00</date> |
|
684 | 684 | <msg xml:space="preserve">other 1 |
|
685 | 685 | other 2 |
|
686 | 686 | |
|
687 | 687 | other 3</msg> |
|
688 | 688 | <paths> |
|
689 | 689 | <path action="A">b</path> |
|
690 | 690 | </paths> |
|
691 | 691 | </logentry> |
|
692 | 692 | <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f"> |
|
693 | 693 | <author email="user@hostname">User Name</author> |
|
694 | 694 | <date>1970-01-12T13:46:40+00:00</date> |
|
695 | 695 | <msg xml:space="preserve">line 1 |
|
696 | 696 | line 2</msg> |
|
697 | 697 | <paths> |
|
698 | 698 | <path action="A">a</path> |
|
699 | 699 | </paths> |
|
700 | 700 | </logentry> |
|
701 | 701 | </log> |
|
702 | 702 | |
|
703 | 703 | $ hg log --debug --style xml |
|
704 | 704 | <?xml version="1.0"?> |
|
705 | 705 | <log> |
|
706 | 706 | <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a"> |
|
707 | 707 | <tag>tip</tag> |
|
708 | 708 | <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" /> |
|
709 | 709 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
710 | 710 | <author email="test">test</author> |
|
711 | 711 | <date>2020-01-01T10:01:00+00:00</date> |
|
712 | 712 | <msg xml:space="preserve">third</msg> |
|
713 | 713 | <paths> |
|
714 | 714 | <path action="A">fourth</path> |
|
715 | 715 | <path action="A">third</path> |
|
716 | 716 | <path action="R">second</path> |
|
717 | 717 | </paths> |
|
718 | 718 | <copies> |
|
719 | 719 | <copy source="second">fourth</copy> |
|
720 | 720 | </copies> |
|
721 | 721 | <extra key="branch">default</extra> |
|
722 | 722 | </logentry> |
|
723 | 723 | <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453"> |
|
724 | 724 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
725 | 725 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
726 | 726 | <author email="user@hostname">User Name</author> |
|
727 | 727 | <date>1970-01-12T13:46:40+00:00</date> |
|
728 | 728 | <msg xml:space="preserve">second</msg> |
|
729 | 729 | <paths> |
|
730 | 730 | <path action="A">second</path> |
|
731 | 731 | </paths> |
|
732 | 732 | <extra key="branch">default</extra> |
|
733 | 733 | </logentry> |
|
734 | 734 | <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b"> |
|
735 | 735 | <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" /> |
|
736 | 736 | <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" /> |
|
737 | 737 | <author email="person">person</author> |
|
738 | 738 | <date>1970-01-18T08:40:01+00:00</date> |
|
739 | 739 | <msg xml:space="preserve">merge</msg> |
|
740 | 740 | <paths> |
|
741 | 741 | </paths> |
|
742 | 742 | <extra key="branch">default</extra> |
|
743 | 743 | </logentry> |
|
744 | 744 | <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f"> |
|
745 | 745 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
746 | 746 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
747 | 747 | <author email="person">person</author> |
|
748 | 748 | <date>1970-01-18T08:40:00+00:00</date> |
|
749 | 749 | <msg xml:space="preserve">new head</msg> |
|
750 | 750 | <paths> |
|
751 | 751 | <path action="A">d</path> |
|
752 | 752 | </paths> |
|
753 | 753 | <extra key="branch">default</extra> |
|
754 | 754 | </logentry> |
|
755 | 755 | <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74"> |
|
756 | 756 | <branch>foo</branch> |
|
757 | 757 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
758 | 758 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
759 | 759 | <author email="person">person</author> |
|
760 | 760 | <date>1970-01-17T04:53:20+00:00</date> |
|
761 | 761 | <msg xml:space="preserve">new branch</msg> |
|
762 | 762 | <paths> |
|
763 | 763 | </paths> |
|
764 | 764 | <extra key="branch">foo</extra> |
|
765 | 765 | </logentry> |
|
766 | 766 | <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47"> |
|
767 | 767 | <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" /> |
|
768 | 768 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
769 | 769 | <author email="person">person</author> |
|
770 | 770 | <date>1970-01-16T01:06:40+00:00</date> |
|
771 | 771 | <msg xml:space="preserve">no user, no domain</msg> |
|
772 | 772 | <paths> |
|
773 | 773 | <path action="M">c</path> |
|
774 | 774 | </paths> |
|
775 | 775 | <extra key="branch">default</extra> |
|
776 | 776 | </logentry> |
|
777 | 777 | <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465"> |
|
778 | 778 | <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" /> |
|
779 | 779 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
780 | 780 | <author email="other@place">other</author> |
|
781 | 781 | <date>1970-01-14T21:20:00+00:00</date> |
|
782 | 782 | <msg xml:space="preserve">no person</msg> |
|
783 | 783 | <paths> |
|
784 | 784 | <path action="A">c</path> |
|
785 | 785 | </paths> |
|
786 | 786 | <extra key="branch">default</extra> |
|
787 | 787 | </logentry> |
|
788 | 788 | <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965"> |
|
789 | 789 | <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" /> |
|
790 | 790 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
791 | 791 | <author email="other@place">A. N. Other</author> |
|
792 | 792 | <date>1970-01-13T17:33:20+00:00</date> |
|
793 | 793 | <msg xml:space="preserve">other 1 |
|
794 | 794 | other 2 |
|
795 | 795 | |
|
796 | 796 | other 3</msg> |
|
797 | 797 | <paths> |
|
798 | 798 | <path action="A">b</path> |
|
799 | 799 | </paths> |
|
800 | 800 | <extra key="branch">default</extra> |
|
801 | 801 | </logentry> |
|
802 | 802 | <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f"> |
|
803 | 803 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
804 | 804 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
805 | 805 | <author email="user@hostname">User Name</author> |
|
806 | 806 | <date>1970-01-12T13:46:40+00:00</date> |
|
807 | 807 | <msg xml:space="preserve">line 1 |
|
808 | 808 | line 2</msg> |
|
809 | 809 | <paths> |
|
810 | 810 | <path action="A">a</path> |
|
811 | 811 | </paths> |
|
812 | 812 | <extra key="branch">default</extra> |
|
813 | 813 | </logentry> |
|
814 | 814 | </log> |
|
815 | 815 | |
|
816 | 816 | |
|
817 | 817 | Test JSON style: |
|
818 | 818 | |
|
819 | 819 | $ hg log -k nosuch -Tjson |
|
820 | 820 | [] |
|
821 | 821 | |
|
822 | 822 | $ hg log -qr . -Tjson |
|
823 | 823 | [ |
|
824 | 824 | { |
|
825 | 825 | "rev": 8, |
|
826 | 826 | "node": "95c24699272ef57d062b8bccc32c878bf841784a" |
|
827 | 827 | } |
|
828 | 828 | ] |
|
829 | 829 | |
|
830 | 830 | $ hg log -vpr . -Tjson --stat |
|
831 | 831 | [ |
|
832 | 832 | { |
|
833 | 833 | "rev": 8, |
|
834 | 834 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
835 | 835 | "branch": "default", |
|
836 | 836 | "phase": "draft", |
|
837 | 837 | "user": "test", |
|
838 | 838 | "date": [1577872860, 0], |
|
839 | 839 | "desc": "third", |
|
840 | 840 | "bookmarks": [], |
|
841 | 841 | "tags": ["tip"], |
|
842 | 842 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
843 | 843 | "files": ["fourth", "second", "third"], |
|
844 | 844 | "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n", |
|
845 | 845 | "diff": "diff -r 29114dbae42b -r 95c24699272e fourth\n--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/fourth\tWed Jan 01 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+second\ndiff -r 29114dbae42b -r 95c24699272e second\n--- a/second\tMon Jan 12 13:46:40 1970 +0000\n+++ /dev/null\tThu Jan 01 00:00:00 1970 +0000\n@@ -1,1 +0,0 @@\n-second\ndiff -r 29114dbae42b -r 95c24699272e third\n--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/third\tWed Jan 01 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+third\n" |
|
846 | 846 | } |
|
847 | 847 | ] |
|
848 | 848 | |
|
849 | 849 | honor --git but not format-breaking diffopts |
|
850 | 850 | $ hg --config diff.noprefix=True log --git -vpr . -Tjson |
|
851 | 851 | [ |
|
852 | 852 | { |
|
853 | 853 | "rev": 8, |
|
854 | 854 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
855 | 855 | "branch": "default", |
|
856 | 856 | "phase": "draft", |
|
857 | 857 | "user": "test", |
|
858 | 858 | "date": [1577872860, 0], |
|
859 | 859 | "desc": "third", |
|
860 | 860 | "bookmarks": [], |
|
861 | 861 | "tags": ["tip"], |
|
862 | 862 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
863 | 863 | "files": ["fourth", "second", "third"], |
|
864 | 864 | "diff": "diff --git a/second b/fourth\nrename from second\nrename to fourth\ndiff --git a/third b/third\nnew file mode 100644\n--- /dev/null\n+++ b/third\n@@ -0,0 +1,1 @@\n+third\n" |
|
865 | 865 | } |
|
866 | 866 | ] |
|
867 | 867 | |
|
868 | 868 | $ hg log -T json |
|
869 | 869 | [ |
|
870 | 870 | { |
|
871 | 871 | "rev": 8, |
|
872 | 872 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
873 | 873 | "branch": "default", |
|
874 | 874 | "phase": "draft", |
|
875 | 875 | "user": "test", |
|
876 | 876 | "date": [1577872860, 0], |
|
877 | 877 | "desc": "third", |
|
878 | 878 | "bookmarks": [], |
|
879 | 879 | "tags": ["tip"], |
|
880 | 880 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"] |
|
881 | 881 | }, |
|
882 | 882 | { |
|
883 | 883 | "rev": 7, |
|
884 | 884 | "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453", |
|
885 | 885 | "branch": "default", |
|
886 | 886 | "phase": "draft", |
|
887 | 887 | "user": "User Name <user@hostname>", |
|
888 | 888 | "date": [1000000, 0], |
|
889 | 889 | "desc": "second", |
|
890 | 890 | "bookmarks": [], |
|
891 | 891 | "tags": [], |
|
892 | 892 | "parents": ["0000000000000000000000000000000000000000"] |
|
893 | 893 | }, |
|
894 | 894 | { |
|
895 | 895 | "rev": 6, |
|
896 | 896 | "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b", |
|
897 | 897 | "branch": "default", |
|
898 | 898 | "phase": "draft", |
|
899 | 899 | "user": "person", |
|
900 | 900 | "date": [1500001, 0], |
|
901 | 901 | "desc": "merge", |
|
902 | 902 | "bookmarks": [], |
|
903 | 903 | "tags": [], |
|
904 | 904 | "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"] |
|
905 | 905 | }, |
|
906 | 906 | { |
|
907 | 907 | "rev": 5, |
|
908 | 908 | "node": "13207e5a10d9fd28ec424934298e176197f2c67f", |
|
909 | 909 | "branch": "default", |
|
910 | 910 | "phase": "draft", |
|
911 | 911 | "user": "person", |
|
912 | 912 | "date": [1500000, 0], |
|
913 | 913 | "desc": "new head", |
|
914 | 914 | "bookmarks": [], |
|
915 | 915 | "tags": [], |
|
916 | 916 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"] |
|
917 | 917 | }, |
|
918 | 918 | { |
|
919 | 919 | "rev": 4, |
|
920 | 920 | "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74", |
|
921 | 921 | "branch": "foo", |
|
922 | 922 | "phase": "draft", |
|
923 | 923 | "user": "person", |
|
924 | 924 | "date": [1400000, 0], |
|
925 | 925 | "desc": "new branch", |
|
926 | 926 | "bookmarks": [], |
|
927 | 927 | "tags": [], |
|
928 | 928 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"] |
|
929 | 929 | }, |
|
930 | 930 | { |
|
931 | 931 | "rev": 3, |
|
932 | 932 | "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47", |
|
933 | 933 | "branch": "default", |
|
934 | 934 | "phase": "draft", |
|
935 | 935 | "user": "person", |
|
936 | 936 | "date": [1300000, 0], |
|
937 | 937 | "desc": "no user, no domain", |
|
938 | 938 | "bookmarks": [], |
|
939 | 939 | "tags": [], |
|
940 | 940 | "parents": ["97054abb4ab824450e9164180baf491ae0078465"] |
|
941 | 941 | }, |
|
942 | 942 | { |
|
943 | 943 | "rev": 2, |
|
944 | 944 | "node": "97054abb4ab824450e9164180baf491ae0078465", |
|
945 | 945 | "branch": "default", |
|
946 | 946 | "phase": "draft", |
|
947 | 947 | "user": "other@place", |
|
948 | 948 | "date": [1200000, 0], |
|
949 | 949 | "desc": "no person", |
|
950 | 950 | "bookmarks": [], |
|
951 | 951 | "tags": [], |
|
952 | 952 | "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"] |
|
953 | 953 | }, |
|
954 | 954 | { |
|
955 | 955 | "rev": 1, |
|
956 | 956 | "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965", |
|
957 | 957 | "branch": "default", |
|
958 | 958 | "phase": "draft", |
|
959 | 959 | "user": "A. N. Other <other@place>", |
|
960 | 960 | "date": [1100000, 0], |
|
961 | 961 | "desc": "other 1\nother 2\n\nother 3", |
|
962 | 962 | "bookmarks": [], |
|
963 | 963 | "tags": [], |
|
964 | 964 | "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"] |
|
965 | 965 | }, |
|
966 | 966 | { |
|
967 | 967 | "rev": 0, |
|
968 | 968 | "node": "1e4e1b8f71e05681d422154f5421e385fec3454f", |
|
969 | 969 | "branch": "default", |
|
970 | 970 | "phase": "draft", |
|
971 | 971 | "user": "User Name <user@hostname>", |
|
972 | 972 | "date": [1000000, 0], |
|
973 | 973 | "desc": "line 1\nline 2", |
|
974 | 974 | "bookmarks": [], |
|
975 | 975 | "tags": [], |
|
976 | 976 | "parents": ["0000000000000000000000000000000000000000"] |
|
977 | 977 | } |
|
978 | 978 | ] |
|
979 | 979 | |
|
980 | 980 | $ hg heads -v -Tjson |
|
981 | 981 | [ |
|
982 | 982 | { |
|
983 | 983 | "rev": 8, |
|
984 | 984 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
985 | 985 | "branch": "default", |
|
986 | 986 | "phase": "draft", |
|
987 | 987 | "user": "test", |
|
988 | 988 | "date": [1577872860, 0], |
|
989 | 989 | "desc": "third", |
|
990 | 990 | "bookmarks": [], |
|
991 | 991 | "tags": ["tip"], |
|
992 | 992 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
993 | 993 | "files": ["fourth", "second", "third"] |
|
994 | 994 | }, |
|
995 | 995 | { |
|
996 | 996 | "rev": 6, |
|
997 | 997 | "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b", |
|
998 | 998 | "branch": "default", |
|
999 | 999 | "phase": "draft", |
|
1000 | 1000 | "user": "person", |
|
1001 | 1001 | "date": [1500001, 0], |
|
1002 | 1002 | "desc": "merge", |
|
1003 | 1003 | "bookmarks": [], |
|
1004 | 1004 | "tags": [], |
|
1005 | 1005 | "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"], |
|
1006 | 1006 | "files": [] |
|
1007 | 1007 | }, |
|
1008 | 1008 | { |
|
1009 | 1009 | "rev": 4, |
|
1010 | 1010 | "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74", |
|
1011 | 1011 | "branch": "foo", |
|
1012 | 1012 | "phase": "draft", |
|
1013 | 1013 | "user": "person", |
|
1014 | 1014 | "date": [1400000, 0], |
|
1015 | 1015 | "desc": "new branch", |
|
1016 | 1016 | "bookmarks": [], |
|
1017 | 1017 | "tags": [], |
|
1018 | 1018 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
1019 | 1019 | "files": [] |
|
1020 | 1020 | } |
|
1021 | 1021 | ] |
|
1022 | 1022 | |
|
1023 | 1023 | $ hg log --debug -Tjson |
|
1024 | 1024 | [ |
|
1025 | 1025 | { |
|
1026 | 1026 | "rev": 8, |
|
1027 | 1027 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
1028 | 1028 | "branch": "default", |
|
1029 | 1029 | "phase": "draft", |
|
1030 | 1030 | "user": "test", |
|
1031 | 1031 | "date": [1577872860, 0], |
|
1032 | 1032 | "desc": "third", |
|
1033 | 1033 | "bookmarks": [], |
|
1034 | 1034 | "tags": ["tip"], |
|
1035 | 1035 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
1036 | 1036 | "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64", |
|
1037 | 1037 | "extra": {"branch": "default"}, |
|
1038 | 1038 | "modified": [], |
|
1039 | 1039 | "added": ["fourth", "third"], |
|
1040 | 1040 | "removed": ["second"] |
|
1041 | 1041 | }, |
|
1042 | 1042 | { |
|
1043 | 1043 | "rev": 7, |
|
1044 | 1044 | "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453", |
|
1045 | 1045 | "branch": "default", |
|
1046 | 1046 | "phase": "draft", |
|
1047 | 1047 | "user": "User Name <user@hostname>", |
|
1048 | 1048 | "date": [1000000, 0], |
|
1049 | 1049 | "desc": "second", |
|
1050 | 1050 | "bookmarks": [], |
|
1051 | 1051 | "tags": [], |
|
1052 | 1052 | "parents": ["0000000000000000000000000000000000000000"], |
|
1053 | 1053 | "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf", |
|
1054 | 1054 | "extra": {"branch": "default"}, |
|
1055 | 1055 | "modified": [], |
|
1056 | 1056 | "added": ["second"], |
|
1057 | 1057 | "removed": [] |
|
1058 | 1058 | }, |
|
1059 | 1059 | { |
|
1060 | 1060 | "rev": 6, |
|
1061 | 1061 | "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b", |
|
1062 | 1062 | "branch": "default", |
|
1063 | 1063 | "phase": "draft", |
|
1064 | 1064 | "user": "person", |
|
1065 | 1065 | "date": [1500001, 0], |
|
1066 | 1066 | "desc": "merge", |
|
1067 | 1067 | "bookmarks": [], |
|
1068 | 1068 | "tags": [], |
|
1069 | 1069 | "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"], |
|
1070 | 1070 | "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216", |
|
1071 | 1071 | "extra": {"branch": "default"}, |
|
1072 | 1072 | "modified": [], |
|
1073 | 1073 | "added": [], |
|
1074 | 1074 | "removed": [] |
|
1075 | 1075 | }, |
|
1076 | 1076 | { |
|
1077 | 1077 | "rev": 5, |
|
1078 | 1078 | "node": "13207e5a10d9fd28ec424934298e176197f2c67f", |
|
1079 | 1079 | "branch": "default", |
|
1080 | 1080 | "phase": "draft", |
|
1081 | 1081 | "user": "person", |
|
1082 | 1082 | "date": [1500000, 0], |
|
1083 | 1083 | "desc": "new head", |
|
1084 | 1084 | "bookmarks": [], |
|
1085 | 1085 | "tags": [], |
|
1086 | 1086 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
1087 | 1087 | "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216", |
|
1088 | 1088 | "extra": {"branch": "default"}, |
|
1089 | 1089 | "modified": [], |
|
1090 | 1090 | "added": ["d"], |
|
1091 | 1091 | "removed": [] |
|
1092 | 1092 | }, |
|
1093 | 1093 | { |
|
1094 | 1094 | "rev": 4, |
|
1095 | 1095 | "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74", |
|
1096 | 1096 | "branch": "foo", |
|
1097 | 1097 | "phase": "draft", |
|
1098 | 1098 | "user": "person", |
|
1099 | 1099 | "date": [1400000, 0], |
|
1100 | 1100 | "desc": "new branch", |
|
1101 | 1101 | "bookmarks": [], |
|
1102 | 1102 | "tags": [], |
|
1103 | 1103 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
1104 | 1104 | "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc", |
|
1105 | 1105 | "extra": {"branch": "foo"}, |
|
1106 | 1106 | "modified": [], |
|
1107 | 1107 | "added": [], |
|
1108 | 1108 | "removed": [] |
|
1109 | 1109 | }, |
|
1110 | 1110 | { |
|
1111 | 1111 | "rev": 3, |
|
1112 | 1112 | "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47", |
|
1113 | 1113 | "branch": "default", |
|
1114 | 1114 | "phase": "draft", |
|
1115 | 1115 | "user": "person", |
|
1116 | 1116 | "date": [1300000, 0], |
|
1117 | 1117 | "desc": "no user, no domain", |
|
1118 | 1118 | "bookmarks": [], |
|
1119 | 1119 | "tags": [], |
|
1120 | 1120 | "parents": ["97054abb4ab824450e9164180baf491ae0078465"], |
|
1121 | 1121 | "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc", |
|
1122 | 1122 | "extra": {"branch": "default"}, |
|
1123 | 1123 | "modified": ["c"], |
|
1124 | 1124 | "added": [], |
|
1125 | 1125 | "removed": [] |
|
1126 | 1126 | }, |
|
1127 | 1127 | { |
|
1128 | 1128 | "rev": 2, |
|
1129 | 1129 | "node": "97054abb4ab824450e9164180baf491ae0078465", |
|
1130 | 1130 | "branch": "default", |
|
1131 | 1131 | "phase": "draft", |
|
1132 | 1132 | "user": "other@place", |
|
1133 | 1133 | "date": [1200000, 0], |
|
1134 | 1134 | "desc": "no person", |
|
1135 | 1135 | "bookmarks": [], |
|
1136 | 1136 | "tags": [], |
|
1137 | 1137 | "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"], |
|
1138 | 1138 | "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1", |
|
1139 | 1139 | "extra": {"branch": "default"}, |
|
1140 | 1140 | "modified": [], |
|
1141 | 1141 | "added": ["c"], |
|
1142 | 1142 | "removed": [] |
|
1143 | 1143 | }, |
|
1144 | 1144 | { |
|
1145 | 1145 | "rev": 1, |
|
1146 | 1146 | "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965", |
|
1147 | 1147 | "branch": "default", |
|
1148 | 1148 | "phase": "draft", |
|
1149 | 1149 | "user": "A. N. Other <other@place>", |
|
1150 | 1150 | "date": [1100000, 0], |
|
1151 | 1151 | "desc": "other 1\nother 2\n\nother 3", |
|
1152 | 1152 | "bookmarks": [], |
|
1153 | 1153 | "tags": [], |
|
1154 | 1154 | "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"], |
|
1155 | 1155 | "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55", |
|
1156 | 1156 | "extra": {"branch": "default"}, |
|
1157 | 1157 | "modified": [], |
|
1158 | 1158 | "added": ["b"], |
|
1159 | 1159 | "removed": [] |
|
1160 | 1160 | }, |
|
1161 | 1161 | { |
|
1162 | 1162 | "rev": 0, |
|
1163 | 1163 | "node": "1e4e1b8f71e05681d422154f5421e385fec3454f", |
|
1164 | 1164 | "branch": "default", |
|
1165 | 1165 | "phase": "draft", |
|
1166 | 1166 | "user": "User Name <user@hostname>", |
|
1167 | 1167 | "date": [1000000, 0], |
|
1168 | 1168 | "desc": "line 1\nline 2", |
|
1169 | 1169 | "bookmarks": [], |
|
1170 | 1170 | "tags": [], |
|
1171 | 1171 | "parents": ["0000000000000000000000000000000000000000"], |
|
1172 | 1172 | "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0", |
|
1173 | 1173 | "extra": {"branch": "default"}, |
|
1174 | 1174 | "modified": [], |
|
1175 | 1175 | "added": ["a"], |
|
1176 | 1176 | "removed": [] |
|
1177 | 1177 | } |
|
1178 | 1178 | ] |
|
1179 | 1179 | |
|
1180 | 1180 | Error if style not readable: |
|
1181 | 1181 | |
|
1182 | 1182 | #if unix-permissions no-root |
|
1183 | 1183 | $ touch q |
|
1184 | 1184 | $ chmod 0 q |
|
1185 | 1185 | $ hg log --style ./q |
|
1186 | 1186 | abort: Permission denied: ./q |
|
1187 | 1187 | [255] |
|
1188 | 1188 | #endif |
|
1189 | 1189 | |
|
1190 | 1190 | Error if no style: |
|
1191 | 1191 | |
|
1192 | 1192 | $ hg log --style notexist |
|
1193 | 1193 | abort: style 'notexist' not found |
|
1194 | 1194 | (available styles: bisect, changelog, compact, default, phases, show, status, xml) |
|
1195 | 1195 | [255] |
|
1196 | 1196 | |
|
1197 | 1197 | $ hg log -T list |
|
1198 | 1198 | available styles: bisect, changelog, compact, default, phases, show, status, xml |
|
1199 | 1199 | abort: specify a template |
|
1200 | 1200 | [255] |
|
1201 | 1201 | |
|
1202 | 1202 | Error if style missing key: |
|
1203 | 1203 | |
|
1204 | 1204 | $ echo 'q = q' > t |
|
1205 | 1205 | $ hg log --style ./t |
|
1206 | 1206 | abort: "changeset" not in template map |
|
1207 | 1207 | [255] |
|
1208 | 1208 | |
|
1209 | 1209 | Error if style missing value: |
|
1210 | 1210 | |
|
1211 | 1211 | $ echo 'changeset =' > t |
|
1212 | 1212 | $ hg log --style t |
|
1213 | 1213 | hg: parse error at t:1: missing value |
|
1214 | 1214 | [255] |
|
1215 | 1215 | |
|
1216 | 1216 | Error if include fails: |
|
1217 | 1217 | |
|
1218 | 1218 | $ echo 'changeset = q' >> t |
|
1219 | 1219 | #if unix-permissions no-root |
|
1220 | 1220 | $ hg log --style ./t |
|
1221 | 1221 | abort: template file ./q: Permission denied |
|
1222 | 1222 | [255] |
|
1223 | 1223 | $ rm -f q |
|
1224 | 1224 | #endif |
|
1225 | 1225 | |
|
1226 | 1226 | Include works: |
|
1227 | 1227 | |
|
1228 | 1228 | $ echo '{rev}' > q |
|
1229 | 1229 | $ hg log --style ./t |
|
1230 | 1230 | 8 |
|
1231 | 1231 | 7 |
|
1232 | 1232 | 6 |
|
1233 | 1233 | 5 |
|
1234 | 1234 | 4 |
|
1235 | 1235 | 3 |
|
1236 | 1236 | 2 |
|
1237 | 1237 | 1 |
|
1238 | 1238 | 0 |
|
1239 | 1239 | |
|
1240 | 1240 | Check that recursive reference does not fall into RuntimeError (issue4758): |
|
1241 | 1241 | |
|
1242 | 1242 | common mistake: |
|
1243 | 1243 | |
|
1244 | 1244 | $ cat << EOF > issue4758 |
|
1245 | 1245 | > changeset = '{changeset}\n' |
|
1246 | 1246 | > EOF |
|
1247 | 1247 | $ hg log --style ./issue4758 |
|
1248 | 1248 | abort: recursive reference 'changeset' in template |
|
1249 | 1249 | [255] |
|
1250 | 1250 | |
|
1251 | 1251 | circular reference: |
|
1252 | 1252 | |
|
1253 | 1253 | $ cat << EOF > issue4758 |
|
1254 | 1254 | > changeset = '{foo}' |
|
1255 | 1255 | > foo = '{changeset}' |
|
1256 | 1256 | > EOF |
|
1257 | 1257 | $ hg log --style ./issue4758 |
|
1258 | 1258 | abort: recursive reference 'foo' in template |
|
1259 | 1259 | [255] |
|
1260 | 1260 | |
|
1261 | 1261 | buildmap() -> gettemplate(), where no thunk was made: |
|
1262 | 1262 | |
|
1263 | 1263 | $ cat << EOF > issue4758 |
|
1264 | 1264 | > changeset = '{files % changeset}\n' |
|
1265 | 1265 | > EOF |
|
1266 | 1266 | $ hg log --style ./issue4758 |
|
1267 | 1267 | abort: recursive reference 'changeset' in template |
|
1268 | 1268 | [255] |
|
1269 | 1269 | |
|
1270 | 1270 | not a recursion if a keyword of the same name exists: |
|
1271 | 1271 | |
|
1272 | 1272 | $ cat << EOF > issue4758 |
|
1273 | 1273 | > changeset = '{tags % rev}' |
|
1274 | 1274 | > rev = '{rev} {tag}\n' |
|
1275 | 1275 | > EOF |
|
1276 | 1276 | $ hg log --style ./issue4758 -r tip |
|
1277 | 1277 | 8 tip |
|
1278 | 1278 | |
|
1279 | 1279 | Check that {phase} works correctly on parents: |
|
1280 | 1280 | |
|
1281 | 1281 | $ cat << EOF > parentphase |
|
1282 | 1282 | > changeset_debug = '{rev} ({phase}):{parents}\n' |
|
1283 | 1283 | > parent = ' {rev} ({phase})' |
|
1284 | 1284 | > EOF |
|
1285 | 1285 | $ hg phase -r 5 --public |
|
1286 | 1286 | $ hg phase -r 7 --secret --force |
|
1287 | 1287 | $ hg log --debug -G --style ./parentphase |
|
1288 | 1288 | @ 8 (secret): 7 (secret) -1 (public) |
|
1289 | 1289 | | |
|
1290 | 1290 | o 7 (secret): -1 (public) -1 (public) |
|
1291 | 1291 | |
|
1292 | 1292 | o 6 (draft): 5 (public) 4 (draft) |
|
1293 | 1293 | |\ |
|
1294 | 1294 | | o 5 (public): 3 (public) -1 (public) |
|
1295 | 1295 | | | |
|
1296 | 1296 | o | 4 (draft): 3 (public) -1 (public) |
|
1297 | 1297 | |/ |
|
1298 | 1298 | o 3 (public): 2 (public) -1 (public) |
|
1299 | 1299 | | |
|
1300 | 1300 | o 2 (public): 1 (public) -1 (public) |
|
1301 | 1301 | | |
|
1302 | 1302 | o 1 (public): 0 (public) -1 (public) |
|
1303 | 1303 | | |
|
1304 | 1304 | o 0 (public): -1 (public) -1 (public) |
|
1305 | 1305 | |
|
1306 | 1306 | |
|
1307 | 1307 | Missing non-standard names give no error (backward compatibility): |
|
1308 | 1308 | |
|
1309 | 1309 | $ echo "changeset = '{c}'" > t |
|
1310 | 1310 | $ hg log --style ./t |
|
1311 | 1311 | |
|
1312 | 1312 | Defining non-standard name works: |
|
1313 | 1313 | |
|
1314 | 1314 | $ cat <<EOF > t |
|
1315 | 1315 | > changeset = '{c}' |
|
1316 | 1316 | > c = q |
|
1317 | 1317 | > EOF |
|
1318 | 1318 | $ hg log --style ./t |
|
1319 | 1319 | 8 |
|
1320 | 1320 | 7 |
|
1321 | 1321 | 6 |
|
1322 | 1322 | 5 |
|
1323 | 1323 | 4 |
|
1324 | 1324 | 3 |
|
1325 | 1325 | 2 |
|
1326 | 1326 | 1 |
|
1327 | 1327 | 0 |
|
1328 | 1328 | |
|
1329 | 1329 | ui.style works: |
|
1330 | 1330 | |
|
1331 | 1331 | $ echo '[ui]' > .hg/hgrc |
|
1332 | 1332 | $ echo 'style = t' >> .hg/hgrc |
|
1333 | 1333 | $ hg log |
|
1334 | 1334 | 8 |
|
1335 | 1335 | 7 |
|
1336 | 1336 | 6 |
|
1337 | 1337 | 5 |
|
1338 | 1338 | 4 |
|
1339 | 1339 | 3 |
|
1340 | 1340 | 2 |
|
1341 | 1341 | 1 |
|
1342 | 1342 | 0 |
|
1343 | 1343 | |
|
1344 | 1344 | |
|
1345 | 1345 | Issue338: |
|
1346 | 1346 | |
|
1347 | 1347 | $ hg log --style=changelog > changelog |
|
1348 | 1348 | |
|
1349 | 1349 | $ cat changelog |
|
1350 | 1350 | 2020-01-01 test <test> |
|
1351 | 1351 | |
|
1352 | 1352 | * fourth, second, third: |
|
1353 | 1353 | third |
|
1354 | 1354 | [95c24699272e] [tip] |
|
1355 | 1355 | |
|
1356 | 1356 | 1970-01-12 User Name <user@hostname> |
|
1357 | 1357 | |
|
1358 | 1358 | * second: |
|
1359 | 1359 | second |
|
1360 | 1360 | [29114dbae42b] |
|
1361 | 1361 | |
|
1362 | 1362 | 1970-01-18 person <person> |
|
1363 | 1363 | |
|
1364 | 1364 | * merge |
|
1365 | 1365 | [d41e714fe50d] |
|
1366 | 1366 | |
|
1367 | 1367 | * d: |
|
1368 | 1368 | new head |
|
1369 | 1369 | [13207e5a10d9] |
|
1370 | 1370 | |
|
1371 | 1371 | 1970-01-17 person <person> |
|
1372 | 1372 | |
|
1373 | 1373 | * new branch |
|
1374 | 1374 | [bbe44766e73d] <foo> |
|
1375 | 1375 | |
|
1376 | 1376 | 1970-01-16 person <person> |
|
1377 | 1377 | |
|
1378 | 1378 | * c: |
|
1379 | 1379 | no user, no domain |
|
1380 | 1380 | [10e46f2dcbf4] |
|
1381 | 1381 | |
|
1382 | 1382 | 1970-01-14 other <other@place> |
|
1383 | 1383 | |
|
1384 | 1384 | * c: |
|
1385 | 1385 | no person |
|
1386 | 1386 | [97054abb4ab8] |
|
1387 | 1387 | |
|
1388 | 1388 | 1970-01-13 A. N. Other <other@place> |
|
1389 | 1389 | |
|
1390 | 1390 | * b: |
|
1391 | 1391 | other 1 other 2 |
|
1392 | 1392 | |
|
1393 | 1393 | other 3 |
|
1394 | 1394 | [b608e9d1a3f0] |
|
1395 | 1395 | |
|
1396 | 1396 | 1970-01-12 User Name <user@hostname> |
|
1397 | 1397 | |
|
1398 | 1398 | * a: |
|
1399 | 1399 | line 1 line 2 |
|
1400 | 1400 | [1e4e1b8f71e0] |
|
1401 | 1401 | |
|
1402 | 1402 | |
|
1403 | 1403 | Issue2130: xml output for 'hg heads' is malformed |
|
1404 | 1404 | |
|
1405 | 1405 | $ hg heads --style changelog |
|
1406 | 1406 | 2020-01-01 test <test> |
|
1407 | 1407 | |
|
1408 | 1408 | * fourth, second, third: |
|
1409 | 1409 | third |
|
1410 | 1410 | [95c24699272e] [tip] |
|
1411 | 1411 | |
|
1412 | 1412 | 1970-01-18 person <person> |
|
1413 | 1413 | |
|
1414 | 1414 | * merge |
|
1415 | 1415 | [d41e714fe50d] |
|
1416 | 1416 | |
|
1417 | 1417 | 1970-01-17 person <person> |
|
1418 | 1418 | |
|
1419 | 1419 | * new branch |
|
1420 | 1420 | [bbe44766e73d] <foo> |
|
1421 | 1421 | |
|
1422 | 1422 | |
|
1423 | 1423 | Keys work: |
|
1424 | 1424 | |
|
1425 | 1425 | $ for key in author branch branches date desc file_adds file_dels file_mods \ |
|
1426 | 1426 | > file_copies file_copies_switch files \ |
|
1427 | 1427 | > manifest node parents rev tags diffstat extras \ |
|
1428 | 1428 | > p1rev p2rev p1node p2node; do |
|
1429 | 1429 | > for mode in '' --verbose --debug; do |
|
1430 | 1430 | > hg log $mode --template "$key$mode: {$key}\n" |
|
1431 | 1431 | > done |
|
1432 | 1432 | > done |
|
1433 | 1433 | author: test |
|
1434 | 1434 | author: User Name <user@hostname> |
|
1435 | 1435 | author: person |
|
1436 | 1436 | author: person |
|
1437 | 1437 | author: person |
|
1438 | 1438 | author: person |
|
1439 | 1439 | author: other@place |
|
1440 | 1440 | author: A. N. Other <other@place> |
|
1441 | 1441 | author: User Name <user@hostname> |
|
1442 | 1442 | author--verbose: test |
|
1443 | 1443 | author--verbose: User Name <user@hostname> |
|
1444 | 1444 | author--verbose: person |
|
1445 | 1445 | author--verbose: person |
|
1446 | 1446 | author--verbose: person |
|
1447 | 1447 | author--verbose: person |
|
1448 | 1448 | author--verbose: other@place |
|
1449 | 1449 | author--verbose: A. N. Other <other@place> |
|
1450 | 1450 | author--verbose: User Name <user@hostname> |
|
1451 | 1451 | author--debug: test |
|
1452 | 1452 | author--debug: User Name <user@hostname> |
|
1453 | 1453 | author--debug: person |
|
1454 | 1454 | author--debug: person |
|
1455 | 1455 | author--debug: person |
|
1456 | 1456 | author--debug: person |
|
1457 | 1457 | author--debug: other@place |
|
1458 | 1458 | author--debug: A. N. Other <other@place> |
|
1459 | 1459 | author--debug: User Name <user@hostname> |
|
1460 | 1460 | branch: default |
|
1461 | 1461 | branch: default |
|
1462 | 1462 | branch: default |
|
1463 | 1463 | branch: default |
|
1464 | 1464 | branch: foo |
|
1465 | 1465 | branch: default |
|
1466 | 1466 | branch: default |
|
1467 | 1467 | branch: default |
|
1468 | 1468 | branch: default |
|
1469 | 1469 | branch--verbose: default |
|
1470 | 1470 | branch--verbose: default |
|
1471 | 1471 | branch--verbose: default |
|
1472 | 1472 | branch--verbose: default |
|
1473 | 1473 | branch--verbose: foo |
|
1474 | 1474 | branch--verbose: default |
|
1475 | 1475 | branch--verbose: default |
|
1476 | 1476 | branch--verbose: default |
|
1477 | 1477 | branch--verbose: default |
|
1478 | 1478 | branch--debug: default |
|
1479 | 1479 | branch--debug: default |
|
1480 | 1480 | branch--debug: default |
|
1481 | 1481 | branch--debug: default |
|
1482 | 1482 | branch--debug: foo |
|
1483 | 1483 | branch--debug: default |
|
1484 | 1484 | branch--debug: default |
|
1485 | 1485 | branch--debug: default |
|
1486 | 1486 | branch--debug: default |
|
1487 | 1487 | branches: |
|
1488 | 1488 | branches: |
|
1489 | 1489 | branches: |
|
1490 | 1490 | branches: |
|
1491 | 1491 | branches: foo |
|
1492 | 1492 | branches: |
|
1493 | 1493 | branches: |
|
1494 | 1494 | branches: |
|
1495 | 1495 | branches: |
|
1496 | 1496 | branches--verbose: |
|
1497 | 1497 | branches--verbose: |
|
1498 | 1498 | branches--verbose: |
|
1499 | 1499 | branches--verbose: |
|
1500 | 1500 | branches--verbose: foo |
|
1501 | 1501 | branches--verbose: |
|
1502 | 1502 | branches--verbose: |
|
1503 | 1503 | branches--verbose: |
|
1504 | 1504 | branches--verbose: |
|
1505 | 1505 | branches--debug: |
|
1506 | 1506 | branches--debug: |
|
1507 | 1507 | branches--debug: |
|
1508 | 1508 | branches--debug: |
|
1509 | 1509 | branches--debug: foo |
|
1510 | 1510 | branches--debug: |
|
1511 | 1511 | branches--debug: |
|
1512 | 1512 | branches--debug: |
|
1513 | 1513 | branches--debug: |
|
1514 | 1514 | date: 1577872860.00 |
|
1515 | 1515 | date: 1000000.00 |
|
1516 | 1516 | date: 1500001.00 |
|
1517 | 1517 | date: 1500000.00 |
|
1518 | 1518 | date: 1400000.00 |
|
1519 | 1519 | date: 1300000.00 |
|
1520 | 1520 | date: 1200000.00 |
|
1521 | 1521 | date: 1100000.00 |
|
1522 | 1522 | date: 1000000.00 |
|
1523 | 1523 | date--verbose: 1577872860.00 |
|
1524 | 1524 | date--verbose: 1000000.00 |
|
1525 | 1525 | date--verbose: 1500001.00 |
|
1526 | 1526 | date--verbose: 1500000.00 |
|
1527 | 1527 | date--verbose: 1400000.00 |
|
1528 | 1528 | date--verbose: 1300000.00 |
|
1529 | 1529 | date--verbose: 1200000.00 |
|
1530 | 1530 | date--verbose: 1100000.00 |
|
1531 | 1531 | date--verbose: 1000000.00 |
|
1532 | 1532 | date--debug: 1577872860.00 |
|
1533 | 1533 | date--debug: 1000000.00 |
|
1534 | 1534 | date--debug: 1500001.00 |
|
1535 | 1535 | date--debug: 1500000.00 |
|
1536 | 1536 | date--debug: 1400000.00 |
|
1537 | 1537 | date--debug: 1300000.00 |
|
1538 | 1538 | date--debug: 1200000.00 |
|
1539 | 1539 | date--debug: 1100000.00 |
|
1540 | 1540 | date--debug: 1000000.00 |
|
1541 | 1541 | desc: third |
|
1542 | 1542 | desc: second |
|
1543 | 1543 | desc: merge |
|
1544 | 1544 | desc: new head |
|
1545 | 1545 | desc: new branch |
|
1546 | 1546 | desc: no user, no domain |
|
1547 | 1547 | desc: no person |
|
1548 | 1548 | desc: other 1 |
|
1549 | 1549 | other 2 |
|
1550 | 1550 | |
|
1551 | 1551 | other 3 |
|
1552 | 1552 | desc: line 1 |
|
1553 | 1553 | line 2 |
|
1554 | 1554 | desc--verbose: third |
|
1555 | 1555 | desc--verbose: second |
|
1556 | 1556 | desc--verbose: merge |
|
1557 | 1557 | desc--verbose: new head |
|
1558 | 1558 | desc--verbose: new branch |
|
1559 | 1559 | desc--verbose: no user, no domain |
|
1560 | 1560 | desc--verbose: no person |
|
1561 | 1561 | desc--verbose: other 1 |
|
1562 | 1562 | other 2 |
|
1563 | 1563 | |
|
1564 | 1564 | other 3 |
|
1565 | 1565 | desc--verbose: line 1 |
|
1566 | 1566 | line 2 |
|
1567 | 1567 | desc--debug: third |
|
1568 | 1568 | desc--debug: second |
|
1569 | 1569 | desc--debug: merge |
|
1570 | 1570 | desc--debug: new head |
|
1571 | 1571 | desc--debug: new branch |
|
1572 | 1572 | desc--debug: no user, no domain |
|
1573 | 1573 | desc--debug: no person |
|
1574 | 1574 | desc--debug: other 1 |
|
1575 | 1575 | other 2 |
|
1576 | 1576 | |
|
1577 | 1577 | other 3 |
|
1578 | 1578 | desc--debug: line 1 |
|
1579 | 1579 | line 2 |
|
1580 | 1580 | file_adds: fourth third |
|
1581 | 1581 | file_adds: second |
|
1582 | 1582 | file_adds: |
|
1583 | 1583 | file_adds: d |
|
1584 | 1584 | file_adds: |
|
1585 | 1585 | file_adds: |
|
1586 | 1586 | file_adds: c |
|
1587 | 1587 | file_adds: b |
|
1588 | 1588 | file_adds: a |
|
1589 | 1589 | file_adds--verbose: fourth third |
|
1590 | 1590 | file_adds--verbose: second |
|
1591 | 1591 | file_adds--verbose: |
|
1592 | 1592 | file_adds--verbose: d |
|
1593 | 1593 | file_adds--verbose: |
|
1594 | 1594 | file_adds--verbose: |
|
1595 | 1595 | file_adds--verbose: c |
|
1596 | 1596 | file_adds--verbose: b |
|
1597 | 1597 | file_adds--verbose: a |
|
1598 | 1598 | file_adds--debug: fourth third |
|
1599 | 1599 | file_adds--debug: second |
|
1600 | 1600 | file_adds--debug: |
|
1601 | 1601 | file_adds--debug: d |
|
1602 | 1602 | file_adds--debug: |
|
1603 | 1603 | file_adds--debug: |
|
1604 | 1604 | file_adds--debug: c |
|
1605 | 1605 | file_adds--debug: b |
|
1606 | 1606 | file_adds--debug: a |
|
1607 | 1607 | file_dels: second |
|
1608 | 1608 | file_dels: |
|
1609 | 1609 | file_dels: |
|
1610 | 1610 | file_dels: |
|
1611 | 1611 | file_dels: |
|
1612 | 1612 | file_dels: |
|
1613 | 1613 | file_dels: |
|
1614 | 1614 | file_dels: |
|
1615 | 1615 | file_dels: |
|
1616 | 1616 | file_dels--verbose: second |
|
1617 | 1617 | file_dels--verbose: |
|
1618 | 1618 | file_dels--verbose: |
|
1619 | 1619 | file_dels--verbose: |
|
1620 | 1620 | file_dels--verbose: |
|
1621 | 1621 | file_dels--verbose: |
|
1622 | 1622 | file_dels--verbose: |
|
1623 | 1623 | file_dels--verbose: |
|
1624 | 1624 | file_dels--verbose: |
|
1625 | 1625 | file_dels--debug: second |
|
1626 | 1626 | file_dels--debug: |
|
1627 | 1627 | file_dels--debug: |
|
1628 | 1628 | file_dels--debug: |
|
1629 | 1629 | file_dels--debug: |
|
1630 | 1630 | file_dels--debug: |
|
1631 | 1631 | file_dels--debug: |
|
1632 | 1632 | file_dels--debug: |
|
1633 | 1633 | file_dels--debug: |
|
1634 | 1634 | file_mods: |
|
1635 | 1635 | file_mods: |
|
1636 | 1636 | file_mods: |
|
1637 | 1637 | file_mods: |
|
1638 | 1638 | file_mods: |
|
1639 | 1639 | file_mods: c |
|
1640 | 1640 | file_mods: |
|
1641 | 1641 | file_mods: |
|
1642 | 1642 | file_mods: |
|
1643 | 1643 | file_mods--verbose: |
|
1644 | 1644 | file_mods--verbose: |
|
1645 | 1645 | file_mods--verbose: |
|
1646 | 1646 | file_mods--verbose: |
|
1647 | 1647 | file_mods--verbose: |
|
1648 | 1648 | file_mods--verbose: c |
|
1649 | 1649 | file_mods--verbose: |
|
1650 | 1650 | file_mods--verbose: |
|
1651 | 1651 | file_mods--verbose: |
|
1652 | 1652 | file_mods--debug: |
|
1653 | 1653 | file_mods--debug: |
|
1654 | 1654 | file_mods--debug: |
|
1655 | 1655 | file_mods--debug: |
|
1656 | 1656 | file_mods--debug: |
|
1657 | 1657 | file_mods--debug: c |
|
1658 | 1658 | file_mods--debug: |
|
1659 | 1659 | file_mods--debug: |
|
1660 | 1660 | file_mods--debug: |
|
1661 | 1661 | file_copies: fourth (second) |
|
1662 | 1662 | file_copies: |
|
1663 | 1663 | file_copies: |
|
1664 | 1664 | file_copies: |
|
1665 | 1665 | file_copies: |
|
1666 | 1666 | file_copies: |
|
1667 | 1667 | file_copies: |
|
1668 | 1668 | file_copies: |
|
1669 | 1669 | file_copies: |
|
1670 | 1670 | file_copies--verbose: fourth (second) |
|
1671 | 1671 | file_copies--verbose: |
|
1672 | 1672 | file_copies--verbose: |
|
1673 | 1673 | file_copies--verbose: |
|
1674 | 1674 | file_copies--verbose: |
|
1675 | 1675 | file_copies--verbose: |
|
1676 | 1676 | file_copies--verbose: |
|
1677 | 1677 | file_copies--verbose: |
|
1678 | 1678 | file_copies--verbose: |
|
1679 | 1679 | file_copies--debug: fourth (second) |
|
1680 | 1680 | file_copies--debug: |
|
1681 | 1681 | file_copies--debug: |
|
1682 | 1682 | file_copies--debug: |
|
1683 | 1683 | file_copies--debug: |
|
1684 | 1684 | file_copies--debug: |
|
1685 | 1685 | file_copies--debug: |
|
1686 | 1686 | file_copies--debug: |
|
1687 | 1687 | file_copies--debug: |
|
1688 | 1688 | file_copies_switch: |
|
1689 | 1689 | file_copies_switch: |
|
1690 | 1690 | file_copies_switch: |
|
1691 | 1691 | file_copies_switch: |
|
1692 | 1692 | file_copies_switch: |
|
1693 | 1693 | file_copies_switch: |
|
1694 | 1694 | file_copies_switch: |
|
1695 | 1695 | file_copies_switch: |
|
1696 | 1696 | file_copies_switch: |
|
1697 | 1697 | file_copies_switch--verbose: |
|
1698 | 1698 | file_copies_switch--verbose: |
|
1699 | 1699 | file_copies_switch--verbose: |
|
1700 | 1700 | file_copies_switch--verbose: |
|
1701 | 1701 | file_copies_switch--verbose: |
|
1702 | 1702 | file_copies_switch--verbose: |
|
1703 | 1703 | file_copies_switch--verbose: |
|
1704 | 1704 | file_copies_switch--verbose: |
|
1705 | 1705 | file_copies_switch--verbose: |
|
1706 | 1706 | file_copies_switch--debug: |
|
1707 | 1707 | file_copies_switch--debug: |
|
1708 | 1708 | file_copies_switch--debug: |
|
1709 | 1709 | file_copies_switch--debug: |
|
1710 | 1710 | file_copies_switch--debug: |
|
1711 | 1711 | file_copies_switch--debug: |
|
1712 | 1712 | file_copies_switch--debug: |
|
1713 | 1713 | file_copies_switch--debug: |
|
1714 | 1714 | file_copies_switch--debug: |
|
1715 | 1715 | files: fourth second third |
|
1716 | 1716 | files: second |
|
1717 | 1717 | files: |
|
1718 | 1718 | files: d |
|
1719 | 1719 | files: |
|
1720 | 1720 | files: c |
|
1721 | 1721 | files: c |
|
1722 | 1722 | files: b |
|
1723 | 1723 | files: a |
|
1724 | 1724 | files--verbose: fourth second third |
|
1725 | 1725 | files--verbose: second |
|
1726 | 1726 | files--verbose: |
|
1727 | 1727 | files--verbose: d |
|
1728 | 1728 | files--verbose: |
|
1729 | 1729 | files--verbose: c |
|
1730 | 1730 | files--verbose: c |
|
1731 | 1731 | files--verbose: b |
|
1732 | 1732 | files--verbose: a |
|
1733 | 1733 | files--debug: fourth second third |
|
1734 | 1734 | files--debug: second |
|
1735 | 1735 | files--debug: |
|
1736 | 1736 | files--debug: d |
|
1737 | 1737 | files--debug: |
|
1738 | 1738 | files--debug: c |
|
1739 | 1739 | files--debug: c |
|
1740 | 1740 | files--debug: b |
|
1741 | 1741 | files--debug: a |
|
1742 | 1742 | manifest: 6:94961b75a2da |
|
1743 | 1743 | manifest: 5:f2dbc354b94e |
|
1744 | 1744 | manifest: 4:4dc3def4f9b4 |
|
1745 | 1745 | manifest: 4:4dc3def4f9b4 |
|
1746 | 1746 | manifest: 3:cb5a1327723b |
|
1747 | 1747 | manifest: 3:cb5a1327723b |
|
1748 | 1748 | manifest: 2:6e0e82995c35 |
|
1749 | 1749 | manifest: 1:4e8d705b1e53 |
|
1750 | 1750 | manifest: 0:a0c8bcbbb45c |
|
1751 | 1751 | manifest--verbose: 6:94961b75a2da |
|
1752 | 1752 | manifest--verbose: 5:f2dbc354b94e |
|
1753 | 1753 | manifest--verbose: 4:4dc3def4f9b4 |
|
1754 | 1754 | manifest--verbose: 4:4dc3def4f9b4 |
|
1755 | 1755 | manifest--verbose: 3:cb5a1327723b |
|
1756 | 1756 | manifest--verbose: 3:cb5a1327723b |
|
1757 | 1757 | manifest--verbose: 2:6e0e82995c35 |
|
1758 | 1758 | manifest--verbose: 1:4e8d705b1e53 |
|
1759 | 1759 | manifest--verbose: 0:a0c8bcbbb45c |
|
1760 | 1760 | manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64 |
|
1761 | 1761 | manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf |
|
1762 | 1762 | manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216 |
|
1763 | 1763 | manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216 |
|
1764 | 1764 | manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
1765 | 1765 | manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
1766 | 1766 | manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1 |
|
1767 | 1767 | manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55 |
|
1768 | 1768 | manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 |
|
1769 | 1769 | node: 95c24699272ef57d062b8bccc32c878bf841784a |
|
1770 | 1770 | node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1771 | 1771 | node: d41e714fe50d9e4a5f11b4d595d543481b5f980b |
|
1772 | 1772 | node: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1773 | 1773 | node: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1774 | 1774 | node: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1775 | 1775 | node: 97054abb4ab824450e9164180baf491ae0078465 |
|
1776 | 1776 | node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1777 | 1777 | node: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1778 | 1778 | node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a |
|
1779 | 1779 | node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1780 | 1780 | node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b |
|
1781 | 1781 | node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1782 | 1782 | node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1783 | 1783 | node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1784 | 1784 | node--verbose: 97054abb4ab824450e9164180baf491ae0078465 |
|
1785 | 1785 | node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1786 | 1786 | node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1787 | 1787 | node--debug: 95c24699272ef57d062b8bccc32c878bf841784a |
|
1788 | 1788 | node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1789 | 1789 | node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b |
|
1790 | 1790 | node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1791 | 1791 | node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1792 | 1792 | node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1793 | 1793 | node--debug: 97054abb4ab824450e9164180baf491ae0078465 |
|
1794 | 1794 | node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1795 | 1795 | node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1796 | 1796 | parents: |
|
1797 | 1797 | parents: -1:000000000000 |
|
1798 | 1798 | parents: 5:13207e5a10d9 4:bbe44766e73d |
|
1799 | 1799 | parents: 3:10e46f2dcbf4 |
|
1800 | 1800 | parents: |
|
1801 | 1801 | parents: |
|
1802 | 1802 | parents: |
|
1803 | 1803 | parents: |
|
1804 | 1804 | parents: |
|
1805 | 1805 | parents--verbose: |
|
1806 | 1806 | parents--verbose: -1:000000000000 |
|
1807 | 1807 | parents--verbose: 5:13207e5a10d9 4:bbe44766e73d |
|
1808 | 1808 | parents--verbose: 3:10e46f2dcbf4 |
|
1809 | 1809 | parents--verbose: |
|
1810 | 1810 | parents--verbose: |
|
1811 | 1811 | parents--verbose: |
|
1812 | 1812 | parents--verbose: |
|
1813 | 1813 | parents--verbose: |
|
1814 | 1814 | parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000 |
|
1815 | 1815 | parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000 |
|
1816 | 1816 | parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1817 | 1817 | parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000 |
|
1818 | 1818 | parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000 |
|
1819 | 1819 | parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000 |
|
1820 | 1820 | parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000 |
|
1821 | 1821 | parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000 |
|
1822 | 1822 | parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000 |
|
1823 | 1823 | rev: 8 |
|
1824 | 1824 | rev: 7 |
|
1825 | 1825 | rev: 6 |
|
1826 | 1826 | rev: 5 |
|
1827 | 1827 | rev: 4 |
|
1828 | 1828 | rev: 3 |
|
1829 | 1829 | rev: 2 |
|
1830 | 1830 | rev: 1 |
|
1831 | 1831 | rev: 0 |
|
1832 | 1832 | rev--verbose: 8 |
|
1833 | 1833 | rev--verbose: 7 |
|
1834 | 1834 | rev--verbose: 6 |
|
1835 | 1835 | rev--verbose: 5 |
|
1836 | 1836 | rev--verbose: 4 |
|
1837 | 1837 | rev--verbose: 3 |
|
1838 | 1838 | rev--verbose: 2 |
|
1839 | 1839 | rev--verbose: 1 |
|
1840 | 1840 | rev--verbose: 0 |
|
1841 | 1841 | rev--debug: 8 |
|
1842 | 1842 | rev--debug: 7 |
|
1843 | 1843 | rev--debug: 6 |
|
1844 | 1844 | rev--debug: 5 |
|
1845 | 1845 | rev--debug: 4 |
|
1846 | 1846 | rev--debug: 3 |
|
1847 | 1847 | rev--debug: 2 |
|
1848 | 1848 | rev--debug: 1 |
|
1849 | 1849 | rev--debug: 0 |
|
1850 | 1850 | tags: tip |
|
1851 | 1851 | tags: |
|
1852 | 1852 | tags: |
|
1853 | 1853 | tags: |
|
1854 | 1854 | tags: |
|
1855 | 1855 | tags: |
|
1856 | 1856 | tags: |
|
1857 | 1857 | tags: |
|
1858 | 1858 | tags: |
|
1859 | 1859 | tags--verbose: tip |
|
1860 | 1860 | tags--verbose: |
|
1861 | 1861 | tags--verbose: |
|
1862 | 1862 | tags--verbose: |
|
1863 | 1863 | tags--verbose: |
|
1864 | 1864 | tags--verbose: |
|
1865 | 1865 | tags--verbose: |
|
1866 | 1866 | tags--verbose: |
|
1867 | 1867 | tags--verbose: |
|
1868 | 1868 | tags--debug: tip |
|
1869 | 1869 | tags--debug: |
|
1870 | 1870 | tags--debug: |
|
1871 | 1871 | tags--debug: |
|
1872 | 1872 | tags--debug: |
|
1873 | 1873 | tags--debug: |
|
1874 | 1874 | tags--debug: |
|
1875 | 1875 | tags--debug: |
|
1876 | 1876 | tags--debug: |
|
1877 | 1877 | diffstat: 3: +2/-1 |
|
1878 | 1878 | diffstat: 1: +1/-0 |
|
1879 | 1879 | diffstat: 0: +0/-0 |
|
1880 | 1880 | diffstat: 1: +1/-0 |
|
1881 | 1881 | diffstat: 0: +0/-0 |
|
1882 | 1882 | diffstat: 1: +1/-0 |
|
1883 | 1883 | diffstat: 1: +4/-0 |
|
1884 | 1884 | diffstat: 1: +2/-0 |
|
1885 | 1885 | diffstat: 1: +1/-0 |
|
1886 | 1886 | diffstat--verbose: 3: +2/-1 |
|
1887 | 1887 | diffstat--verbose: 1: +1/-0 |
|
1888 | 1888 | diffstat--verbose: 0: +0/-0 |
|
1889 | 1889 | diffstat--verbose: 1: +1/-0 |
|
1890 | 1890 | diffstat--verbose: 0: +0/-0 |
|
1891 | 1891 | diffstat--verbose: 1: +1/-0 |
|
1892 | 1892 | diffstat--verbose: 1: +4/-0 |
|
1893 | 1893 | diffstat--verbose: 1: +2/-0 |
|
1894 | 1894 | diffstat--verbose: 1: +1/-0 |
|
1895 | 1895 | diffstat--debug: 3: +2/-1 |
|
1896 | 1896 | diffstat--debug: 1: +1/-0 |
|
1897 | 1897 | diffstat--debug: 0: +0/-0 |
|
1898 | 1898 | diffstat--debug: 1: +1/-0 |
|
1899 | 1899 | diffstat--debug: 0: +0/-0 |
|
1900 | 1900 | diffstat--debug: 1: +1/-0 |
|
1901 | 1901 | diffstat--debug: 1: +4/-0 |
|
1902 | 1902 | diffstat--debug: 1: +2/-0 |
|
1903 | 1903 | diffstat--debug: 1: +1/-0 |
|
1904 | 1904 | extras: branch=default |
|
1905 | 1905 | extras: branch=default |
|
1906 | 1906 | extras: branch=default |
|
1907 | 1907 | extras: branch=default |
|
1908 | 1908 | extras: branch=foo |
|
1909 | 1909 | extras: branch=default |
|
1910 | 1910 | extras: branch=default |
|
1911 | 1911 | extras: branch=default |
|
1912 | 1912 | extras: branch=default |
|
1913 | 1913 | extras--verbose: branch=default |
|
1914 | 1914 | extras--verbose: branch=default |
|
1915 | 1915 | extras--verbose: branch=default |
|
1916 | 1916 | extras--verbose: branch=default |
|
1917 | 1917 | extras--verbose: branch=foo |
|
1918 | 1918 | extras--verbose: branch=default |
|
1919 | 1919 | extras--verbose: branch=default |
|
1920 | 1920 | extras--verbose: branch=default |
|
1921 | 1921 | extras--verbose: branch=default |
|
1922 | 1922 | extras--debug: branch=default |
|
1923 | 1923 | extras--debug: branch=default |
|
1924 | 1924 | extras--debug: branch=default |
|
1925 | 1925 | extras--debug: branch=default |
|
1926 | 1926 | extras--debug: branch=foo |
|
1927 | 1927 | extras--debug: branch=default |
|
1928 | 1928 | extras--debug: branch=default |
|
1929 | 1929 | extras--debug: branch=default |
|
1930 | 1930 | extras--debug: branch=default |
|
1931 | 1931 | p1rev: 7 |
|
1932 | 1932 | p1rev: -1 |
|
1933 | 1933 | p1rev: 5 |
|
1934 | 1934 | p1rev: 3 |
|
1935 | 1935 | p1rev: 3 |
|
1936 | 1936 | p1rev: 2 |
|
1937 | 1937 | p1rev: 1 |
|
1938 | 1938 | p1rev: 0 |
|
1939 | 1939 | p1rev: -1 |
|
1940 | 1940 | p1rev--verbose: 7 |
|
1941 | 1941 | p1rev--verbose: -1 |
|
1942 | 1942 | p1rev--verbose: 5 |
|
1943 | 1943 | p1rev--verbose: 3 |
|
1944 | 1944 | p1rev--verbose: 3 |
|
1945 | 1945 | p1rev--verbose: 2 |
|
1946 | 1946 | p1rev--verbose: 1 |
|
1947 | 1947 | p1rev--verbose: 0 |
|
1948 | 1948 | p1rev--verbose: -1 |
|
1949 | 1949 | p1rev--debug: 7 |
|
1950 | 1950 | p1rev--debug: -1 |
|
1951 | 1951 | p1rev--debug: 5 |
|
1952 | 1952 | p1rev--debug: 3 |
|
1953 | 1953 | p1rev--debug: 3 |
|
1954 | 1954 | p1rev--debug: 2 |
|
1955 | 1955 | p1rev--debug: 1 |
|
1956 | 1956 | p1rev--debug: 0 |
|
1957 | 1957 | p1rev--debug: -1 |
|
1958 | 1958 | p2rev: -1 |
|
1959 | 1959 | p2rev: -1 |
|
1960 | 1960 | p2rev: 4 |
|
1961 | 1961 | p2rev: -1 |
|
1962 | 1962 | p2rev: -1 |
|
1963 | 1963 | p2rev: -1 |
|
1964 | 1964 | p2rev: -1 |
|
1965 | 1965 | p2rev: -1 |
|
1966 | 1966 | p2rev: -1 |
|
1967 | 1967 | p2rev--verbose: -1 |
|
1968 | 1968 | p2rev--verbose: -1 |
|
1969 | 1969 | p2rev--verbose: 4 |
|
1970 | 1970 | p2rev--verbose: -1 |
|
1971 | 1971 | p2rev--verbose: -1 |
|
1972 | 1972 | p2rev--verbose: -1 |
|
1973 | 1973 | p2rev--verbose: -1 |
|
1974 | 1974 | p2rev--verbose: -1 |
|
1975 | 1975 | p2rev--verbose: -1 |
|
1976 | 1976 | p2rev--debug: -1 |
|
1977 | 1977 | p2rev--debug: -1 |
|
1978 | 1978 | p2rev--debug: 4 |
|
1979 | 1979 | p2rev--debug: -1 |
|
1980 | 1980 | p2rev--debug: -1 |
|
1981 | 1981 | p2rev--debug: -1 |
|
1982 | 1982 | p2rev--debug: -1 |
|
1983 | 1983 | p2rev--debug: -1 |
|
1984 | 1984 | p2rev--debug: -1 |
|
1985 | 1985 | p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1986 | 1986 | p1node: 0000000000000000000000000000000000000000 |
|
1987 | 1987 | p1node: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1988 | 1988 | p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1989 | 1989 | p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1990 | 1990 | p1node: 97054abb4ab824450e9164180baf491ae0078465 |
|
1991 | 1991 | p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1992 | 1992 | p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1993 | 1993 | p1node: 0000000000000000000000000000000000000000 |
|
1994 | 1994 | p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1995 | 1995 | p1node--verbose: 0000000000000000000000000000000000000000 |
|
1996 | 1996 | p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1997 | 1997 | p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1998 | 1998 | p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1999 | 1999 | p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465 |
|
2000 | 2000 | p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2001 | 2001 | p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2002 | 2002 | p1node--verbose: 0000000000000000000000000000000000000000 |
|
2003 | 2003 | p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
2004 | 2004 | p1node--debug: 0000000000000000000000000000000000000000 |
|
2005 | 2005 | p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
2006 | 2006 | p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2007 | 2007 | p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2008 | 2008 | p1node--debug: 97054abb4ab824450e9164180baf491ae0078465 |
|
2009 | 2009 | p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2010 | 2010 | p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2011 | 2011 | p1node--debug: 0000000000000000000000000000000000000000 |
|
2012 | 2012 | p2node: 0000000000000000000000000000000000000000 |
|
2013 | 2013 | p2node: 0000000000000000000000000000000000000000 |
|
2014 | 2014 | p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2015 | 2015 | p2node: 0000000000000000000000000000000000000000 |
|
2016 | 2016 | p2node: 0000000000000000000000000000000000000000 |
|
2017 | 2017 | p2node: 0000000000000000000000000000000000000000 |
|
2018 | 2018 | p2node: 0000000000000000000000000000000000000000 |
|
2019 | 2019 | p2node: 0000000000000000000000000000000000000000 |
|
2020 | 2020 | p2node: 0000000000000000000000000000000000000000 |
|
2021 | 2021 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2022 | 2022 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2023 | 2023 | p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2024 | 2024 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2025 | 2025 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2026 | 2026 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2027 | 2027 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2028 | 2028 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2029 | 2029 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2030 | 2030 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2031 | 2031 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2032 | 2032 | p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2033 | 2033 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2034 | 2034 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2035 | 2035 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2036 | 2036 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2037 | 2037 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2038 | 2038 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2039 | 2039 | |
|
2040 | 2040 | Filters work: |
|
2041 | 2041 | |
|
2042 | 2042 | $ hg log --template '{author|domain}\n' |
|
2043 | 2043 | |
|
2044 | 2044 | hostname |
|
2045 | 2045 | |
|
2046 | 2046 | |
|
2047 | 2047 | |
|
2048 | 2048 | |
|
2049 | 2049 | place |
|
2050 | 2050 | place |
|
2051 | 2051 | hostname |
|
2052 | 2052 | |
|
2053 | 2053 | $ hg log --template '{author|person}\n' |
|
2054 | 2054 | test |
|
2055 | 2055 | User Name |
|
2056 | 2056 | person |
|
2057 | 2057 | person |
|
2058 | 2058 | person |
|
2059 | 2059 | person |
|
2060 | 2060 | other |
|
2061 | 2061 | A. N. Other |
|
2062 | 2062 | User Name |
|
2063 | 2063 | |
|
2064 | 2064 | $ hg log --template '{author|user}\n' |
|
2065 | 2065 | test |
|
2066 | 2066 | user |
|
2067 | 2067 | person |
|
2068 | 2068 | person |
|
2069 | 2069 | person |
|
2070 | 2070 | person |
|
2071 | 2071 | other |
|
2072 | 2072 | other |
|
2073 | 2073 | user |
|
2074 | 2074 | |
|
2075 | 2075 | $ hg log --template '{date|date}\n' |
|
2076 | 2076 | Wed Jan 01 10:01:00 2020 +0000 |
|
2077 | 2077 | Mon Jan 12 13:46:40 1970 +0000 |
|
2078 | 2078 | Sun Jan 18 08:40:01 1970 +0000 |
|
2079 | 2079 | Sun Jan 18 08:40:00 1970 +0000 |
|
2080 | 2080 | Sat Jan 17 04:53:20 1970 +0000 |
|
2081 | 2081 | Fri Jan 16 01:06:40 1970 +0000 |
|
2082 | 2082 | Wed Jan 14 21:20:00 1970 +0000 |
|
2083 | 2083 | Tue Jan 13 17:33:20 1970 +0000 |
|
2084 | 2084 | Mon Jan 12 13:46:40 1970 +0000 |
|
2085 | 2085 | |
|
2086 | 2086 | $ hg log --template '{date|isodate}\n' |
|
2087 | 2087 | 2020-01-01 10:01 +0000 |
|
2088 | 2088 | 1970-01-12 13:46 +0000 |
|
2089 | 2089 | 1970-01-18 08:40 +0000 |
|
2090 | 2090 | 1970-01-18 08:40 +0000 |
|
2091 | 2091 | 1970-01-17 04:53 +0000 |
|
2092 | 2092 | 1970-01-16 01:06 +0000 |
|
2093 | 2093 | 1970-01-14 21:20 +0000 |
|
2094 | 2094 | 1970-01-13 17:33 +0000 |
|
2095 | 2095 | 1970-01-12 13:46 +0000 |
|
2096 | 2096 | |
|
2097 | 2097 | $ hg log --template '{date|isodatesec}\n' |
|
2098 | 2098 | 2020-01-01 10:01:00 +0000 |
|
2099 | 2099 | 1970-01-12 13:46:40 +0000 |
|
2100 | 2100 | 1970-01-18 08:40:01 +0000 |
|
2101 | 2101 | 1970-01-18 08:40:00 +0000 |
|
2102 | 2102 | 1970-01-17 04:53:20 +0000 |
|
2103 | 2103 | 1970-01-16 01:06:40 +0000 |
|
2104 | 2104 | 1970-01-14 21:20:00 +0000 |
|
2105 | 2105 | 1970-01-13 17:33:20 +0000 |
|
2106 | 2106 | 1970-01-12 13:46:40 +0000 |
|
2107 | 2107 | |
|
2108 | 2108 | $ hg log --template '{date|rfc822date}\n' |
|
2109 | 2109 | Wed, 01 Jan 2020 10:01:00 +0000 |
|
2110 | 2110 | Mon, 12 Jan 1970 13:46:40 +0000 |
|
2111 | 2111 | Sun, 18 Jan 1970 08:40:01 +0000 |
|
2112 | 2112 | Sun, 18 Jan 1970 08:40:00 +0000 |
|
2113 | 2113 | Sat, 17 Jan 1970 04:53:20 +0000 |
|
2114 | 2114 | Fri, 16 Jan 1970 01:06:40 +0000 |
|
2115 | 2115 | Wed, 14 Jan 1970 21:20:00 +0000 |
|
2116 | 2116 | Tue, 13 Jan 1970 17:33:20 +0000 |
|
2117 | 2117 | Mon, 12 Jan 1970 13:46:40 +0000 |
|
2118 | 2118 | |
|
2119 | 2119 | $ hg log --template '{desc|firstline}\n' |
|
2120 | 2120 | third |
|
2121 | 2121 | second |
|
2122 | 2122 | merge |
|
2123 | 2123 | new head |
|
2124 | 2124 | new branch |
|
2125 | 2125 | no user, no domain |
|
2126 | 2126 | no person |
|
2127 | 2127 | other 1 |
|
2128 | 2128 | line 1 |
|
2129 | 2129 | |
|
2130 | 2130 | $ hg log --template '{node|short}\n' |
|
2131 | 2131 | 95c24699272e |
|
2132 | 2132 | 29114dbae42b |
|
2133 | 2133 | d41e714fe50d |
|
2134 | 2134 | 13207e5a10d9 |
|
2135 | 2135 | bbe44766e73d |
|
2136 | 2136 | 10e46f2dcbf4 |
|
2137 | 2137 | 97054abb4ab8 |
|
2138 | 2138 | b608e9d1a3f0 |
|
2139 | 2139 | 1e4e1b8f71e0 |
|
2140 | 2140 | |
|
2141 | 2141 | $ hg log --template '<changeset author="{author|xmlescape}"/>\n' |
|
2142 | 2142 | <changeset author="test"/> |
|
2143 | 2143 | <changeset author="User Name <user@hostname>"/> |
|
2144 | 2144 | <changeset author="person"/> |
|
2145 | 2145 | <changeset author="person"/> |
|
2146 | 2146 | <changeset author="person"/> |
|
2147 | 2147 | <changeset author="person"/> |
|
2148 | 2148 | <changeset author="other@place"/> |
|
2149 | 2149 | <changeset author="A. N. Other <other@place>"/> |
|
2150 | 2150 | <changeset author="User Name <user@hostname>"/> |
|
2151 | 2151 | |
|
2152 | 2152 | $ hg log --template '{rev}: {children}\n' |
|
2153 | 2153 | 8: |
|
2154 | 2154 | 7: 8:95c24699272e |
|
2155 | 2155 | 6: |
|
2156 | 2156 | 5: 6:d41e714fe50d |
|
2157 | 2157 | 4: 6:d41e714fe50d |
|
2158 | 2158 | 3: 4:bbe44766e73d 5:13207e5a10d9 |
|
2159 | 2159 | 2: 3:10e46f2dcbf4 |
|
2160 | 2160 | 1: 2:97054abb4ab8 |
|
2161 | 2161 | 0: 1:b608e9d1a3f0 |
|
2162 | 2162 | |
|
2163 | 2163 | Formatnode filter works: |
|
2164 | 2164 | |
|
2165 | 2165 | $ hg -q log -r 0 --template '{node|formatnode}\n' |
|
2166 | 2166 | 1e4e1b8f71e0 |
|
2167 | 2167 | |
|
2168 | 2168 | $ hg log -r 0 --template '{node|formatnode}\n' |
|
2169 | 2169 | 1e4e1b8f71e0 |
|
2170 | 2170 | |
|
2171 | 2171 | $ hg -v log -r 0 --template '{node|formatnode}\n' |
|
2172 | 2172 | 1e4e1b8f71e0 |
|
2173 | 2173 | |
|
2174 | 2174 | $ hg --debug log -r 0 --template '{node|formatnode}\n' |
|
2175 | 2175 | 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2176 | 2176 | |
|
2177 | 2177 | Age filter: |
|
2178 | 2178 | |
|
2179 | 2179 | $ hg init unstable-hash |
|
2180 | 2180 | $ cd unstable-hash |
|
2181 | 2181 | $ hg log --template '{date|age}\n' > /dev/null || exit 1 |
|
2182 | 2182 | |
|
2183 | 2183 | >>> from __future__ import absolute_import |
|
2184 | 2184 | >>> import datetime |
|
2185 | 2185 | >>> fp = open('a', 'w') |
|
2186 | 2186 | >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7) |
|
2187 | 2187 | >>> fp.write('%d-%d-%d 00:00' % (n.year, n.month, n.day)) |
|
2188 | 2188 | >>> fp.close() |
|
2189 | 2189 | $ hg add a |
|
2190 | 2190 | $ hg commit -m future -d "`cat a`" |
|
2191 | 2191 | |
|
2192 | 2192 | $ hg log -l1 --template '{date|age}\n' |
|
2193 | 2193 | 7 years from now |
|
2194 | 2194 | |
|
2195 | 2195 | $ cd .. |
|
2196 | 2196 | $ rm -rf unstable-hash |
|
2197 | 2197 | |
|
2198 | 2198 | Add a dummy commit to make up for the instability of the above: |
|
2199 | 2199 | |
|
2200 | 2200 | $ echo a > a |
|
2201 | 2201 | $ hg add a |
|
2202 | 2202 | $ hg ci -m future |
|
2203 | 2203 | |
|
2204 | 2204 | Count filter: |
|
2205 | 2205 | |
|
2206 | 2206 | $ hg log -l1 --template '{node|count} {node|short|count}\n' |
|
2207 | 2207 | 40 12 |
|
2208 | 2208 | |
|
2209 | 2209 | $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n' |
|
2210 | 2210 | 0 1 4 |
|
2211 | 2211 | |
|
2212 | 2212 | $ hg log -G --template '{rev}: children: {children|count}, \ |
|
2213 | 2213 | > tags: {tags|count}, file_adds: {file_adds|count}, \ |
|
2214 | 2214 | > ancestors: {revset("ancestors(%s)", rev)|count}' |
|
2215 | 2215 | @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3 |
|
2216 | 2216 | | |
|
2217 | 2217 | o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2 |
|
2218 | 2218 | | |
|
2219 | 2219 | o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1 |
|
2220 | 2220 | |
|
2221 | 2221 | o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7 |
|
2222 | 2222 | |\ |
|
2223 | 2223 | | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5 |
|
2224 | 2224 | | | |
|
2225 | 2225 | o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5 |
|
2226 | 2226 | |/ |
|
2227 | 2227 | o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4 |
|
2228 | 2228 | | |
|
2229 | 2229 | o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3 |
|
2230 | 2230 | | |
|
2231 | 2231 | o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2 |
|
2232 | 2232 | | |
|
2233 | 2233 | o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1 |
|
2234 | 2234 | |
|
2235 | 2235 | |
|
2236 | 2236 | Upper/lower filters: |
|
2237 | 2237 | |
|
2238 | 2238 | $ hg log -r0 --template '{branch|upper}\n' |
|
2239 | 2239 | DEFAULT |
|
2240 | 2240 | $ hg log -r0 --template '{author|lower}\n' |
|
2241 | 2241 | user name <user@hostname> |
|
2242 | 2242 | $ hg log -r0 --template '{date|upper}\n' |
|
2243 | 2243 | abort: template filter 'upper' is not compatible with keyword 'date' |
|
2244 | 2244 | [255] |
|
2245 | 2245 | |
|
2246 | 2246 | Add a commit that does all possible modifications at once |
|
2247 | 2247 | |
|
2248 | 2248 | $ echo modify >> third |
|
2249 | 2249 | $ touch b |
|
2250 | 2250 | $ hg add b |
|
2251 | 2251 | $ hg mv fourth fifth |
|
2252 | 2252 | $ hg rm a |
|
2253 | 2253 | $ hg ci -m "Modify, add, remove, rename" |
|
2254 | 2254 | |
|
2255 | 2255 | Check the status template |
|
2256 | 2256 | |
|
2257 | 2257 | $ cat <<EOF >> $HGRCPATH |
|
2258 | 2258 | > [extensions] |
|
2259 | 2259 | > color= |
|
2260 | 2260 | > EOF |
|
2261 | 2261 | |
|
2262 | 2262 | $ hg log -T status -r 10 |
|
2263 | 2263 | changeset: 10:0f9759ec227a |
|
2264 | 2264 | tag: tip |
|
2265 | 2265 | user: test |
|
2266 | 2266 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2267 | 2267 | summary: Modify, add, remove, rename |
|
2268 | 2268 | files: |
|
2269 | 2269 | M third |
|
2270 | 2270 | A b |
|
2271 | 2271 | A fifth |
|
2272 | 2272 | R a |
|
2273 | 2273 | R fourth |
|
2274 | 2274 | |
|
2275 | 2275 | $ hg log -T status -C -r 10 |
|
2276 | 2276 | changeset: 10:0f9759ec227a |
|
2277 | 2277 | tag: tip |
|
2278 | 2278 | user: test |
|
2279 | 2279 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2280 | 2280 | summary: Modify, add, remove, rename |
|
2281 | 2281 | files: |
|
2282 | 2282 | M third |
|
2283 | 2283 | A b |
|
2284 | 2284 | A fifth |
|
2285 | 2285 | fourth |
|
2286 | 2286 | R a |
|
2287 | 2287 | R fourth |
|
2288 | 2288 | |
|
2289 | 2289 | $ hg log -T status -C -r 10 -v |
|
2290 | 2290 | changeset: 10:0f9759ec227a |
|
2291 | 2291 | tag: tip |
|
2292 | 2292 | user: test |
|
2293 | 2293 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2294 | 2294 | description: |
|
2295 | 2295 | Modify, add, remove, rename |
|
2296 | 2296 | |
|
2297 | 2297 | files: |
|
2298 | 2298 | M third |
|
2299 | 2299 | A b |
|
2300 | 2300 | A fifth |
|
2301 | 2301 | fourth |
|
2302 | 2302 | R a |
|
2303 | 2303 | R fourth |
|
2304 | 2304 | |
|
2305 | 2305 | $ hg log -T status -C -r 10 --debug |
|
2306 | 2306 | changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c |
|
2307 | 2307 | tag: tip |
|
2308 | 2308 | phase: secret |
|
2309 | 2309 | parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066 |
|
2310 | 2310 | parent: -1:0000000000000000000000000000000000000000 |
|
2311 | 2311 | manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567 |
|
2312 | 2312 | user: test |
|
2313 | 2313 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2314 | 2314 | extra: branch=default |
|
2315 | 2315 | description: |
|
2316 | 2316 | Modify, add, remove, rename |
|
2317 | 2317 | |
|
2318 | 2318 | files: |
|
2319 | 2319 | M third |
|
2320 | 2320 | A b |
|
2321 | 2321 | A fifth |
|
2322 | 2322 | fourth |
|
2323 | 2323 | R a |
|
2324 | 2324 | R fourth |
|
2325 | 2325 | |
|
2326 | 2326 | $ hg log -T status -C -r 10 --quiet |
|
2327 | 2327 | 10:0f9759ec227a |
|
2328 | 2328 | $ hg --color=debug log -T status -r 10 |
|
2329 | 2329 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a] |
|
2330 | 2330 | [log.tag|tag: tip] |
|
2331 | 2331 | [log.user|user: test] |
|
2332 | 2332 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2333 | 2333 | [log.summary|summary: Modify, add, remove, rename] |
|
2334 | 2334 | [ui.note log.files|files:] |
|
2335 | 2335 | [status.modified|M third] |
|
2336 | 2336 | [status.added|A b] |
|
2337 | 2337 | [status.added|A fifth] |
|
2338 | 2338 | [status.removed|R a] |
|
2339 | 2339 | [status.removed|R fourth] |
|
2340 | 2340 | |
|
2341 | 2341 | $ hg --color=debug log -T status -C -r 10 |
|
2342 | 2342 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a] |
|
2343 | 2343 | [log.tag|tag: tip] |
|
2344 | 2344 | [log.user|user: test] |
|
2345 | 2345 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2346 | 2346 | [log.summary|summary: Modify, add, remove, rename] |
|
2347 | 2347 | [ui.note log.files|files:] |
|
2348 | 2348 | [status.modified|M third] |
|
2349 | 2349 | [status.added|A b] |
|
2350 | 2350 | [status.added|A fifth] |
|
2351 | 2351 | [status.copied| fourth] |
|
2352 | 2352 | [status.removed|R a] |
|
2353 | 2353 | [status.removed|R fourth] |
|
2354 | 2354 | |
|
2355 | 2355 | $ hg --color=debug log -T status -C -r 10 -v |
|
2356 | 2356 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a] |
|
2357 | 2357 | [log.tag|tag: tip] |
|
2358 | 2358 | [log.user|user: test] |
|
2359 | 2359 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2360 | 2360 | [ui.note log.description|description:] |
|
2361 | 2361 | [ui.note log.description|Modify, add, remove, rename] |
|
2362 | 2362 | |
|
2363 | 2363 | [ui.note log.files|files:] |
|
2364 | 2364 | [status.modified|M third] |
|
2365 | 2365 | [status.added|A b] |
|
2366 | 2366 | [status.added|A fifth] |
|
2367 | 2367 | [status.copied| fourth] |
|
2368 | 2368 | [status.removed|R a] |
|
2369 | 2369 | [status.removed|R fourth] |
|
2370 | 2370 | |
|
2371 | 2371 | $ hg --color=debug log -T status -C -r 10 --debug |
|
2372 | 2372 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c] |
|
2373 | 2373 | [log.tag|tag: tip] |
|
2374 | 2374 | [log.phase|phase: secret] |
|
2375 | 2375 | [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066] |
|
2376 | 2376 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2377 | 2377 | [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567] |
|
2378 | 2378 | [log.user|user: test] |
|
2379 | 2379 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2380 | 2380 | [ui.debug log.extra|extra: branch=default] |
|
2381 | 2381 | [ui.note log.description|description:] |
|
2382 | 2382 | [ui.note log.description|Modify, add, remove, rename] |
|
2383 | 2383 | |
|
2384 | 2384 | [ui.note log.files|files:] |
|
2385 | 2385 | [status.modified|M third] |
|
2386 | 2386 | [status.added|A b] |
|
2387 | 2387 | [status.added|A fifth] |
|
2388 | 2388 | [status.copied| fourth] |
|
2389 | 2389 | [status.removed|R a] |
|
2390 | 2390 | [status.removed|R fourth] |
|
2391 | 2391 | |
|
2392 | 2392 | $ hg --color=debug log -T status -C -r 10 --quiet |
|
2393 | 2393 | [log.node|10:0f9759ec227a] |
|
2394 | 2394 | |
|
2395 | 2395 | Check the bisect template |
|
2396 | 2396 | |
|
2397 | 2397 | $ hg bisect -g 1 |
|
2398 | 2398 | $ hg bisect -b 3 --noupdate |
|
2399 | 2399 | Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests) |
|
2400 | 2400 | $ hg log -T bisect -r 0:4 |
|
2401 | 2401 | changeset: 0:1e4e1b8f71e0 |
|
2402 | 2402 | bisect: good (implicit) |
|
2403 | 2403 | user: User Name <user@hostname> |
|
2404 | 2404 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
2405 | 2405 | summary: line 1 |
|
2406 | 2406 | |
|
2407 | 2407 | changeset: 1:b608e9d1a3f0 |
|
2408 | 2408 | bisect: good |
|
2409 | 2409 | user: A. N. Other <other@place> |
|
2410 | 2410 | date: Tue Jan 13 17:33:20 1970 +0000 |
|
2411 | 2411 | summary: other 1 |
|
2412 | 2412 | |
|
2413 | 2413 | changeset: 2:97054abb4ab8 |
|
2414 | 2414 | bisect: untested |
|
2415 | 2415 | user: other@place |
|
2416 | 2416 | date: Wed Jan 14 21:20:00 1970 +0000 |
|
2417 | 2417 | summary: no person |
|
2418 | 2418 | |
|
2419 | 2419 | changeset: 3:10e46f2dcbf4 |
|
2420 | 2420 | bisect: bad |
|
2421 | 2421 | user: person |
|
2422 | 2422 | date: Fri Jan 16 01:06:40 1970 +0000 |
|
2423 | 2423 | summary: no user, no domain |
|
2424 | 2424 | |
|
2425 | 2425 | changeset: 4:bbe44766e73d |
|
2426 | 2426 | bisect: bad (implicit) |
|
2427 | 2427 | branch: foo |
|
2428 | 2428 | user: person |
|
2429 | 2429 | date: Sat Jan 17 04:53:20 1970 +0000 |
|
2430 | 2430 | summary: new branch |
|
2431 | 2431 | |
|
2432 | 2432 | $ hg log --debug -T bisect -r 0:4 |
|
2433 | 2433 | changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2434 | 2434 | bisect: good (implicit) |
|
2435 | 2435 | phase: public |
|
2436 | 2436 | parent: -1:0000000000000000000000000000000000000000 |
|
2437 | 2437 | parent: -1:0000000000000000000000000000000000000000 |
|
2438 | 2438 | manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 |
|
2439 | 2439 | user: User Name <user@hostname> |
|
2440 | 2440 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
2441 | 2441 | files+: a |
|
2442 | 2442 | extra: branch=default |
|
2443 | 2443 | description: |
|
2444 | 2444 | line 1 |
|
2445 | 2445 | line 2 |
|
2446 | 2446 | |
|
2447 | 2447 | |
|
2448 | 2448 | changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2449 | 2449 | bisect: good |
|
2450 | 2450 | phase: public |
|
2451 | 2451 | parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2452 | 2452 | parent: -1:0000000000000000000000000000000000000000 |
|
2453 | 2453 | manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55 |
|
2454 | 2454 | user: A. N. Other <other@place> |
|
2455 | 2455 | date: Tue Jan 13 17:33:20 1970 +0000 |
|
2456 | 2456 | files+: b |
|
2457 | 2457 | extra: branch=default |
|
2458 | 2458 | description: |
|
2459 | 2459 | other 1 |
|
2460 | 2460 | other 2 |
|
2461 | 2461 | |
|
2462 | 2462 | other 3 |
|
2463 | 2463 | |
|
2464 | 2464 | |
|
2465 | 2465 | changeset: 2:97054abb4ab824450e9164180baf491ae0078465 |
|
2466 | 2466 | bisect: untested |
|
2467 | 2467 | phase: public |
|
2468 | 2468 | parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2469 | 2469 | parent: -1:0000000000000000000000000000000000000000 |
|
2470 | 2470 | manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1 |
|
2471 | 2471 | user: other@place |
|
2472 | 2472 | date: Wed Jan 14 21:20:00 1970 +0000 |
|
2473 | 2473 | files+: c |
|
2474 | 2474 | extra: branch=default |
|
2475 | 2475 | description: |
|
2476 | 2476 | no person |
|
2477 | 2477 | |
|
2478 | 2478 | |
|
2479 | 2479 | changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2480 | 2480 | bisect: bad |
|
2481 | 2481 | phase: public |
|
2482 | 2482 | parent: 2:97054abb4ab824450e9164180baf491ae0078465 |
|
2483 | 2483 | parent: -1:0000000000000000000000000000000000000000 |
|
2484 | 2484 | manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
2485 | 2485 | user: person |
|
2486 | 2486 | date: Fri Jan 16 01:06:40 1970 +0000 |
|
2487 | 2487 | files: c |
|
2488 | 2488 | extra: branch=default |
|
2489 | 2489 | description: |
|
2490 | 2490 | no user, no domain |
|
2491 | 2491 | |
|
2492 | 2492 | |
|
2493 | 2493 | changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2494 | 2494 | bisect: bad (implicit) |
|
2495 | 2495 | branch: foo |
|
2496 | 2496 | phase: draft |
|
2497 | 2497 | parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2498 | 2498 | parent: -1:0000000000000000000000000000000000000000 |
|
2499 | 2499 | manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
2500 | 2500 | user: person |
|
2501 | 2501 | date: Sat Jan 17 04:53:20 1970 +0000 |
|
2502 | 2502 | extra: branch=foo |
|
2503 | 2503 | description: |
|
2504 | 2504 | new branch |
|
2505 | 2505 | |
|
2506 | 2506 | |
|
2507 | 2507 | $ hg log -v -T bisect -r 0:4 |
|
2508 | 2508 | changeset: 0:1e4e1b8f71e0 |
|
2509 | 2509 | bisect: good (implicit) |
|
2510 | 2510 | user: User Name <user@hostname> |
|
2511 | 2511 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
2512 | 2512 | files: a |
|
2513 | 2513 | description: |
|
2514 | 2514 | line 1 |
|
2515 | 2515 | line 2 |
|
2516 | 2516 | |
|
2517 | 2517 | |
|
2518 | 2518 | changeset: 1:b608e9d1a3f0 |
|
2519 | 2519 | bisect: good |
|
2520 | 2520 | user: A. N. Other <other@place> |
|
2521 | 2521 | date: Tue Jan 13 17:33:20 1970 +0000 |
|
2522 | 2522 | files: b |
|
2523 | 2523 | description: |
|
2524 | 2524 | other 1 |
|
2525 | 2525 | other 2 |
|
2526 | 2526 | |
|
2527 | 2527 | other 3 |
|
2528 | 2528 | |
|
2529 | 2529 | |
|
2530 | 2530 | changeset: 2:97054abb4ab8 |
|
2531 | 2531 | bisect: untested |
|
2532 | 2532 | user: other@place |
|
2533 | 2533 | date: Wed Jan 14 21:20:00 1970 +0000 |
|
2534 | 2534 | files: c |
|
2535 | 2535 | description: |
|
2536 | 2536 | no person |
|
2537 | 2537 | |
|
2538 | 2538 | |
|
2539 | 2539 | changeset: 3:10e46f2dcbf4 |
|
2540 | 2540 | bisect: bad |
|
2541 | 2541 | user: person |
|
2542 | 2542 | date: Fri Jan 16 01:06:40 1970 +0000 |
|
2543 | 2543 | files: c |
|
2544 | 2544 | description: |
|
2545 | 2545 | no user, no domain |
|
2546 | 2546 | |
|
2547 | 2547 | |
|
2548 | 2548 | changeset: 4:bbe44766e73d |
|
2549 | 2549 | bisect: bad (implicit) |
|
2550 | 2550 | branch: foo |
|
2551 | 2551 | user: person |
|
2552 | 2552 | date: Sat Jan 17 04:53:20 1970 +0000 |
|
2553 | 2553 | description: |
|
2554 | 2554 | new branch |
|
2555 | 2555 | |
|
2556 | 2556 | |
|
2557 | 2557 | $ hg --color=debug log -T bisect -r 0:4 |
|
2558 | 2558 | [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0] |
|
2559 | 2559 | [log.bisect bisect.good|bisect: good (implicit)] |
|
2560 | 2560 | [log.user|user: User Name <user@hostname>] |
|
2561 | 2561 | [log.date|date: Mon Jan 12 13:46:40 1970 +0000] |
|
2562 | 2562 | [log.summary|summary: line 1] |
|
2563 | 2563 | |
|
2564 | 2564 | [log.changeset changeset.public|changeset: 1:b608e9d1a3f0] |
|
2565 | 2565 | [log.bisect bisect.good|bisect: good] |
|
2566 | 2566 | [log.user|user: A. N. Other <other@place>] |
|
2567 | 2567 | [log.date|date: Tue Jan 13 17:33:20 1970 +0000] |
|
2568 | 2568 | [log.summary|summary: other 1] |
|
2569 | 2569 | |
|
2570 | 2570 | [log.changeset changeset.public|changeset: 2:97054abb4ab8] |
|
2571 | 2571 | [log.bisect bisect.untested|bisect: untested] |
|
2572 | 2572 | [log.user|user: other@place] |
|
2573 | 2573 | [log.date|date: Wed Jan 14 21:20:00 1970 +0000] |
|
2574 | 2574 | [log.summary|summary: no person] |
|
2575 | 2575 | |
|
2576 | 2576 | [log.changeset changeset.public|changeset: 3:10e46f2dcbf4] |
|
2577 | 2577 | [log.bisect bisect.bad|bisect: bad] |
|
2578 | 2578 | [log.user|user: person] |
|
2579 | 2579 | [log.date|date: Fri Jan 16 01:06:40 1970 +0000] |
|
2580 | 2580 | [log.summary|summary: no user, no domain] |
|
2581 | 2581 | |
|
2582 | 2582 | [log.changeset changeset.draft|changeset: 4:bbe44766e73d] |
|
2583 | 2583 | [log.bisect bisect.bad|bisect: bad (implicit)] |
|
2584 | 2584 | [log.branch|branch: foo] |
|
2585 | 2585 | [log.user|user: person] |
|
2586 | 2586 | [log.date|date: Sat Jan 17 04:53:20 1970 +0000] |
|
2587 | 2587 | [log.summary|summary: new branch] |
|
2588 | 2588 | |
|
2589 | 2589 | $ hg --color=debug log --debug -T bisect -r 0:4 |
|
2590 | 2590 | [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f] |
|
2591 | 2591 | [log.bisect bisect.good|bisect: good (implicit)] |
|
2592 | 2592 | [log.phase|phase: public] |
|
2593 | 2593 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2594 | 2594 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2595 | 2595 | [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0] |
|
2596 | 2596 | [log.user|user: User Name <user@hostname>] |
|
2597 | 2597 | [log.date|date: Mon Jan 12 13:46:40 1970 +0000] |
|
2598 | 2598 | [ui.debug log.files|files+: a] |
|
2599 | 2599 | [ui.debug log.extra|extra: branch=default] |
|
2600 | 2600 | [ui.note log.description|description:] |
|
2601 | 2601 | [ui.note log.description|line 1 |
|
2602 | 2602 | line 2] |
|
2603 | 2603 | |
|
2604 | 2604 | |
|
2605 | 2605 | [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965] |
|
2606 | 2606 | [log.bisect bisect.good|bisect: good] |
|
2607 | 2607 | [log.phase|phase: public] |
|
2608 | 2608 | [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f] |
|
2609 | 2609 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2610 | 2610 | [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55] |
|
2611 | 2611 | [log.user|user: A. N. Other <other@place>] |
|
2612 | 2612 | [log.date|date: Tue Jan 13 17:33:20 1970 +0000] |
|
2613 | 2613 | [ui.debug log.files|files+: b] |
|
2614 | 2614 | [ui.debug log.extra|extra: branch=default] |
|
2615 | 2615 | [ui.note log.description|description:] |
|
2616 | 2616 | [ui.note log.description|other 1 |
|
2617 | 2617 | other 2 |
|
2618 | 2618 | |
|
2619 | 2619 | other 3] |
|
2620 | 2620 | |
|
2621 | 2621 | |
|
2622 | 2622 | [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465] |
|
2623 | 2623 | [log.bisect bisect.untested|bisect: untested] |
|
2624 | 2624 | [log.phase|phase: public] |
|
2625 | 2625 | [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965] |
|
2626 | 2626 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2627 | 2627 | [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1] |
|
2628 | 2628 | [log.user|user: other@place] |
|
2629 | 2629 | [log.date|date: Wed Jan 14 21:20:00 1970 +0000] |
|
2630 | 2630 | [ui.debug log.files|files+: c] |
|
2631 | 2631 | [ui.debug log.extra|extra: branch=default] |
|
2632 | 2632 | [ui.note log.description|description:] |
|
2633 | 2633 | [ui.note log.description|no person] |
|
2634 | 2634 | |
|
2635 | 2635 | |
|
2636 | 2636 | [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47] |
|
2637 | 2637 | [log.bisect bisect.bad|bisect: bad] |
|
2638 | 2638 | [log.phase|phase: public] |
|
2639 | 2639 | [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465] |
|
2640 | 2640 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2641 | 2641 | [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc] |
|
2642 | 2642 | [log.user|user: person] |
|
2643 | 2643 | [log.date|date: Fri Jan 16 01:06:40 1970 +0000] |
|
2644 | 2644 | [ui.debug log.files|files: c] |
|
2645 | 2645 | [ui.debug log.extra|extra: branch=default] |
|
2646 | 2646 | [ui.note log.description|description:] |
|
2647 | 2647 | [ui.note log.description|no user, no domain] |
|
2648 | 2648 | |
|
2649 | 2649 | |
|
2650 | 2650 | [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74] |
|
2651 | 2651 | [log.bisect bisect.bad|bisect: bad (implicit)] |
|
2652 | 2652 | [log.branch|branch: foo] |
|
2653 | 2653 | [log.phase|phase: draft] |
|
2654 | 2654 | [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47] |
|
2655 | 2655 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2656 | 2656 | [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc] |
|
2657 | 2657 | [log.user|user: person] |
|
2658 | 2658 | [log.date|date: Sat Jan 17 04:53:20 1970 +0000] |
|
2659 | 2659 | [ui.debug log.extra|extra: branch=foo] |
|
2660 | 2660 | [ui.note log.description|description:] |
|
2661 | 2661 | [ui.note log.description|new branch] |
|
2662 | 2662 | |
|
2663 | 2663 | |
|
2664 | 2664 | $ hg --color=debug log -v -T bisect -r 0:4 |
|
2665 | 2665 | [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0] |
|
2666 | 2666 | [log.bisect bisect.good|bisect: good (implicit)] |
|
2667 | 2667 | [log.user|user: User Name <user@hostname>] |
|
2668 | 2668 | [log.date|date: Mon Jan 12 13:46:40 1970 +0000] |
|
2669 | 2669 | [ui.note log.files|files: a] |
|
2670 | 2670 | [ui.note log.description|description:] |
|
2671 | 2671 | [ui.note log.description|line 1 |
|
2672 | 2672 | line 2] |
|
2673 | 2673 | |
|
2674 | 2674 | |
|
2675 | 2675 | [log.changeset changeset.public|changeset: 1:b608e9d1a3f0] |
|
2676 | 2676 | [log.bisect bisect.good|bisect: good] |
|
2677 | 2677 | [log.user|user: A. N. Other <other@place>] |
|
2678 | 2678 | [log.date|date: Tue Jan 13 17:33:20 1970 +0000] |
|
2679 | 2679 | [ui.note log.files|files: b] |
|
2680 | 2680 | [ui.note log.description|description:] |
|
2681 | 2681 | [ui.note log.description|other 1 |
|
2682 | 2682 | other 2 |
|
2683 | 2683 | |
|
2684 | 2684 | other 3] |
|
2685 | 2685 | |
|
2686 | 2686 | |
|
2687 | 2687 | [log.changeset changeset.public|changeset: 2:97054abb4ab8] |
|
2688 | 2688 | [log.bisect bisect.untested|bisect: untested] |
|
2689 | 2689 | [log.user|user: other@place] |
|
2690 | 2690 | [log.date|date: Wed Jan 14 21:20:00 1970 +0000] |
|
2691 | 2691 | [ui.note log.files|files: c] |
|
2692 | 2692 | [ui.note log.description|description:] |
|
2693 | 2693 | [ui.note log.description|no person] |
|
2694 | 2694 | |
|
2695 | 2695 | |
|
2696 | 2696 | [log.changeset changeset.public|changeset: 3:10e46f2dcbf4] |
|
2697 | 2697 | [log.bisect bisect.bad|bisect: bad] |
|
2698 | 2698 | [log.user|user: person] |
|
2699 | 2699 | [log.date|date: Fri Jan 16 01:06:40 1970 +0000] |
|
2700 | 2700 | [ui.note log.files|files: c] |
|
2701 | 2701 | [ui.note log.description|description:] |
|
2702 | 2702 | [ui.note log.description|no user, no domain] |
|
2703 | 2703 | |
|
2704 | 2704 | |
|
2705 | 2705 | [log.changeset changeset.draft|changeset: 4:bbe44766e73d] |
|
2706 | 2706 | [log.bisect bisect.bad|bisect: bad (implicit)] |
|
2707 | 2707 | [log.branch|branch: foo] |
|
2708 | 2708 | [log.user|user: person] |
|
2709 | 2709 | [log.date|date: Sat Jan 17 04:53:20 1970 +0000] |
|
2710 | 2710 | [ui.note log.description|description:] |
|
2711 | 2711 | [ui.note log.description|new branch] |
|
2712 | 2712 | |
|
2713 | 2713 | |
|
2714 | 2714 | $ hg bisect --reset |
|
2715 | 2715 | |
|
2716 | 2716 | Error on syntax: |
|
2717 | 2717 | |
|
2718 | 2718 | $ echo 'x = "f' >> t |
|
2719 | 2719 | $ hg log |
|
2720 | 2720 | hg: parse error at t:3: unmatched quotes |
|
2721 | 2721 | [255] |
|
2722 | 2722 | |
|
2723 | 2723 | $ hg log -T '{date' |
|
2724 | 2724 | hg: parse error at 1: unterminated template expansion |
|
2725 | 2725 | [255] |
|
2726 | 2726 | |
|
2727 | 2727 | Behind the scenes, this will throw TypeError |
|
2728 | 2728 | |
|
2729 | 2729 | $ hg log -l 3 --template '{date|obfuscate}\n' |
|
2730 | 2730 | abort: template filter 'obfuscate' is not compatible with keyword 'date' |
|
2731 | 2731 | [255] |
|
2732 | 2732 | |
|
2733 | 2733 | Behind the scenes, this will throw a ValueError |
|
2734 | 2734 | |
|
2735 | 2735 | $ hg log -l 3 --template 'line: {desc|shortdate}\n' |
|
2736 | 2736 | abort: template filter 'shortdate' is not compatible with keyword 'desc' |
|
2737 | 2737 | [255] |
|
2738 | 2738 | |
|
2739 | 2739 | Behind the scenes, this will throw AttributeError |
|
2740 | 2740 | |
|
2741 | 2741 | $ hg log -l 3 --template 'line: {date|escape}\n' |
|
2742 | 2742 | abort: template filter 'escape' is not compatible with keyword 'date' |
|
2743 | 2743 | [255] |
|
2744 | 2744 | |
|
2745 | 2745 | $ hg log -l 3 --template 'line: {extras|localdate}\n' |
|
2746 | 2746 | hg: parse error: localdate expects a date information |
|
2747 | 2747 | [255] |
|
2748 | 2748 | |
|
2749 | 2749 | Behind the scenes, this will throw ValueError |
|
2750 | 2750 | |
|
2751 | 2751 | $ hg tip --template '{author|email|date}\n' |
|
2752 | 2752 | hg: parse error: date expects a date information |
|
2753 | 2753 | [255] |
|
2754 | 2754 | |
|
2755 | 2755 | $ hg tip -T '{author|email|shortdate}\n' |
|
2756 | 2756 | abort: template filter 'shortdate' is not compatible with keyword 'author' |
|
2757 | 2757 | [255] |
|
2758 | 2758 | |
|
2759 | 2759 | $ hg tip -T '{get(extras, "branch")|shortdate}\n' |
|
2760 | 2760 | abort: incompatible use of template filter 'shortdate' |
|
2761 | 2761 | [255] |
|
2762 | 2762 | |
|
2763 | 2763 | Error in nested template: |
|
2764 | 2764 | |
|
2765 | 2765 | $ hg log -T '{"date' |
|
2766 | 2766 | hg: parse error at 2: unterminated string |
|
2767 | 2767 | [255] |
|
2768 | 2768 | |
|
2769 | 2769 | $ hg log -T '{"foo{date|?}"}' |
|
2770 | 2770 | hg: parse error at 11: syntax error |
|
2771 | 2771 | [255] |
|
2772 | 2772 | |
|
2773 | 2773 | Thrown an error if a template function doesn't exist |
|
2774 | 2774 | |
|
2775 | 2775 | $ hg tip --template '{foo()}\n' |
|
2776 | 2776 | hg: parse error: unknown function 'foo' |
|
2777 | 2777 | [255] |
|
2778 | 2778 | |
|
2779 | 2779 | Pass generator object created by template function to filter |
|
2780 | 2780 | |
|
2781 | 2781 | $ hg log -l 1 --template '{if(author, author)|user}\n' |
|
2782 | 2782 | test |
|
2783 | 2783 | |
|
2784 | 2784 | Test index keyword: |
|
2785 | 2785 | |
|
2786 | 2786 | $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n' |
|
2787 | 2787 | 10 0:a 1:b 2:fifth 3:fourth 4:third |
|
2788 | 2788 | 11 0:a |
|
2789 | 2789 | |
|
2790 | 2790 | $ hg branches -T '{index} {branch}\n' |
|
2791 | 2791 | 0 default |
|
2792 | 2792 | 1 foo |
|
2793 | 2793 | |
|
2794 | 2794 | Test diff function: |
|
2795 | 2795 | |
|
2796 | 2796 | $ hg diff -c 8 |
|
2797 | 2797 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2798 | 2798 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2799 | 2799 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2800 | 2800 | @@ -0,0 +1,1 @@ |
|
2801 | 2801 | +second |
|
2802 | 2802 | diff -r 29114dbae42b -r 95c24699272e second |
|
2803 | 2803 | --- a/second Mon Jan 12 13:46:40 1970 +0000 |
|
2804 | 2804 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2805 | 2805 | @@ -1,1 +0,0 @@ |
|
2806 | 2806 | -second |
|
2807 | 2807 | diff -r 29114dbae42b -r 95c24699272e third |
|
2808 | 2808 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2809 | 2809 | +++ b/third Wed Jan 01 10:01:00 2020 +0000 |
|
2810 | 2810 | @@ -0,0 +1,1 @@ |
|
2811 | 2811 | +third |
|
2812 | 2812 | |
|
2813 | 2813 | $ hg log -r 8 -T "{diff()}" |
|
2814 | 2814 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2815 | 2815 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2816 | 2816 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2817 | 2817 | @@ -0,0 +1,1 @@ |
|
2818 | 2818 | +second |
|
2819 | 2819 | diff -r 29114dbae42b -r 95c24699272e second |
|
2820 | 2820 | --- a/second Mon Jan 12 13:46:40 1970 +0000 |
|
2821 | 2821 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2822 | 2822 | @@ -1,1 +0,0 @@ |
|
2823 | 2823 | -second |
|
2824 | 2824 | diff -r 29114dbae42b -r 95c24699272e third |
|
2825 | 2825 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2826 | 2826 | +++ b/third Wed Jan 01 10:01:00 2020 +0000 |
|
2827 | 2827 | @@ -0,0 +1,1 @@ |
|
2828 | 2828 | +third |
|
2829 | 2829 | |
|
2830 | 2830 | $ hg log -r 8 -T "{diff('glob:f*')}" |
|
2831 | 2831 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2832 | 2832 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2833 | 2833 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2834 | 2834 | @@ -0,0 +1,1 @@ |
|
2835 | 2835 | +second |
|
2836 | 2836 | |
|
2837 | 2837 | $ hg log -r 8 -T "{diff('', 'glob:f*')}" |
|
2838 | 2838 | diff -r 29114dbae42b -r 95c24699272e second |
|
2839 | 2839 | --- a/second Mon Jan 12 13:46:40 1970 +0000 |
|
2840 | 2840 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2841 | 2841 | @@ -1,1 +0,0 @@ |
|
2842 | 2842 | -second |
|
2843 | 2843 | diff -r 29114dbae42b -r 95c24699272e third |
|
2844 | 2844 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2845 | 2845 | +++ b/third Wed Jan 01 10:01:00 2020 +0000 |
|
2846 | 2846 | @@ -0,0 +1,1 @@ |
|
2847 | 2847 | +third |
|
2848 | 2848 | |
|
2849 | 2849 | $ hg log -r 8 -T "{diff('FOURTH'|lower)}" |
|
2850 | 2850 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2851 | 2851 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2852 | 2852 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2853 | 2853 | @@ -0,0 +1,1 @@ |
|
2854 | 2854 | +second |
|
2855 | 2855 | |
|
2856 | 2856 | $ cd .. |
|
2857 | 2857 | |
|
2858 | 2858 | |
|
2859 | 2859 | latesttag: |
|
2860 | 2860 | |
|
2861 | 2861 | $ hg init latesttag |
|
2862 | 2862 | $ cd latesttag |
|
2863 | 2863 | |
|
2864 | 2864 | $ echo a > file |
|
2865 | 2865 | $ hg ci -Am a -d '0 0' |
|
2866 | 2866 | adding file |
|
2867 | 2867 | |
|
2868 | 2868 | $ echo b >> file |
|
2869 | 2869 | $ hg ci -m b -d '1 0' |
|
2870 | 2870 | |
|
2871 | 2871 | $ echo c >> head1 |
|
2872 | 2872 | $ hg ci -Am h1c -d '2 0' |
|
2873 | 2873 | adding head1 |
|
2874 | 2874 | |
|
2875 | 2875 | $ hg update -q 1 |
|
2876 | 2876 | $ echo d >> head2 |
|
2877 | 2877 | $ hg ci -Am h2d -d '3 0' |
|
2878 | 2878 | adding head2 |
|
2879 | 2879 | created new head |
|
2880 | 2880 | |
|
2881 | 2881 | $ echo e >> head2 |
|
2882 | 2882 | $ hg ci -m h2e -d '4 0' |
|
2883 | 2883 | |
|
2884 | 2884 | $ hg merge -q |
|
2885 | 2885 | $ hg ci -m merge -d '5 -3600' |
|
2886 | 2886 | |
|
2887 | 2887 | No tag set: |
|
2888 | 2888 | |
|
2889 | 2889 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
2890 | 2890 | @ 5: null+5 |
|
2891 | 2891 | |\ |
|
2892 | 2892 | | o 4: null+4 |
|
2893 | 2893 | | | |
|
2894 | 2894 | | o 3: null+3 |
|
2895 | 2895 | | | |
|
2896 | 2896 | o | 2: null+3 |
|
2897 | 2897 | |/ |
|
2898 | 2898 | o 1: null+2 |
|
2899 | 2899 | | |
|
2900 | 2900 | o 0: null+1 |
|
2901 | 2901 | |
|
2902 | 2902 | |
|
2903 | 2903 | One common tag: longest path wins for {latesttagdistance}: |
|
2904 | 2904 | |
|
2905 | 2905 | $ hg tag -r 1 -m t1 -d '6 0' t1 |
|
2906 | 2906 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
2907 | 2907 | @ 6: t1+4 |
|
2908 | 2908 | | |
|
2909 | 2909 | o 5: t1+3 |
|
2910 | 2910 | |\ |
|
2911 | 2911 | | o 4: t1+2 |
|
2912 | 2912 | | | |
|
2913 | 2913 | | o 3: t1+1 |
|
2914 | 2914 | | | |
|
2915 | 2915 | o | 2: t1+1 |
|
2916 | 2916 | |/ |
|
2917 | 2917 | o 1: t1+0 |
|
2918 | 2918 | | |
|
2919 | 2919 | o 0: null+1 |
|
2920 | 2920 | |
|
2921 | 2921 | |
|
2922 | 2922 | One ancestor tag: closest wins: |
|
2923 | 2923 | |
|
2924 | 2924 | $ hg tag -r 2 -m t2 -d '7 0' t2 |
|
2925 | 2925 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
2926 | 2926 | @ 7: t2+3 |
|
2927 | 2927 | | |
|
2928 | 2928 | o 6: t2+2 |
|
2929 | 2929 | | |
|
2930 | 2930 | o 5: t2+1 |
|
2931 | 2931 | |\ |
|
2932 | 2932 | | o 4: t1+2 |
|
2933 | 2933 | | | |
|
2934 | 2934 | | o 3: t1+1 |
|
2935 | 2935 | | | |
|
2936 | 2936 | o | 2: t2+0 |
|
2937 | 2937 | |/ |
|
2938 | 2938 | o 1: t1+0 |
|
2939 | 2939 | | |
|
2940 | 2940 | o 0: null+1 |
|
2941 | 2941 | |
|
2942 | 2942 | |
|
2943 | 2943 | Two branch tags: more recent wins if same number of changes: |
|
2944 | 2944 | |
|
2945 | 2945 | $ hg tag -r 3 -m t3 -d '8 0' t3 |
|
2946 | 2946 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
2947 | 2947 | @ 8: t3+5 |
|
2948 | 2948 | | |
|
2949 | 2949 | o 7: t3+4 |
|
2950 | 2950 | | |
|
2951 | 2951 | o 6: t3+3 |
|
2952 | 2952 | | |
|
2953 | 2953 | o 5: t3+2 |
|
2954 | 2954 | |\ |
|
2955 | 2955 | | o 4: t3+1 |
|
2956 | 2956 | | | |
|
2957 | 2957 | | o 3: t3+0 |
|
2958 | 2958 | | | |
|
2959 | 2959 | o | 2: t2+0 |
|
2960 | 2960 | |/ |
|
2961 | 2961 | o 1: t1+0 |
|
2962 | 2962 | | |
|
2963 | 2963 | o 0: null+1 |
|
2964 | 2964 | |
|
2965 | 2965 | |
|
2966 | 2966 | Two branch tags: fewest changes wins: |
|
2967 | 2967 | |
|
2968 | 2968 | $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter |
|
2969 | 2969 | $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n" |
|
2970 | 2970 | @ 9: t4+5,6 |
|
2971 | 2971 | | |
|
2972 | 2972 | o 8: t4+4,5 |
|
2973 | 2973 | | |
|
2974 | 2974 | o 7: t4+3,4 |
|
2975 | 2975 | | |
|
2976 | 2976 | o 6: t4+2,3 |
|
2977 | 2977 | | |
|
2978 | 2978 | o 5: t4+1,2 |
|
2979 | 2979 | |\ |
|
2980 | 2980 | | o 4: t4+0,0 |
|
2981 | 2981 | | | |
|
2982 | 2982 | | o 3: t3+0,0 |
|
2983 | 2983 | | | |
|
2984 | 2984 | o | 2: t2+0,0 |
|
2985 | 2985 | |/ |
|
2986 | 2986 | o 1: t1+0,0 |
|
2987 | 2987 | | |
|
2988 | 2988 | o 0: null+1,1 |
|
2989 | 2989 | |
|
2990 | 2990 | |
|
2991 | 2991 | Merged tag overrides: |
|
2992 | 2992 | |
|
2993 | 2993 | $ hg tag -r 5 -m t5 -d '9 0' t5 |
|
2994 | 2994 | $ hg tag -r 3 -m at3 -d '10 0' at3 |
|
2995 | 2995 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
2996 | 2996 | @ 11: t5+6 |
|
2997 | 2997 | | |
|
2998 | 2998 | o 10: t5+5 |
|
2999 | 2999 | | |
|
3000 | 3000 | o 9: t5+4 |
|
3001 | 3001 | | |
|
3002 | 3002 | o 8: t5+3 |
|
3003 | 3003 | | |
|
3004 | 3004 | o 7: t5+2 |
|
3005 | 3005 | | |
|
3006 | 3006 | o 6: t5+1 |
|
3007 | 3007 | | |
|
3008 | 3008 | o 5: t5+0 |
|
3009 | 3009 | |\ |
|
3010 | 3010 | | o 4: t4+0 |
|
3011 | 3011 | | | |
|
3012 | 3012 | | o 3: at3:t3+0 |
|
3013 | 3013 | | | |
|
3014 | 3014 | o | 2: t2+0 |
|
3015 | 3015 | |/ |
|
3016 | 3016 | o 1: t1+0 |
|
3017 | 3017 | | |
|
3018 | 3018 | o 0: null+1 |
|
3019 | 3019 | |
|
3020 | 3020 | |
|
3021 | 3021 | $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n" |
|
3022 | 3022 | @ 11: t5+6,6 |
|
3023 | 3023 | | |
|
3024 | 3024 | o 10: t5+5,5 |
|
3025 | 3025 | | |
|
3026 | 3026 | o 9: t5+4,4 |
|
3027 | 3027 | | |
|
3028 | 3028 | o 8: t5+3,3 |
|
3029 | 3029 | | |
|
3030 | 3030 | o 7: t5+2,2 |
|
3031 | 3031 | | |
|
3032 | 3032 | o 6: t5+1,1 |
|
3033 | 3033 | | |
|
3034 | 3034 | o 5: t5+0,0 |
|
3035 | 3035 | |\ |
|
3036 | 3036 | | o 4: t4+0,0 |
|
3037 | 3037 | | | |
|
3038 | 3038 | | o 3: at3+0,0 t3+0,0 |
|
3039 | 3039 | | | |
|
3040 | 3040 | o | 2: t2+0,0 |
|
3041 | 3041 | |/ |
|
3042 | 3042 | o 1: t1+0,0 |
|
3043 | 3043 | | |
|
3044 | 3044 | o 0: null+1,1 |
|
3045 | 3045 | |
|
3046 | 3046 | |
|
3047 | 3047 | $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n" |
|
3048 | 3048 | @ 11: t3, C: 9, D: 8 |
|
3049 | 3049 | | |
|
3050 | 3050 | o 10: t3, C: 8, D: 7 |
|
3051 | 3051 | | |
|
3052 | 3052 | o 9: t3, C: 7, D: 6 |
|
3053 | 3053 | | |
|
3054 | 3054 | o 8: t3, C: 6, D: 5 |
|
3055 | 3055 | | |
|
3056 | 3056 | o 7: t3, C: 5, D: 4 |
|
3057 | 3057 | | |
|
3058 | 3058 | o 6: t3, C: 4, D: 3 |
|
3059 | 3059 | | |
|
3060 | 3060 | o 5: t3, C: 3, D: 2 |
|
3061 | 3061 | |\ |
|
3062 | 3062 | | o 4: t3, C: 1, D: 1 |
|
3063 | 3063 | | | |
|
3064 | 3064 | | o 3: t3, C: 0, D: 0 |
|
3065 | 3065 | | | |
|
3066 | 3066 | o | 2: t1, C: 1, D: 1 |
|
3067 | 3067 | |/ |
|
3068 | 3068 | o 1: t1, C: 0, D: 0 |
|
3069 | 3069 | | |
|
3070 | 3070 | o 0: null, C: 1, D: 1 |
|
3071 | 3071 | |
|
3072 | 3072 | |
|
3073 | 3073 | $ cd .. |
|
3074 | 3074 | |
|
3075 | 3075 | |
|
3076 | 3076 | Style path expansion: issue1948 - ui.style option doesn't work on OSX |
|
3077 | 3077 | if it is a relative path |
|
3078 | 3078 | |
|
3079 | 3079 | $ mkdir -p home/styles |
|
3080 | 3080 | |
|
3081 | 3081 | $ cat > home/styles/teststyle <<EOF |
|
3082 | 3082 | > changeset = 'test {rev}:{node|short}\n' |
|
3083 | 3083 | > EOF |
|
3084 | 3084 | |
|
3085 | 3085 | $ HOME=`pwd`/home; export HOME |
|
3086 | 3086 | |
|
3087 | 3087 | $ cat > latesttag/.hg/hgrc <<EOF |
|
3088 | 3088 | > [ui] |
|
3089 | 3089 | > style = ~/styles/teststyle |
|
3090 | 3090 | > EOF |
|
3091 | 3091 | |
|
3092 | 3092 | $ hg -R latesttag tip |
|
3093 | 3093 | test 11:97e5943b523a |
|
3094 | 3094 | |
|
3095 | 3095 | Test recursive showlist template (issue1989): |
|
3096 | 3096 | |
|
3097 | 3097 | $ cat > style1989 <<EOF |
|
3098 | 3098 | > changeset = '{file_mods}{manifest}{extras}' |
|
3099 | 3099 | > file_mod = 'M|{author|person}\n' |
|
3100 | 3100 | > manifest = '{rev},{author}\n' |
|
3101 | 3101 | > extra = '{key}: {author}\n' |
|
3102 | 3102 | > EOF |
|
3103 | 3103 | |
|
3104 | 3104 | $ hg -R latesttag log -r tip --style=style1989 |
|
3105 | 3105 | M|test |
|
3106 | 3106 | 11,test |
|
3107 | 3107 | branch: test |
|
3108 | 3108 | |
|
3109 | 3109 | Test new-style inline templating: |
|
3110 | 3110 | |
|
3111 | 3111 | $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n' |
|
3112 | 3112 | modified files: .hgtags |
|
3113 | 3113 | |
|
3114 | 3114 | |
|
3115 | 3115 | $ hg log -R latesttag -r tip -T '{rev % "a"}\n' |
|
3116 | 3116 | hg: parse error: keyword 'rev' is not iterable |
|
3117 | 3117 | [255] |
|
3118 | 3118 | $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n' |
|
3119 | 3119 | hg: parse error: None is not iterable |
|
3120 | 3120 | [255] |
|
3121 | 3121 | |
|
3122 | 3122 | Test new-style inline templating of non-list/dict type: |
|
3123 | 3123 | |
|
3124 | 3124 | $ hg log -R latesttag -r tip -T '{manifest}\n' |
|
3125 | 3125 | 11:2bc6e9006ce2 |
|
3126 | 3126 | $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n' |
|
3127 | 3127 | string length: 15 |
|
3128 | 3128 | $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n' |
|
3129 | 3129 | 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc |
|
3130 | 3130 | |
|
3131 | 3131 | $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}' |
|
3132 | 3132 | branch: default |
|
3133 | 3133 | $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}' |
|
3134 | 3134 | hg: parse error: None is not iterable |
|
3135 | 3135 | [255] |
|
3136 | 3136 | $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}' |
|
3137 | 3137 | branch: default |
|
3138 | 3138 | $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}' |
|
3139 | 3139 | 0:ce3cec86e6c2 |
|
3140 | 3140 | $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}' |
|
3141 | 3141 | 9:fbc7cd862e9c |
|
3142 | 3142 | |
|
3143 | 3143 | Test manifest/get() can be join()-ed as before, though it's silly: |
|
3144 | 3144 | |
|
3145 | 3145 | $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n' |
|
3146 | 3146 | 11:2bc6e9006ce2 |
|
3147 | 3147 | $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n' |
|
3148 | 3148 | default |
|
3149 | 3149 | |
|
3150 | 3150 | Test dot operator precedence: |
|
3151 | 3151 | |
|
3152 | 3152 | $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n' |
|
3153 | 3153 | (template |
|
3154 | 3154 | (| |
|
3155 | 3155 | (. |
|
3156 | 3156 | (symbol 'manifest') |
|
3157 | 3157 | (symbol 'node')) |
|
3158 | 3158 | (symbol 'short')) |
|
3159 | 3159 | (string '\n')) |
|
3160 | 3160 | 89f4071fec70 |
|
3161 | 3161 | |
|
3162 | 3162 | (the following examples are invalid, but seem natural in parsing POV) |
|
3163 | 3163 | |
|
3164 | 3164 | $ hg debugtemplate -R latesttag -r0 -v '{foo|bar.baz}\n' 2> /dev/null |
|
3165 | 3165 | (template |
|
3166 | 3166 | (| |
|
3167 | 3167 | (symbol 'foo') |
|
3168 | 3168 | (. |
|
3169 | 3169 | (symbol 'bar') |
|
3170 | 3170 | (symbol 'baz'))) |
|
3171 | 3171 | (string '\n')) |
|
3172 | 3172 | [255] |
|
3173 | 3173 | $ hg debugtemplate -R latesttag -r0 -v '{foo.bar()}\n' 2> /dev/null |
|
3174 | 3174 | (template |
|
3175 | 3175 | (. |
|
3176 | 3176 | (symbol 'foo') |
|
3177 | 3177 | (func |
|
3178 | 3178 | (symbol 'bar') |
|
3179 | 3179 | None)) |
|
3180 | 3180 | (string '\n')) |
|
3181 | 3181 | [255] |
|
3182 | 3182 | |
|
3183 | 3183 | Test evaluation of dot operator: |
|
3184 | 3184 | |
|
3185 | 3185 | $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n' |
|
3186 | 3186 | ce3cec86e6c26bd9bdfc590a6b92abc9680f1796 |
|
3187 | $ hg log -R latesttag -r0 -T '{extras.branch}\n' | |
|
3188 | default | |
|
3187 | 3189 | |
|
3188 | 3190 | $ hg log -R latesttag -l1 -T '{author.invalid}\n' |
|
3189 | 3191 | hg: parse error: keyword 'author' has no member |
|
3190 | 3192 | [255] |
|
3191 | 3193 | $ hg log -R latesttag -l1 -T '{min("abc").invalid}\n' |
|
3192 | 3194 | hg: parse error: 'a' has no member |
|
3193 | 3195 | [255] |
|
3194 | 3196 | |
|
3195 | 3197 | Test the sub function of templating for expansion: |
|
3196 | 3198 | |
|
3197 | 3199 | $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n' |
|
3198 | 3200 | xx |
|
3199 | 3201 | |
|
3200 | 3202 | $ hg log -R latesttag -r 10 -T '{sub("[", "x", rev)}\n' |
|
3201 | 3203 | hg: parse error: sub got an invalid pattern: [ |
|
3202 | 3204 | [255] |
|
3203 | 3205 | $ hg log -R latesttag -r 10 -T '{sub("[0-9]", r"\1", rev)}\n' |
|
3204 | 3206 | hg: parse error: sub got an invalid replacement: \1 |
|
3205 | 3207 | [255] |
|
3206 | 3208 | |
|
3207 | 3209 | Test the strip function with chars specified: |
|
3208 | 3210 | |
|
3209 | 3211 | $ hg log -R latesttag --template '{desc}\n' |
|
3210 | 3212 | at3 |
|
3211 | 3213 | t5 |
|
3212 | 3214 | t4 |
|
3213 | 3215 | t3 |
|
3214 | 3216 | t2 |
|
3215 | 3217 | t1 |
|
3216 | 3218 | merge |
|
3217 | 3219 | h2e |
|
3218 | 3220 | h2d |
|
3219 | 3221 | h1c |
|
3220 | 3222 | b |
|
3221 | 3223 | a |
|
3222 | 3224 | |
|
3223 | 3225 | $ hg log -R latesttag --template '{strip(desc, "te")}\n' |
|
3224 | 3226 | at3 |
|
3225 | 3227 | 5 |
|
3226 | 3228 | 4 |
|
3227 | 3229 | 3 |
|
3228 | 3230 | 2 |
|
3229 | 3231 | 1 |
|
3230 | 3232 | merg |
|
3231 | 3233 | h2 |
|
3232 | 3234 | h2d |
|
3233 | 3235 | h1c |
|
3234 | 3236 | b |
|
3235 | 3237 | a |
|
3236 | 3238 | |
|
3237 | 3239 | Test date format: |
|
3238 | 3240 | |
|
3239 | 3241 | $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n' |
|
3240 | 3242 | date: 70 01 01 10 +0000 |
|
3241 | 3243 | date: 70 01 01 09 +0000 |
|
3242 | 3244 | date: 70 01 01 04 +0000 |
|
3243 | 3245 | date: 70 01 01 08 +0000 |
|
3244 | 3246 | date: 70 01 01 07 +0000 |
|
3245 | 3247 | date: 70 01 01 06 +0000 |
|
3246 | 3248 | date: 70 01 01 05 +0100 |
|
3247 | 3249 | date: 70 01 01 04 +0000 |
|
3248 | 3250 | date: 70 01 01 03 +0000 |
|
3249 | 3251 | date: 70 01 01 02 +0000 |
|
3250 | 3252 | date: 70 01 01 01 +0000 |
|
3251 | 3253 | date: 70 01 01 00 +0000 |
|
3252 | 3254 | |
|
3253 | 3255 | Test invalid date: |
|
3254 | 3256 | |
|
3255 | 3257 | $ hg log -R latesttag -T '{date(rev)}\n' |
|
3256 | 3258 | hg: parse error: date expects a date information |
|
3257 | 3259 | [255] |
|
3258 | 3260 | |
|
3259 | 3261 | Test integer literal: |
|
3260 | 3262 | |
|
3261 | 3263 | $ hg debugtemplate -v '{(0)}\n' |
|
3262 | 3264 | (template |
|
3263 | 3265 | (group |
|
3264 | 3266 | (integer '0')) |
|
3265 | 3267 | (string '\n')) |
|
3266 | 3268 | 0 |
|
3267 | 3269 | $ hg debugtemplate -v '{(123)}\n' |
|
3268 | 3270 | (template |
|
3269 | 3271 | (group |
|
3270 | 3272 | (integer '123')) |
|
3271 | 3273 | (string '\n')) |
|
3272 | 3274 | 123 |
|
3273 | 3275 | $ hg debugtemplate -v '{(-4)}\n' |
|
3274 | 3276 | (template |
|
3275 | 3277 | (group |
|
3276 | 3278 | (negate |
|
3277 | 3279 | (integer '4'))) |
|
3278 | 3280 | (string '\n')) |
|
3279 | 3281 | -4 |
|
3280 | 3282 | $ hg debugtemplate '{(-)}\n' |
|
3281 | 3283 | hg: parse error at 3: not a prefix: ) |
|
3282 | 3284 | [255] |
|
3283 | 3285 | $ hg debugtemplate '{(-a)}\n' |
|
3284 | 3286 | hg: parse error: negation needs an integer argument |
|
3285 | 3287 | [255] |
|
3286 | 3288 | |
|
3287 | 3289 | top-level integer literal is interpreted as symbol (i.e. variable name): |
|
3288 | 3290 | |
|
3289 | 3291 | $ hg debugtemplate -D 1=one -v '{1}\n' |
|
3290 | 3292 | (template |
|
3291 | 3293 | (integer '1') |
|
3292 | 3294 | (string '\n')) |
|
3293 | 3295 | one |
|
3294 | 3296 | $ hg debugtemplate -D 1=one -v '{if("t", "{1}")}\n' |
|
3295 | 3297 | (template |
|
3296 | 3298 | (func |
|
3297 | 3299 | (symbol 'if') |
|
3298 | 3300 | (list |
|
3299 | 3301 | (string 't') |
|
3300 | 3302 | (template |
|
3301 | 3303 | (integer '1')))) |
|
3302 | 3304 | (string '\n')) |
|
3303 | 3305 | one |
|
3304 | 3306 | $ hg debugtemplate -D 1=one -v '{1|stringify}\n' |
|
3305 | 3307 | (template |
|
3306 | 3308 | (| |
|
3307 | 3309 | (integer '1') |
|
3308 | 3310 | (symbol 'stringify')) |
|
3309 | 3311 | (string '\n')) |
|
3310 | 3312 | one |
|
3311 | 3313 | |
|
3312 | 3314 | unless explicit symbol is expected: |
|
3313 | 3315 | |
|
3314 | 3316 | $ hg log -Ra -r0 -T '{desc|1}\n' |
|
3315 | 3317 | hg: parse error: expected a symbol, got 'integer' |
|
3316 | 3318 | [255] |
|
3317 | 3319 | $ hg log -Ra -r0 -T '{1()}\n' |
|
3318 | 3320 | hg: parse error: expected a symbol, got 'integer' |
|
3319 | 3321 | [255] |
|
3320 | 3322 | |
|
3321 | 3323 | Test string literal: |
|
3322 | 3324 | |
|
3323 | 3325 | $ hg debugtemplate -Ra -r0 -v '{"string with no template fragment"}\n' |
|
3324 | 3326 | (template |
|
3325 | 3327 | (string 'string with no template fragment') |
|
3326 | 3328 | (string '\n')) |
|
3327 | 3329 | string with no template fragment |
|
3328 | 3330 | $ hg debugtemplate -Ra -r0 -v '{"template: {rev}"}\n' |
|
3329 | 3331 | (template |
|
3330 | 3332 | (template |
|
3331 | 3333 | (string 'template: ') |
|
3332 | 3334 | (symbol 'rev')) |
|
3333 | 3335 | (string '\n')) |
|
3334 | 3336 | template: 0 |
|
3335 | 3337 | $ hg debugtemplate -Ra -r0 -v '{r"rawstring: {rev}"}\n' |
|
3336 | 3338 | (template |
|
3337 | 3339 | (string 'rawstring: {rev}') |
|
3338 | 3340 | (string '\n')) |
|
3339 | 3341 | rawstring: {rev} |
|
3340 | 3342 | $ hg debugtemplate -Ra -r0 -v '{files % r"rawstring: {file}"}\n' |
|
3341 | 3343 | (template |
|
3342 | 3344 | (% |
|
3343 | 3345 | (symbol 'files') |
|
3344 | 3346 | (string 'rawstring: {file}')) |
|
3345 | 3347 | (string '\n')) |
|
3346 | 3348 | rawstring: {file} |
|
3347 | 3349 | |
|
3348 | 3350 | Test string escaping: |
|
3349 | 3351 | |
|
3350 | 3352 | $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3351 | 3353 | > |
|
3352 | 3354 | <>\n<[> |
|
3353 | 3355 | <>\n<]> |
|
3354 | 3356 | <>\n< |
|
3355 | 3357 | |
|
3356 | 3358 | $ hg log -R latesttag -r 0 \ |
|
3357 | 3359 | > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3358 | 3360 | > |
|
3359 | 3361 | <>\n<[> |
|
3360 | 3362 | <>\n<]> |
|
3361 | 3363 | <>\n< |
|
3362 | 3364 | |
|
3363 | 3365 | $ hg log -R latesttag -r 0 -T esc \ |
|
3364 | 3366 | > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3365 | 3367 | > |
|
3366 | 3368 | <>\n<[> |
|
3367 | 3369 | <>\n<]> |
|
3368 | 3370 | <>\n< |
|
3369 | 3371 | |
|
3370 | 3372 | $ cat <<'EOF' > esctmpl |
|
3371 | 3373 | > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3372 | 3374 | > EOF |
|
3373 | 3375 | $ hg log -R latesttag -r 0 --style ./esctmpl |
|
3374 | 3376 | > |
|
3375 | 3377 | <>\n<[> |
|
3376 | 3378 | <>\n<]> |
|
3377 | 3379 | <>\n< |
|
3378 | 3380 | |
|
3379 | 3381 | Test string escaping of quotes: |
|
3380 | 3382 | |
|
3381 | 3383 | $ hg log -Ra -r0 -T '{"\""}\n' |
|
3382 | 3384 | " |
|
3383 | 3385 | $ hg log -Ra -r0 -T '{"\\\""}\n' |
|
3384 | 3386 | \" |
|
3385 | 3387 | $ hg log -Ra -r0 -T '{r"\""}\n' |
|
3386 | 3388 | \" |
|
3387 | 3389 | $ hg log -Ra -r0 -T '{r"\\\""}\n' |
|
3388 | 3390 | \\\" |
|
3389 | 3391 | |
|
3390 | 3392 | |
|
3391 | 3393 | $ hg log -Ra -r0 -T '{"\""}\n' |
|
3392 | 3394 | " |
|
3393 | 3395 | $ hg log -Ra -r0 -T '{"\\\""}\n' |
|
3394 | 3396 | \" |
|
3395 | 3397 | $ hg log -Ra -r0 -T '{r"\""}\n' |
|
3396 | 3398 | \" |
|
3397 | 3399 | $ hg log -Ra -r0 -T '{r"\\\""}\n' |
|
3398 | 3400 | \\\" |
|
3399 | 3401 | |
|
3400 | 3402 | Test exception in quoted template. single backslash before quotation mark is |
|
3401 | 3403 | stripped before parsing: |
|
3402 | 3404 | |
|
3403 | 3405 | $ cat <<'EOF' > escquotetmpl |
|
3404 | 3406 | > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n" |
|
3405 | 3407 | > EOF |
|
3406 | 3408 | $ cd latesttag |
|
3407 | 3409 | $ hg log -r 2 --style ../escquotetmpl |
|
3408 | 3410 | " \" \" \\" head1 |
|
3409 | 3411 | |
|
3410 | 3412 | $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"' |
|
3411 | 3413 | valid |
|
3412 | 3414 | $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'" |
|
3413 | 3415 | valid |
|
3414 | 3416 | |
|
3415 | 3417 | Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested |
|
3416 | 3418 | _evalifliteral() templates (issue4733): |
|
3417 | 3419 | |
|
3418 | 3420 | $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n' |
|
3419 | 3421 | "2 |
|
3420 | 3422 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n' |
|
3421 | 3423 | "2 |
|
3422 | 3424 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n' |
|
3423 | 3425 | "2 |
|
3424 | 3426 | |
|
3425 | 3427 | $ hg log -r 2 -T '{if(rev, "\\\"")}\n' |
|
3426 | 3428 | \" |
|
3427 | 3429 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n' |
|
3428 | 3430 | \" |
|
3429 | 3431 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n' |
|
3430 | 3432 | \" |
|
3431 | 3433 | |
|
3432 | 3434 | $ hg log -r 2 -T '{if(rev, r"\\\"")}\n' |
|
3433 | 3435 | \\\" |
|
3434 | 3436 | $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n' |
|
3435 | 3437 | \\\" |
|
3436 | 3438 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n' |
|
3437 | 3439 | \\\" |
|
3438 | 3440 | |
|
3439 | 3441 | escaped single quotes and errors: |
|
3440 | 3442 | |
|
3441 | 3443 | $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n' |
|
3442 | 3444 | foo |
|
3443 | 3445 | $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n' |
|
3444 | 3446 | foo |
|
3445 | 3447 | $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n' |
|
3446 | 3448 | hg: parse error at 21: unterminated string |
|
3447 | 3449 | [255] |
|
3448 | 3450 | $ hg log -r 2 -T '{if(rev, \"\\"")}\n' |
|
3449 | 3451 | hg: parse error: trailing \ in string |
|
3450 | 3452 | [255] |
|
3451 | 3453 | $ hg log -r 2 -T '{if(rev, r\"\\"")}\n' |
|
3452 | 3454 | hg: parse error: trailing \ in string |
|
3453 | 3455 | [255] |
|
3454 | 3456 | |
|
3455 | 3457 | $ cd .. |
|
3456 | 3458 | |
|
3457 | 3459 | Test leading backslashes: |
|
3458 | 3460 | |
|
3459 | 3461 | $ cd latesttag |
|
3460 | 3462 | $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n' |
|
3461 | 3463 | {rev} {file} |
|
3462 | 3464 | $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n' |
|
3463 | 3465 | \2 \head1 |
|
3464 | 3466 | $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n' |
|
3465 | 3467 | \{rev} \{file} |
|
3466 | 3468 | $ cd .. |
|
3467 | 3469 | |
|
3468 | 3470 | Test leading backslashes in "if" expression (issue4714): |
|
3469 | 3471 | |
|
3470 | 3472 | $ cd latesttag |
|
3471 | 3473 | $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n' |
|
3472 | 3474 | {rev} \{rev} |
|
3473 | 3475 | $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n' |
|
3474 | 3476 | \2 \\{rev} |
|
3475 | 3477 | $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n' |
|
3476 | 3478 | \{rev} \\\{rev} |
|
3477 | 3479 | $ cd .. |
|
3478 | 3480 | |
|
3479 | 3481 | "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice) |
|
3480 | 3482 | |
|
3481 | 3483 | $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n' |
|
3482 | 3484 | \x6e |
|
3483 | 3485 | $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n' |
|
3484 | 3486 | \x5c\x786e |
|
3485 | 3487 | $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n' |
|
3486 | 3488 | \x6e |
|
3487 | 3489 | $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n' |
|
3488 | 3490 | \x5c\x786e |
|
3489 | 3491 | |
|
3490 | 3492 | $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n' |
|
3491 | 3493 | \x6e |
|
3492 | 3494 | $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n' |
|
3493 | 3495 | \x5c\x786e |
|
3494 | 3496 | $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n' |
|
3495 | 3497 | \x6e |
|
3496 | 3498 | $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n' |
|
3497 | 3499 | \x5c\x786e |
|
3498 | 3500 | |
|
3499 | 3501 | $ hg log -R a -r 8 --template '{join(files, "\n")}\n' |
|
3500 | 3502 | fourth |
|
3501 | 3503 | second |
|
3502 | 3504 | third |
|
3503 | 3505 | $ hg log -R a -r 8 --template '{join(files, r"\n")}\n' |
|
3504 | 3506 | fourth\nsecond\nthird |
|
3505 | 3507 | |
|
3506 | 3508 | $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}' |
|
3507 | 3509 | <p> |
|
3508 | 3510 | 1st |
|
3509 | 3511 | </p> |
|
3510 | 3512 | <p> |
|
3511 | 3513 | 2nd |
|
3512 | 3514 | </p> |
|
3513 | 3515 | $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}' |
|
3514 | 3516 | <p> |
|
3515 | 3517 | 1st\n\n2nd |
|
3516 | 3518 | </p> |
|
3517 | 3519 | $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}' |
|
3518 | 3520 | 1st |
|
3519 | 3521 | |
|
3520 | 3522 | 2nd |
|
3521 | 3523 | |
|
3522 | 3524 | $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n' |
|
3523 | 3525 | o perso |
|
3524 | 3526 | $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n' |
|
3525 | 3527 | no person |
|
3526 | 3528 | $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n' |
|
3527 | 3529 | o perso |
|
3528 | 3530 | $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n' |
|
3529 | 3531 | no perso |
|
3530 | 3532 | |
|
3531 | 3533 | $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n' |
|
3532 | 3534 | -o perso- |
|
3533 | 3535 | $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n' |
|
3534 | 3536 | no person |
|
3535 | 3537 | $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n' |
|
3536 | 3538 | \x2do perso\x2d |
|
3537 | 3539 | $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n' |
|
3538 | 3540 | -o perso- |
|
3539 | 3541 | $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n' |
|
3540 | 3542 | \x2do perso\x6e |
|
3541 | 3543 | |
|
3542 | 3544 | $ hg log -R a -r 8 --template '{files % "{file}\n"}' |
|
3543 | 3545 | fourth |
|
3544 | 3546 | second |
|
3545 | 3547 | third |
|
3546 | 3548 | |
|
3547 | 3549 | Test string escaping in nested expression: |
|
3548 | 3550 | |
|
3549 | 3551 | $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n' |
|
3550 | 3552 | fourth\x6esecond\x6ethird |
|
3551 | 3553 | $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n' |
|
3552 | 3554 | fourth\x6esecond\x6ethird |
|
3553 | 3555 | |
|
3554 | 3556 | $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n' |
|
3555 | 3557 | fourth\x6esecond\x6ethird |
|
3556 | 3558 | $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n' |
|
3557 | 3559 | fourth\x5c\x786esecond\x5c\x786ethird |
|
3558 | 3560 | |
|
3559 | 3561 | $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n' |
|
3560 | 3562 | 3:\x6eo user, \x6eo domai\x6e |
|
3561 | 3563 | 4:\x5c\x786eew bra\x5c\x786ech |
|
3562 | 3564 | |
|
3563 | 3565 | Test quotes in nested expression are evaluated just like a $(command) |
|
3564 | 3566 | substitution in POSIX shells: |
|
3565 | 3567 | |
|
3566 | 3568 | $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n' |
|
3567 | 3569 | 8:95c24699272e |
|
3568 | 3570 | $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n' |
|
3569 | 3571 | {8} "95c24699272e" |
|
3570 | 3572 | |
|
3571 | 3573 | Test recursive evaluation: |
|
3572 | 3574 | |
|
3573 | 3575 | $ hg init r |
|
3574 | 3576 | $ cd r |
|
3575 | 3577 | $ echo a > a |
|
3576 | 3578 | $ hg ci -Am '{rev}' |
|
3577 | 3579 | adding a |
|
3578 | 3580 | $ hg log -r 0 --template '{if(rev, desc)}\n' |
|
3579 | 3581 | {rev} |
|
3580 | 3582 | $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n' |
|
3581 | 3583 | test 0 |
|
3582 | 3584 | |
|
3583 | 3585 | $ hg branch -q 'text.{rev}' |
|
3584 | 3586 | $ echo aa >> aa |
|
3585 | 3587 | $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped' |
|
3586 | 3588 | |
|
3587 | 3589 | $ hg log -l1 --template '{fill(desc, "20", author, branch)}' |
|
3588 | 3590 | {node|short}desc to |
|
3589 | 3591 | text.{rev}be wrapped |
|
3590 | 3592 | text.{rev}desc to be |
|
3591 | 3593 | text.{rev}wrapped (no-eol) |
|
3592 | 3594 | $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}' |
|
3593 | 3595 | bcc7ff960b8e:desc to |
|
3594 | 3596 | text.1:be wrapped |
|
3595 | 3597 | text.1:desc to be |
|
3596 | 3598 | text.1:wrapped (no-eol) |
|
3597 | 3599 | $ hg log -l1 -T '{fill(desc, date, "", "")}\n' |
|
3598 | 3600 | hg: parse error: fill expects an integer width |
|
3599 | 3601 | [255] |
|
3600 | 3602 | |
|
3601 | 3603 | $ COLUMNS=25 hg log -l1 --template '{fill(desc, termwidth, "{node|short}:", "termwidth.{rev}:")}' |
|
3602 | 3604 | bcc7ff960b8e:desc to be |
|
3603 | 3605 | termwidth.1:wrapped desc |
|
3604 | 3606 | termwidth.1:to be wrapped (no-eol) |
|
3605 | 3607 | |
|
3606 | 3608 | $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}' |
|
3607 | 3609 | {node|short} (no-eol) |
|
3608 | 3610 | $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}' |
|
3609 | 3611 | bcc-ff---b-e (no-eol) |
|
3610 | 3612 | |
|
3611 | 3613 | $ cat >> .hg/hgrc <<EOF |
|
3612 | 3614 | > [extensions] |
|
3613 | 3615 | > color= |
|
3614 | 3616 | > [color] |
|
3615 | 3617 | > mode=ansi |
|
3616 | 3618 | > text.{rev} = red |
|
3617 | 3619 | > text.1 = green |
|
3618 | 3620 | > EOF |
|
3619 | 3621 | $ hg log --color=always -l 1 --template '{label(branch, "text\n")}' |
|
3620 | 3622 | \x1b[0;31mtext\x1b[0m (esc) |
|
3621 | 3623 | $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}' |
|
3622 | 3624 | \x1b[0;32mtext\x1b[0m (esc) |
|
3623 | 3625 | |
|
3624 | 3626 | color effect can be specified without quoting: |
|
3625 | 3627 | |
|
3626 | 3628 | $ hg log --color=always -l 1 --template '{label(red, "text\n")}' |
|
3627 | 3629 | \x1b[0;31mtext\x1b[0m (esc) |
|
3628 | 3630 | |
|
3629 | 3631 | color effects can be nested (issue5413) |
|
3630 | 3632 | |
|
3631 | 3633 | $ hg debugtemplate --color=always \ |
|
3632 | 3634 | > '{label(red, "red{label(magenta, "ma{label(cyan, "cyan")}{label(yellow, "yellow")}genta")}")}\n' |
|
3633 | 3635 | \x1b[0;31mred\x1b[0;35mma\x1b[0;36mcyan\x1b[0m\x1b[0;31m\x1b[0;35m\x1b[0;33myellow\x1b[0m\x1b[0;31m\x1b[0;35mgenta\x1b[0m (esc) |
|
3634 | 3636 | |
|
3635 | 3637 | pad() should interact well with color codes (issue5416) |
|
3636 | 3638 | |
|
3637 | 3639 | $ hg debugtemplate --color=always \ |
|
3638 | 3640 | > '{pad(label(red, "red"), 5, label(cyan, "-"))}\n' |
|
3639 | 3641 | \x1b[0;31mred\x1b[0m\x1b[0;36m-\x1b[0m\x1b[0;36m-\x1b[0m (esc) |
|
3640 | 3642 | |
|
3641 | 3643 | label should be no-op if color is disabled: |
|
3642 | 3644 | |
|
3643 | 3645 | $ hg log --color=never -l 1 --template '{label(red, "text\n")}' |
|
3644 | 3646 | text |
|
3645 | 3647 | $ hg log --config extensions.color=! -l 1 --template '{label(red, "text\n")}' |
|
3646 | 3648 | text |
|
3647 | 3649 | |
|
3648 | 3650 | Test branches inside if statement: |
|
3649 | 3651 | |
|
3650 | 3652 | $ hg log -r 0 --template '{if(branches, "yes", "no")}\n' |
|
3651 | 3653 | no |
|
3652 | 3654 | |
|
3653 | 3655 | Test dict constructor: |
|
3654 | 3656 | |
|
3655 | 3657 | $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n' |
|
3656 | 3658 | y=f7769ec2ab97 x=0 |
|
3657 | 3659 | $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}' |
|
3658 | 3660 | x=0 |
|
3659 | 3661 | y=f7769ec2ab97 |
|
3660 | 3662 | $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n' |
|
3661 | 3663 | {"x": 0, "y": "f7769ec2ab97"} |
|
3662 | 3664 | $ hg log -r 0 -T '{dict()|json}\n' |
|
3663 | 3665 | {} |
|
3664 | 3666 | |
|
3665 | 3667 | $ hg log -r 0 -T '{dict(rev, node=node|short)}\n' |
|
3666 | 3668 | rev=0 node=f7769ec2ab97 |
|
3667 | 3669 | $ hg log -r 0 -T '{dict(rev, node|short)}\n' |
|
3668 | 3670 | rev=0 node=f7769ec2ab97 |
|
3669 | 3671 | |
|
3670 | 3672 | $ hg log -r 0 -T '{dict(rev, rev=rev)}\n' |
|
3671 | 3673 | hg: parse error: duplicated dict key 'rev' inferred |
|
3672 | 3674 | [255] |
|
3673 | 3675 | $ hg log -r 0 -T '{dict(node, node|short)}\n' |
|
3674 | 3676 | hg: parse error: duplicated dict key 'node' inferred |
|
3675 | 3677 | [255] |
|
3676 | 3678 | $ hg log -r 0 -T '{dict(1 + 2)}' |
|
3677 | 3679 | hg: parse error: dict key cannot be inferred |
|
3678 | 3680 | [255] |
|
3679 | 3681 | |
|
3680 | 3682 | $ hg log -r 0 -T '{dict(x=rev, x=node)}' |
|
3681 | 3683 | hg: parse error: dict got multiple values for keyword argument 'x' |
|
3682 | 3684 | [255] |
|
3683 | 3685 | |
|
3684 | 3686 | Test get function: |
|
3685 | 3687 | |
|
3686 | 3688 | $ hg log -r 0 --template '{get(extras, "branch")}\n' |
|
3687 | 3689 | default |
|
3688 | 3690 | $ hg log -r 0 --template '{get(extras, "br{"anch"}")}\n' |
|
3689 | 3691 | default |
|
3690 | 3692 | $ hg log -r 0 --template '{get(files, "should_fail")}\n' |
|
3691 | 3693 | hg: parse error: get() expects a dict as first argument |
|
3692 | 3694 | [255] |
|
3693 | 3695 | |
|
3694 | 3696 | Test json filter applied to hybrid object: |
|
3695 | 3697 | |
|
3696 | 3698 | $ hg log -r0 -T '{files|json}\n' |
|
3697 | 3699 | ["a"] |
|
3698 | 3700 | $ hg log -r0 -T '{extras|json}\n' |
|
3699 | 3701 | {"branch": "default"} |
|
3700 | 3702 | |
|
3701 | 3703 | Test localdate(date, tz) function: |
|
3702 | 3704 | |
|
3703 | 3705 | $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n' |
|
3704 | 3706 | 1970-01-01 09:00 +0900 |
|
3705 | 3707 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n' |
|
3706 | 3708 | 1970-01-01 00:00 +0000 |
|
3707 | 3709 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "blahUTC")|isodate}\n' |
|
3708 | 3710 | hg: parse error: localdate expects a timezone |
|
3709 | 3711 | [255] |
|
3710 | 3712 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n' |
|
3711 | 3713 | 1970-01-01 02:00 +0200 |
|
3712 | 3714 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n' |
|
3713 | 3715 | 1970-01-01 00:00 +0000 |
|
3714 | 3716 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n' |
|
3715 | 3717 | 1970-01-01 00:00 +0000 |
|
3716 | 3718 | $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n' |
|
3717 | 3719 | hg: parse error: localdate expects a timezone |
|
3718 | 3720 | [255] |
|
3719 | 3721 | $ hg log -r0 -T '{localdate(date, date)|isodate}\n' |
|
3720 | 3722 | hg: parse error: localdate expects a timezone |
|
3721 | 3723 | [255] |
|
3722 | 3724 | |
|
3723 | 3725 | Test shortest(node) function: |
|
3724 | 3726 | |
|
3725 | 3727 | $ echo b > b |
|
3726 | 3728 | $ hg ci -qAm b |
|
3727 | 3729 | $ hg log --template '{shortest(node)}\n' |
|
3728 | 3730 | e777 |
|
3729 | 3731 | bcc7 |
|
3730 | 3732 | f776 |
|
3731 | 3733 | $ hg log --template '{shortest(node, 10)}\n' |
|
3732 | 3734 | e777603221 |
|
3733 | 3735 | bcc7ff960b |
|
3734 | 3736 | f7769ec2ab |
|
3735 | 3737 | $ hg log --template '{node|shortest}\n' -l1 |
|
3736 | 3738 | e777 |
|
3737 | 3739 | |
|
3738 | 3740 | $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n' |
|
3739 | 3741 | f7769ec2ab |
|
3740 | 3742 | $ hg log -r 0 -T '{shortest(node, "not an int")}\n' |
|
3741 | 3743 | hg: parse error: shortest() expects an integer minlength |
|
3742 | 3744 | [255] |
|
3743 | 3745 | |
|
3744 | 3746 | $ hg log -r 'wdir()' -T '{node|shortest}\n' |
|
3745 | 3747 | ffff |
|
3746 | 3748 | |
|
3747 | 3749 | $ cd .. |
|
3748 | 3750 | |
|
3749 | 3751 | Test shortest(node) with the repo having short hash collision: |
|
3750 | 3752 | |
|
3751 | 3753 | $ hg init hashcollision |
|
3752 | 3754 | $ cd hashcollision |
|
3753 | 3755 | $ cat <<EOF >> .hg/hgrc |
|
3754 | 3756 | > [experimental] |
|
3755 | 3757 | > stabilization = createmarkers |
|
3756 | 3758 | > EOF |
|
3757 | 3759 | $ echo 0 > a |
|
3758 | 3760 | $ hg ci -qAm 0 |
|
3759 | 3761 | $ for i in 17 129 248 242 480 580 617 1057 2857 4025; do |
|
3760 | 3762 | > hg up -q 0 |
|
3761 | 3763 | > echo $i > a |
|
3762 | 3764 | > hg ci -qm $i |
|
3763 | 3765 | > done |
|
3764 | 3766 | $ hg up -q null |
|
3765 | 3767 | $ hg log -r0: -T '{rev}:{node}\n' |
|
3766 | 3768 | 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a |
|
3767 | 3769 | 1:11424df6dc1dd4ea255eae2b58eaca7831973bbc |
|
3768 | 3770 | 2:11407b3f1b9c3e76a79c1ec5373924df096f0499 |
|
3769 | 3771 | 3:11dd92fe0f39dfdaacdaa5f3997edc533875cfc4 |
|
3770 | 3772 | 4:10776689e627b465361ad5c296a20a487e153ca4 |
|
3771 | 3773 | 5:a00be79088084cb3aff086ab799f8790e01a976b |
|
3772 | 3774 | 6:a0b0acd79b4498d0052993d35a6a748dd51d13e6 |
|
3773 | 3775 | 7:a0457b3450b8e1b778f1163b31a435802987fe5d |
|
3774 | 3776 | 8:c56256a09cd28e5764f32e8e2810d0f01e2e357a |
|
3775 | 3777 | 9:c5623987d205cd6d9d8389bfc40fff9dbb670b48 |
|
3776 | 3778 | 10:c562ddd9c94164376c20b86b0b4991636a3bf84f |
|
3777 | 3779 | $ hg debugobsolete a00be79088084cb3aff086ab799f8790e01a976b |
|
3778 | 3780 | obsoleted 1 changesets |
|
3779 | 3781 | $ hg debugobsolete c5623987d205cd6d9d8389bfc40fff9dbb670b48 |
|
3780 | 3782 | obsoleted 1 changesets |
|
3781 | 3783 | $ hg debugobsolete c562ddd9c94164376c20b86b0b4991636a3bf84f |
|
3782 | 3784 | obsoleted 1 changesets |
|
3783 | 3785 | |
|
3784 | 3786 | nodes starting with '11' (we don't have the revision number '11' though) |
|
3785 | 3787 | |
|
3786 | 3788 | $ hg log -r 1:3 -T '{rev}:{shortest(node, 0)}\n' |
|
3787 | 3789 | 1:1142 |
|
3788 | 3790 | 2:1140 |
|
3789 | 3791 | 3:11d |
|
3790 | 3792 | |
|
3791 | 3793 | '5:a00' is hidden, but still we have two nodes starting with 'a0' |
|
3792 | 3794 | |
|
3793 | 3795 | $ hg log -r 6:7 -T '{rev}:{shortest(node, 0)}\n' |
|
3794 | 3796 | 6:a0b |
|
3795 | 3797 | 7:a04 |
|
3796 | 3798 | |
|
3797 | 3799 | node '10' conflicts with the revision number '10' even if it is hidden |
|
3798 | 3800 | (we could exclude hidden revision numbers, but currently we don't) |
|
3799 | 3801 | |
|
3800 | 3802 | $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' |
|
3801 | 3803 | 4:107 |
|
3802 | 3804 | $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden |
|
3803 | 3805 | 4:107 |
|
3804 | 3806 | |
|
3805 | 3807 | node 'c562' should be unique if the other 'c562' nodes are hidden |
|
3806 | 3808 | (but we don't try the slow path to filter out hidden nodes for now) |
|
3807 | 3809 | |
|
3808 | 3810 | $ hg log -r 8 -T '{rev}:{node|shortest}\n' |
|
3809 | 3811 | 8:c5625 |
|
3810 | 3812 | $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden |
|
3811 | 3813 | 8:c5625 |
|
3812 | 3814 | 9:c5623 |
|
3813 | 3815 | 10:c562d |
|
3814 | 3816 | |
|
3815 | 3817 | $ cd .. |
|
3816 | 3818 | |
|
3817 | 3819 | Test pad function |
|
3818 | 3820 | |
|
3819 | 3821 | $ cd r |
|
3820 | 3822 | |
|
3821 | 3823 | $ hg log --template '{pad(rev, 20)} {author|user}\n' |
|
3822 | 3824 | 2 test |
|
3823 | 3825 | 1 {node|short} |
|
3824 | 3826 | 0 test |
|
3825 | 3827 | |
|
3826 | 3828 | $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n' |
|
3827 | 3829 | 2 test |
|
3828 | 3830 | 1 {node|short} |
|
3829 | 3831 | 0 test |
|
3830 | 3832 | |
|
3831 | 3833 | $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n' |
|
3832 | 3834 | 2------------------- test |
|
3833 | 3835 | 1------------------- {node|short} |
|
3834 | 3836 | 0------------------- test |
|
3835 | 3837 | |
|
3836 | 3838 | Test template string in pad function |
|
3837 | 3839 | |
|
3838 | 3840 | $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n' |
|
3839 | 3841 | {0} test |
|
3840 | 3842 | |
|
3841 | 3843 | $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n' |
|
3842 | 3844 | \{rev} test |
|
3843 | 3845 | |
|
3844 | 3846 | Test width argument passed to pad function |
|
3845 | 3847 | |
|
3846 | 3848 | $ hg log -r 0 -T '{pad(rev, "1{"0"}")} {author|user}\n' |
|
3847 | 3849 | 0 test |
|
3848 | 3850 | $ hg log -r 0 -T '{pad(rev, "not an int")}\n' |
|
3849 | 3851 | hg: parse error: pad() expects an integer width |
|
3850 | 3852 | [255] |
|
3851 | 3853 | |
|
3852 | 3854 | Test invalid fillchar passed to pad function |
|
3853 | 3855 | |
|
3854 | 3856 | $ hg log -r 0 -T '{pad(rev, 10, "")}\n' |
|
3855 | 3857 | hg: parse error: pad() expects a single fill character |
|
3856 | 3858 | [255] |
|
3857 | 3859 | $ hg log -r 0 -T '{pad(rev, 10, "--")}\n' |
|
3858 | 3860 | hg: parse error: pad() expects a single fill character |
|
3859 | 3861 | [255] |
|
3860 | 3862 | |
|
3861 | 3863 | Test boolean argument passed to pad function |
|
3862 | 3864 | |
|
3863 | 3865 | no crash |
|
3864 | 3866 | |
|
3865 | 3867 | $ hg log -r 0 -T '{pad(rev, 10, "-", "f{"oo"}")}\n' |
|
3866 | 3868 | ---------0 |
|
3867 | 3869 | |
|
3868 | 3870 | string/literal |
|
3869 | 3871 | |
|
3870 | 3872 | $ hg log -r 0 -T '{pad(rev, 10, "-", "false")}\n' |
|
3871 | 3873 | ---------0 |
|
3872 | 3874 | $ hg log -r 0 -T '{pad(rev, 10, "-", false)}\n' |
|
3873 | 3875 | 0--------- |
|
3874 | 3876 | $ hg log -r 0 -T '{pad(rev, 10, "-", "")}\n' |
|
3875 | 3877 | 0--------- |
|
3876 | 3878 | |
|
3877 | 3879 | unknown keyword is evaluated to '' |
|
3878 | 3880 | |
|
3879 | 3881 | $ hg log -r 0 -T '{pad(rev, 10, "-", unknownkeyword)}\n' |
|
3880 | 3882 | 0--------- |
|
3881 | 3883 | |
|
3882 | 3884 | Test separate function |
|
3883 | 3885 | |
|
3884 | 3886 | $ hg log -r 0 -T '{separate("-", "", "a", "b", "", "", "c", "")}\n' |
|
3885 | 3887 | a-b-c |
|
3886 | 3888 | $ hg log -r 0 -T '{separate(" ", "{rev}:{node|short}", author|user, branch)}\n' |
|
3887 | 3889 | 0:f7769ec2ab97 test default |
|
3888 | 3890 | $ hg log -r 0 --color=always -T '{separate(" ", "a", label(red, "b"), "c", label(red, ""), "d")}\n' |
|
3889 | 3891 | a \x1b[0;31mb\x1b[0m c d (esc) |
|
3890 | 3892 | |
|
3891 | 3893 | Test boolean expression/literal passed to if function |
|
3892 | 3894 | |
|
3893 | 3895 | $ hg log -r 0 -T '{if(rev, "rev 0 is True")}\n' |
|
3894 | 3896 | rev 0 is True |
|
3895 | 3897 | $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n' |
|
3896 | 3898 | literal 0 is True as well |
|
3897 | 3899 | $ hg log -r 0 -T '{if("", "", "empty string is False")}\n' |
|
3898 | 3900 | empty string is False |
|
3899 | 3901 | $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n' |
|
3900 | 3902 | empty list is False |
|
3901 | 3903 | $ hg log -r 0 -T '{if(true, "true is True")}\n' |
|
3902 | 3904 | true is True |
|
3903 | 3905 | $ hg log -r 0 -T '{if(false, "", "false is False")}\n' |
|
3904 | 3906 | false is False |
|
3905 | 3907 | $ hg log -r 0 -T '{if("false", "non-empty string is True")}\n' |
|
3906 | 3908 | non-empty string is True |
|
3907 | 3909 | |
|
3908 | 3910 | Test ifcontains function |
|
3909 | 3911 | |
|
3910 | 3912 | $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n' |
|
3911 | 3913 | 2 is in the string |
|
3912 | 3914 | 1 is not |
|
3913 | 3915 | 0 is in the string |
|
3914 | 3916 | |
|
3915 | 3917 | $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n' |
|
3916 | 3918 | 2 is in the string |
|
3917 | 3919 | 1 is not |
|
3918 | 3920 | 0 is in the string |
|
3919 | 3921 | |
|
3920 | 3922 | $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n' |
|
3921 | 3923 | 2 did not add a |
|
3922 | 3924 | 1 did not add a |
|
3923 | 3925 | 0 added a |
|
3924 | 3926 | |
|
3925 | 3927 | $ hg log --debug -T '{rev}{ifcontains(1, parents, " is parent of 1")}\n' |
|
3926 | 3928 | 2 is parent of 1 |
|
3927 | 3929 | 1 |
|
3928 | 3930 | 0 |
|
3929 | 3931 | |
|
3930 | 3932 | Test revset function |
|
3931 | 3933 | |
|
3932 | 3934 | $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n' |
|
3933 | 3935 | 2 current rev |
|
3934 | 3936 | 1 not current rev |
|
3935 | 3937 | 0 not current rev |
|
3936 | 3938 | |
|
3937 | 3939 | $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n' |
|
3938 | 3940 | 2 match rev |
|
3939 | 3941 | 1 match rev |
|
3940 | 3942 | 0 not match rev |
|
3941 | 3943 | |
|
3942 | 3944 | $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n' |
|
3943 | 3945 | 2 Parents: 1 |
|
3944 | 3946 | 1 Parents: 0 |
|
3945 | 3947 | 0 Parents: |
|
3946 | 3948 | |
|
3947 | 3949 | $ cat >> .hg/hgrc <<EOF |
|
3948 | 3950 | > [revsetalias] |
|
3949 | 3951 | > myparents(\$1) = parents(\$1) |
|
3950 | 3952 | > EOF |
|
3951 | 3953 | $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n' |
|
3952 | 3954 | 2 Parents: 1 |
|
3953 | 3955 | 1 Parents: 0 |
|
3954 | 3956 | 0 Parents: |
|
3955 | 3957 | |
|
3956 | 3958 | $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n' |
|
3957 | 3959 | Rev: 2 |
|
3958 | 3960 | Ancestor: 0 |
|
3959 | 3961 | Ancestor: 1 |
|
3960 | 3962 | Ancestor: 2 |
|
3961 | 3963 | |
|
3962 | 3964 | Rev: 1 |
|
3963 | 3965 | Ancestor: 0 |
|
3964 | 3966 | Ancestor: 1 |
|
3965 | 3967 | |
|
3966 | 3968 | Rev: 0 |
|
3967 | 3969 | Ancestor: 0 |
|
3968 | 3970 | |
|
3969 | 3971 | $ hg log --template '{revset("TIP"|lower)}\n' -l1 |
|
3970 | 3972 | 2 |
|
3971 | 3973 | |
|
3972 | 3974 | $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1 |
|
3973 | 3975 | 2 |
|
3974 | 3976 | |
|
3975 | 3977 | a list template is evaluated for each item of revset/parents |
|
3976 | 3978 | |
|
3977 | 3979 | $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n' |
|
3978 | 3980 | 2 p: 1:bcc7ff960b8e |
|
3979 | 3981 | 1 p: 0:f7769ec2ab97 |
|
3980 | 3982 | 0 p: |
|
3981 | 3983 | |
|
3982 | 3984 | $ hg log --debug -T '{rev} p:{parents % " {rev}:{node|short}"}\n' |
|
3983 | 3985 | 2 p: 1:bcc7ff960b8e -1:000000000000 |
|
3984 | 3986 | 1 p: 0:f7769ec2ab97 -1:000000000000 |
|
3985 | 3987 | 0 p: -1:000000000000 -1:000000000000 |
|
3986 | 3988 | |
|
3987 | 3989 | therefore, 'revcache' should be recreated for each rev |
|
3988 | 3990 | |
|
3989 | 3991 | $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n' |
|
3990 | 3992 | 2 aa b |
|
3991 | 3993 | p |
|
3992 | 3994 | 1 |
|
3993 | 3995 | p a |
|
3994 | 3996 | 0 a |
|
3995 | 3997 | p |
|
3996 | 3998 | |
|
3997 | 3999 | $ hg log --debug -T '{rev} {file_adds}\np {parents % "{file_adds}"}\n' |
|
3998 | 4000 | 2 aa b |
|
3999 | 4001 | p |
|
4000 | 4002 | 1 |
|
4001 | 4003 | p a |
|
4002 | 4004 | 0 a |
|
4003 | 4005 | p |
|
4004 | 4006 | |
|
4005 | 4007 | a revset item must be evaluated as an integer revision, not an offset from tip |
|
4006 | 4008 | |
|
4007 | 4009 | $ hg log -l 1 -T '{revset("null") % "{rev}:{node|short}"}\n' |
|
4008 | 4010 | -1:000000000000 |
|
4009 | 4011 | $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n' |
|
4010 | 4012 | -1:000000000000 |
|
4011 | 4013 | |
|
4012 | 4014 | join() should pick '{rev}' from revset items: |
|
4013 | 4015 | |
|
4014 | 4016 | $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6 |
|
4015 | 4017 | 4, 5 |
|
4016 | 4018 | |
|
4017 | 4019 | on the other hand, parents are formatted as '{rev}:{node|formatnode}' by |
|
4018 | 4020 | default. join() should agree with the default formatting: |
|
4019 | 4021 | |
|
4020 | 4022 | $ hg log -R ../a -T '{join(parents, ", ")}\n' -r6 |
|
4021 | 4023 | 5:13207e5a10d9, 4:bbe44766e73d |
|
4022 | 4024 | |
|
4023 | 4025 | $ hg log -R ../a -T '{join(parents, ",\n")}\n' -r6 --debug |
|
4024 | 4026 | 5:13207e5a10d9fd28ec424934298e176197f2c67f, |
|
4025 | 4027 | 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
4026 | 4028 | |
|
4027 | 4029 | Test files function |
|
4028 | 4030 | |
|
4029 | 4031 | $ hg log -T "{rev}\n{join(files('*'), '\n')}\n" |
|
4030 | 4032 | 2 |
|
4031 | 4033 | a |
|
4032 | 4034 | aa |
|
4033 | 4035 | b |
|
4034 | 4036 | 1 |
|
4035 | 4037 | a |
|
4036 | 4038 | 0 |
|
4037 | 4039 | a |
|
4038 | 4040 | |
|
4039 | 4041 | $ hg log -T "{rev}\n{join(files('aa'), '\n')}\n" |
|
4040 | 4042 | 2 |
|
4041 | 4043 | aa |
|
4042 | 4044 | 1 |
|
4043 | 4045 | |
|
4044 | 4046 | 0 |
|
4045 | 4047 | |
|
4046 | 4048 | |
|
4047 | 4049 | Test relpath function |
|
4048 | 4050 | |
|
4049 | 4051 | $ hg log -r0 -T '{files % "{file|relpath}\n"}' |
|
4050 | 4052 | a |
|
4051 | 4053 | $ cd .. |
|
4052 | 4054 | $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}' |
|
4053 | 4055 | r/a |
|
4054 | 4056 | $ cd r |
|
4055 | 4057 | |
|
4056 | 4058 | Test active bookmark templating |
|
4057 | 4059 | |
|
4058 | 4060 | $ hg book foo |
|
4059 | 4061 | $ hg book bar |
|
4060 | 4062 | $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n" |
|
4061 | 4063 | 2 bar* foo |
|
4062 | 4064 | 1 |
|
4063 | 4065 | 0 |
|
4064 | 4066 | $ hg log --template "{rev} {activebookmark}\n" |
|
4065 | 4067 | 2 bar |
|
4066 | 4068 | 1 |
|
4067 | 4069 | 0 |
|
4068 | 4070 | $ hg bookmarks --inactive bar |
|
4069 | 4071 | $ hg log --template "{rev} {activebookmark}\n" |
|
4070 | 4072 | 2 |
|
4071 | 4073 | 1 |
|
4072 | 4074 | 0 |
|
4073 | 4075 | $ hg book -r1 baz |
|
4074 | 4076 | $ hg log --template "{rev} {join(bookmarks, ' ')}\n" |
|
4075 | 4077 | 2 bar foo |
|
4076 | 4078 | 1 baz |
|
4077 | 4079 | 0 |
|
4078 | 4080 | $ hg log --template "{rev} {ifcontains('foo', bookmarks, 't', 'f')}\n" |
|
4079 | 4081 | 2 t |
|
4080 | 4082 | 1 f |
|
4081 | 4083 | 0 f |
|
4082 | 4084 | |
|
4083 | 4085 | Test namespaces dict |
|
4084 | 4086 | |
|
4085 | 4087 | $ hg --config extensions.revnamesext=$TESTDIR/revnamesext.py log -T '{rev}\n{namespaces % " {namespace} color={colorname} builtin={builtin}\n {join(names, ",")}\n"}\n' |
|
4086 | 4088 | 2 |
|
4087 | 4089 | bookmarks color=bookmark builtin=True |
|
4088 | 4090 | bar,foo |
|
4089 | 4091 | tags color=tag builtin=True |
|
4090 | 4092 | tip |
|
4091 | 4093 | branches color=branch builtin=True |
|
4092 | 4094 | text.{rev} |
|
4093 | 4095 | revnames color=revname builtin=False |
|
4094 | 4096 | r2 |
|
4095 | 4097 | |
|
4096 | 4098 | 1 |
|
4097 | 4099 | bookmarks color=bookmark builtin=True |
|
4098 | 4100 | baz |
|
4099 | 4101 | tags color=tag builtin=True |
|
4100 | 4102 | |
|
4101 | 4103 | branches color=branch builtin=True |
|
4102 | 4104 | text.{rev} |
|
4103 | 4105 | revnames color=revname builtin=False |
|
4104 | 4106 | r1 |
|
4105 | 4107 | |
|
4106 | 4108 | 0 |
|
4107 | 4109 | bookmarks color=bookmark builtin=True |
|
4108 | 4110 | |
|
4109 | 4111 | tags color=tag builtin=True |
|
4110 | 4112 | |
|
4111 | 4113 | branches color=branch builtin=True |
|
4112 | 4114 | default |
|
4113 | 4115 | revnames color=revname builtin=False |
|
4114 | 4116 | r0 |
|
4115 | 4117 | |
|
4116 | 4118 | $ hg log -r2 -T '{namespaces % "{namespace}: {names}\n"}' |
|
4117 | 4119 | bookmarks: bar foo |
|
4118 | 4120 | tags: tip |
|
4119 | 4121 | branches: text.{rev} |
|
4120 | 4122 | $ hg log -r2 -T '{namespaces % "{namespace}:\n{names % " {name}\n"}"}' |
|
4121 | 4123 | bookmarks: |
|
4122 | 4124 | bar |
|
4123 | 4125 | foo |
|
4124 | 4126 | tags: |
|
4125 | 4127 | tip |
|
4126 | 4128 | branches: |
|
4127 | 4129 | text.{rev} |
|
4128 | 4130 | $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}' |
|
4129 | 4131 | bar |
|
4130 | 4132 | foo |
|
4131 | 4133 | |
|
4132 | 4134 | Test stringify on sub expressions |
|
4133 | 4135 | |
|
4134 | 4136 | $ cd .. |
|
4135 | 4137 | $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n' |
|
4136 | 4138 | fourth, second, third |
|
4137 | 4139 | $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n' |
|
4138 | 4140 | abc |
|
4139 | 4141 | |
|
4140 | 4142 | Test splitlines |
|
4141 | 4143 | |
|
4142 | 4144 | $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}" |
|
4143 | 4145 | @ foo Modify, add, remove, rename |
|
4144 | 4146 | | |
|
4145 | 4147 | o foo future |
|
4146 | 4148 | | |
|
4147 | 4149 | o foo third |
|
4148 | 4150 | | |
|
4149 | 4151 | o foo second |
|
4150 | 4152 | |
|
4151 | 4153 | o foo merge |
|
4152 | 4154 | |\ |
|
4153 | 4155 | | o foo new head |
|
4154 | 4156 | | | |
|
4155 | 4157 | o | foo new branch |
|
4156 | 4158 | |/ |
|
4157 | 4159 | o foo no user, no domain |
|
4158 | 4160 | | |
|
4159 | 4161 | o foo no person |
|
4160 | 4162 | | |
|
4161 | 4163 | o foo other 1 |
|
4162 | 4164 | | foo other 2 |
|
4163 | 4165 | | foo |
|
4164 | 4166 | | foo other 3 |
|
4165 | 4167 | o foo line 1 |
|
4166 | 4168 | foo line 2 |
|
4167 | 4169 | |
|
4168 | 4170 | $ hg log -R a -r0 -T '{desc|splitlines}\n' |
|
4169 | 4171 | line 1 line 2 |
|
4170 | 4172 | $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n' |
|
4171 | 4173 | line 1|line 2 |
|
4172 | 4174 | |
|
4173 | 4175 | Test startswith |
|
4174 | 4176 | $ hg log -Gv -R a --template "{startswith(desc)}" |
|
4175 | 4177 | hg: parse error: startswith expects two arguments |
|
4176 | 4178 | [255] |
|
4177 | 4179 | |
|
4178 | 4180 | $ hg log -Gv -R a --template "{startswith('line', desc)}" |
|
4179 | 4181 | @ |
|
4180 | 4182 | | |
|
4181 | 4183 | o |
|
4182 | 4184 | | |
|
4183 | 4185 | o |
|
4184 | 4186 | | |
|
4185 | 4187 | o |
|
4186 | 4188 | |
|
4187 | 4189 | o |
|
4188 | 4190 | |\ |
|
4189 | 4191 | | o |
|
4190 | 4192 | | | |
|
4191 | 4193 | o | |
|
4192 | 4194 | |/ |
|
4193 | 4195 | o |
|
4194 | 4196 | | |
|
4195 | 4197 | o |
|
4196 | 4198 | | |
|
4197 | 4199 | o |
|
4198 | 4200 | | |
|
4199 | 4201 | o line 1 |
|
4200 | 4202 | line 2 |
|
4201 | 4203 | |
|
4202 | 4204 | Test bad template with better error message |
|
4203 | 4205 | |
|
4204 | 4206 | $ hg log -Gv -R a --template '{desc|user()}' |
|
4205 | 4207 | hg: parse error: expected a symbol, got 'func' |
|
4206 | 4208 | [255] |
|
4207 | 4209 | |
|
4208 | 4210 | Test word function (including index out of bounds graceful failure) |
|
4209 | 4211 | |
|
4210 | 4212 | $ hg log -Gv -R a --template "{word('1', desc)}" |
|
4211 | 4213 | @ add, |
|
4212 | 4214 | | |
|
4213 | 4215 | o |
|
4214 | 4216 | | |
|
4215 | 4217 | o |
|
4216 | 4218 | | |
|
4217 | 4219 | o |
|
4218 | 4220 | |
|
4219 | 4221 | o |
|
4220 | 4222 | |\ |
|
4221 | 4223 | | o head |
|
4222 | 4224 | | | |
|
4223 | 4225 | o | branch |
|
4224 | 4226 | |/ |
|
4225 | 4227 | o user, |
|
4226 | 4228 | | |
|
4227 | 4229 | o person |
|
4228 | 4230 | | |
|
4229 | 4231 | o 1 |
|
4230 | 4232 | | |
|
4231 | 4233 | o 1 |
|
4232 | 4234 | |
|
4233 | 4235 | |
|
4234 | 4236 | Test word third parameter used as splitter |
|
4235 | 4237 | |
|
4236 | 4238 | $ hg log -Gv -R a --template "{word('0', desc, 'o')}" |
|
4237 | 4239 | @ M |
|
4238 | 4240 | | |
|
4239 | 4241 | o future |
|
4240 | 4242 | | |
|
4241 | 4243 | o third |
|
4242 | 4244 | | |
|
4243 | 4245 | o sec |
|
4244 | 4246 | |
|
4245 | 4247 | o merge |
|
4246 | 4248 | |\ |
|
4247 | 4249 | | o new head |
|
4248 | 4250 | | | |
|
4249 | 4251 | o | new branch |
|
4250 | 4252 | |/ |
|
4251 | 4253 | o n |
|
4252 | 4254 | | |
|
4253 | 4255 | o n |
|
4254 | 4256 | | |
|
4255 | 4257 | o |
|
4256 | 4258 | | |
|
4257 | 4259 | o line 1 |
|
4258 | 4260 | line 2 |
|
4259 | 4261 | |
|
4260 | 4262 | Test word error messages for not enough and too many arguments |
|
4261 | 4263 | |
|
4262 | 4264 | $ hg log -Gv -R a --template "{word('0')}" |
|
4263 | 4265 | hg: parse error: word expects two or three arguments, got 1 |
|
4264 | 4266 | [255] |
|
4265 | 4267 | |
|
4266 | 4268 | $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}" |
|
4267 | 4269 | hg: parse error: word expects two or three arguments, got 7 |
|
4268 | 4270 | [255] |
|
4269 | 4271 | |
|
4270 | 4272 | Test word for integer literal |
|
4271 | 4273 | |
|
4272 | 4274 | $ hg log -R a --template "{word(2, desc)}\n" -r0 |
|
4273 | 4275 | line |
|
4274 | 4276 | |
|
4275 | 4277 | Test word for invalid numbers |
|
4276 | 4278 | |
|
4277 | 4279 | $ hg log -Gv -R a --template "{word('a', desc)}" |
|
4278 | 4280 | hg: parse error: word expects an integer index |
|
4279 | 4281 | [255] |
|
4280 | 4282 | |
|
4281 | 4283 | Test word for out of range |
|
4282 | 4284 | |
|
4283 | 4285 | $ hg log -R a --template "{word(10000, desc)}" |
|
4284 | 4286 | $ hg log -R a --template "{word(-10000, desc)}" |
|
4285 | 4287 | |
|
4286 | 4288 | Test indent and not adding to empty lines |
|
4287 | 4289 | |
|
4288 | 4290 | $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a |
|
4289 | 4291 | ----- |
|
4290 | 4292 | > line 1 |
|
4291 | 4293 | >> line 2 |
|
4292 | 4294 | ----- |
|
4293 | 4295 | > other 1 |
|
4294 | 4296 | >> other 2 |
|
4295 | 4297 | |
|
4296 | 4298 | >> other 3 |
|
4297 | 4299 | |
|
4298 | 4300 | Test with non-strings like dates |
|
4299 | 4301 | |
|
4300 | 4302 | $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a |
|
4301 | 4303 | 1200000.00 |
|
4302 | 4304 | 1300000.00 |
|
4303 | 4305 | |
|
4304 | 4306 | Test broken string escapes: |
|
4305 | 4307 | |
|
4306 | 4308 | $ hg log -T "bogus\\" -R a |
|
4307 | 4309 | hg: parse error: trailing \ in string |
|
4308 | 4310 | [255] |
|
4309 | 4311 | $ hg log -T "\\xy" -R a |
|
4310 | 4312 | hg: parse error: invalid \x escape |
|
4311 | 4313 | [255] |
|
4312 | 4314 | |
|
4313 | 4315 | json filter should escape HTML tags so that the output can be embedded in hgweb: |
|
4314 | 4316 | |
|
4315 | 4317 | $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1 |
|
4316 | 4318 | "\u003cfoo@example.org\u003e" |
|
4317 | 4319 | |
|
4318 | 4320 | Templater supports aliases of symbol and func() styles: |
|
4319 | 4321 | |
|
4320 | 4322 | $ hg clone -q a aliases |
|
4321 | 4323 | $ cd aliases |
|
4322 | 4324 | $ cat <<EOF >> .hg/hgrc |
|
4323 | 4325 | > [templatealias] |
|
4324 | 4326 | > r = rev |
|
4325 | 4327 | > rn = "{r}:{node|short}" |
|
4326 | 4328 | > status(c, files) = files % "{c} {file}\n" |
|
4327 | 4329 | > utcdate(d) = localdate(d, "UTC") |
|
4328 | 4330 | > EOF |
|
4329 | 4331 | |
|
4330 | 4332 | $ hg debugtemplate -vr0 '{rn} {utcdate(date)|isodate}\n' |
|
4331 | 4333 | (template |
|
4332 | 4334 | (symbol 'rn') |
|
4333 | 4335 | (string ' ') |
|
4334 | 4336 | (| |
|
4335 | 4337 | (func |
|
4336 | 4338 | (symbol 'utcdate') |
|
4337 | 4339 | (symbol 'date')) |
|
4338 | 4340 | (symbol 'isodate')) |
|
4339 | 4341 | (string '\n')) |
|
4340 | 4342 | * expanded: |
|
4341 | 4343 | (template |
|
4342 | 4344 | (template |
|
4343 | 4345 | (symbol 'rev') |
|
4344 | 4346 | (string ':') |
|
4345 | 4347 | (| |
|
4346 | 4348 | (symbol 'node') |
|
4347 | 4349 | (symbol 'short'))) |
|
4348 | 4350 | (string ' ') |
|
4349 | 4351 | (| |
|
4350 | 4352 | (func |
|
4351 | 4353 | (symbol 'localdate') |
|
4352 | 4354 | (list |
|
4353 | 4355 | (symbol 'date') |
|
4354 | 4356 | (string 'UTC'))) |
|
4355 | 4357 | (symbol 'isodate')) |
|
4356 | 4358 | (string '\n')) |
|
4357 | 4359 | 0:1e4e1b8f71e0 1970-01-12 13:46 +0000 |
|
4358 | 4360 | |
|
4359 | 4361 | $ hg debugtemplate -vr0 '{status("A", file_adds)}' |
|
4360 | 4362 | (template |
|
4361 | 4363 | (func |
|
4362 | 4364 | (symbol 'status') |
|
4363 | 4365 | (list |
|
4364 | 4366 | (string 'A') |
|
4365 | 4367 | (symbol 'file_adds')))) |
|
4366 | 4368 | * expanded: |
|
4367 | 4369 | (template |
|
4368 | 4370 | (% |
|
4369 | 4371 | (symbol 'file_adds') |
|
4370 | 4372 | (template |
|
4371 | 4373 | (string 'A') |
|
4372 | 4374 | (string ' ') |
|
4373 | 4375 | (symbol 'file') |
|
4374 | 4376 | (string '\n')))) |
|
4375 | 4377 | A a |
|
4376 | 4378 | |
|
4377 | 4379 | A unary function alias can be called as a filter: |
|
4378 | 4380 | |
|
4379 | 4381 | $ hg debugtemplate -vr0 '{date|utcdate|isodate}\n' |
|
4380 | 4382 | (template |
|
4381 | 4383 | (| |
|
4382 | 4384 | (| |
|
4383 | 4385 | (symbol 'date') |
|
4384 | 4386 | (symbol 'utcdate')) |
|
4385 | 4387 | (symbol 'isodate')) |
|
4386 | 4388 | (string '\n')) |
|
4387 | 4389 | * expanded: |
|
4388 | 4390 | (template |
|
4389 | 4391 | (| |
|
4390 | 4392 | (func |
|
4391 | 4393 | (symbol 'localdate') |
|
4392 | 4394 | (list |
|
4393 | 4395 | (symbol 'date') |
|
4394 | 4396 | (string 'UTC'))) |
|
4395 | 4397 | (symbol 'isodate')) |
|
4396 | 4398 | (string '\n')) |
|
4397 | 4399 | 1970-01-12 13:46 +0000 |
|
4398 | 4400 | |
|
4399 | 4401 | Aliases should be applied only to command arguments and templates in hgrc. |
|
4400 | 4402 | Otherwise, our stock styles and web templates could be corrupted: |
|
4401 | 4403 | |
|
4402 | 4404 | $ hg log -r0 -T '{rn} {utcdate(date)|isodate}\n' |
|
4403 | 4405 | 0:1e4e1b8f71e0 1970-01-12 13:46 +0000 |
|
4404 | 4406 | |
|
4405 | 4407 | $ hg log -r0 --config ui.logtemplate='"{rn} {utcdate(date)|isodate}\n"' |
|
4406 | 4408 | 0:1e4e1b8f71e0 1970-01-12 13:46 +0000 |
|
4407 | 4409 | |
|
4408 | 4410 | $ cat <<EOF > tmpl |
|
4409 | 4411 | > changeset = 'nothing expanded:{rn}\n' |
|
4410 | 4412 | > EOF |
|
4411 | 4413 | $ hg log -r0 --style ./tmpl |
|
4412 | 4414 | nothing expanded: |
|
4413 | 4415 | |
|
4414 | 4416 | Aliases in formatter: |
|
4415 | 4417 | |
|
4416 | 4418 | $ hg branches -T '{pad(branch, 7)} {rn}\n' |
|
4417 | 4419 | default 6:d41e714fe50d |
|
4418 | 4420 | foo 4:bbe44766e73d |
|
4419 | 4421 | |
|
4420 | 4422 | Aliases should honor HGPLAIN: |
|
4421 | 4423 | |
|
4422 | 4424 | $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n' |
|
4423 | 4425 | nothing expanded: |
|
4424 | 4426 | $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n' |
|
4425 | 4427 | 0:1e4e1b8f71e0 |
|
4426 | 4428 | |
|
4427 | 4429 | Unparsable alias: |
|
4428 | 4430 | |
|
4429 | 4431 | $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}' |
|
4430 | 4432 | (template |
|
4431 | 4433 | (symbol 'bad')) |
|
4432 | 4434 | abort: bad definition of template alias "bad": at 2: not a prefix: end |
|
4433 | 4435 | [255] |
|
4434 | 4436 | $ hg log --config templatealias.bad='x(' -T '{bad}' |
|
4435 | 4437 | abort: bad definition of template alias "bad": at 2: not a prefix: end |
|
4436 | 4438 | [255] |
|
4437 | 4439 | |
|
4438 | 4440 | $ cd .. |
|
4439 | 4441 | |
|
4440 | 4442 | Set up repository for non-ascii encoding tests: |
|
4441 | 4443 | |
|
4442 | 4444 | $ hg init nonascii |
|
4443 | 4445 | $ cd nonascii |
|
4444 | 4446 | $ $PYTHON <<EOF |
|
4445 | 4447 | > open('latin1', 'w').write('\xe9') |
|
4446 | 4448 | > open('utf-8', 'w').write('\xc3\xa9') |
|
4447 | 4449 | > EOF |
|
4448 | 4450 | $ HGENCODING=utf-8 hg branch -q `cat utf-8` |
|
4449 | 4451 | $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8 |
|
4450 | 4452 | |
|
4451 | 4453 | json filter should try round-trip conversion to utf-8: |
|
4452 | 4454 | |
|
4453 | 4455 | $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0 |
|
4454 | 4456 | "\u00e9" |
|
4455 | 4457 | $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0 |
|
4456 | 4458 | "non-ascii branch: \u00e9" |
|
4457 | 4459 | |
|
4458 | 4460 | json filter takes input as utf-8b: |
|
4459 | 4461 | |
|
4460 | 4462 | $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1 |
|
4461 | 4463 | "\u00e9" |
|
4462 | 4464 | $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1 |
|
4463 | 4465 | "\udce9" |
|
4464 | 4466 | |
|
4465 | 4467 | utf8 filter: |
|
4466 | 4468 | |
|
4467 | 4469 | $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0 |
|
4468 | 4470 | round-trip: c3a9 |
|
4469 | 4471 | $ HGENCODING=latin1 hg log -T "decoded: {'`cat latin1`'|utf8|hex}\n" -l1 |
|
4470 | 4472 | decoded: c3a9 |
|
4471 | 4473 | $ HGENCODING=ascii hg log -T "replaced: {'`cat latin1`'|utf8|hex}\n" -l1 |
|
4472 | 4474 | abort: decoding near * (glob) |
|
4473 | 4475 | [255] |
|
4474 | 4476 | $ hg log -T "invalid type: {rev|utf8}\n" -r0 |
|
4475 | 4477 | abort: template filter 'utf8' is not compatible with keyword 'rev' |
|
4476 | 4478 | [255] |
|
4477 | 4479 | |
|
4478 | 4480 | pad width: |
|
4479 | 4481 | |
|
4480 | 4482 | $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n" |
|
4481 | 4483 | \xc3\xa9- (esc) |
|
4482 | 4484 | |
|
4483 | 4485 | $ cd .. |
|
4484 | 4486 | |
|
4485 | 4487 | Test that template function in extension is registered as expected |
|
4486 | 4488 | |
|
4487 | 4489 | $ cd a |
|
4488 | 4490 | |
|
4489 | 4491 | $ cat <<EOF > $TESTTMP/customfunc.py |
|
4490 | 4492 | > from mercurial import registrar |
|
4491 | 4493 | > |
|
4492 | 4494 | > templatefunc = registrar.templatefunc() |
|
4493 | 4495 | > |
|
4494 | 4496 | > @templatefunc('custom()') |
|
4495 | 4497 | > def custom(context, mapping, args): |
|
4496 | 4498 | > return 'custom' |
|
4497 | 4499 | > EOF |
|
4498 | 4500 | $ cat <<EOF > .hg/hgrc |
|
4499 | 4501 | > [extensions] |
|
4500 | 4502 | > customfunc = $TESTTMP/customfunc.py |
|
4501 | 4503 | > EOF |
|
4502 | 4504 | |
|
4503 | 4505 | $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true |
|
4504 | 4506 | custom |
|
4505 | 4507 | |
|
4506 | 4508 | $ cd .. |
|
4507 | 4509 | |
|
4508 | 4510 | Test 'graphwidth' in 'hg log' on various topologies. The key here is that the |
|
4509 | 4511 | printed graphwidths 3, 5, 7, etc. should all line up in their respective |
|
4510 | 4512 | columns. We don't care about other aspects of the graph rendering here. |
|
4511 | 4513 | |
|
4512 | 4514 | $ hg init graphwidth |
|
4513 | 4515 | $ cd graphwidth |
|
4514 | 4516 | |
|
4515 | 4517 | $ wrappabletext="a a a a a a a a a a a a" |
|
4516 | 4518 | |
|
4517 | 4519 | $ printf "first\n" > file |
|
4518 | 4520 | $ hg add file |
|
4519 | 4521 | $ hg commit -m "$wrappabletext" |
|
4520 | 4522 | |
|
4521 | 4523 | $ printf "first\nsecond\n" > file |
|
4522 | 4524 | $ hg commit -m "$wrappabletext" |
|
4523 | 4525 | |
|
4524 | 4526 | $ hg checkout 0 |
|
4525 | 4527 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4526 | 4528 | $ printf "third\nfirst\n" > file |
|
4527 | 4529 | $ hg commit -m "$wrappabletext" |
|
4528 | 4530 | created new head |
|
4529 | 4531 | |
|
4530 | 4532 | $ hg merge |
|
4531 | 4533 | merging file |
|
4532 | 4534 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
4533 | 4535 | (branch merge, don't forget to commit) |
|
4534 | 4536 | |
|
4535 | 4537 | $ hg log --graph -T "{graphwidth}" |
|
4536 | 4538 | @ 3 |
|
4537 | 4539 | | |
|
4538 | 4540 | | @ 5 |
|
4539 | 4541 | |/ |
|
4540 | 4542 | o 3 |
|
4541 | 4543 | |
|
4542 | 4544 | $ hg commit -m "$wrappabletext" |
|
4543 | 4545 | |
|
4544 | 4546 | $ hg log --graph -T "{graphwidth}" |
|
4545 | 4547 | @ 5 |
|
4546 | 4548 | |\ |
|
4547 | 4549 | | o 5 |
|
4548 | 4550 | | | |
|
4549 | 4551 | o | 5 |
|
4550 | 4552 | |/ |
|
4551 | 4553 | o 3 |
|
4552 | 4554 | |
|
4553 | 4555 | |
|
4554 | 4556 | $ hg checkout 0 |
|
4555 | 4557 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4556 | 4558 | $ printf "third\nfirst\nsecond\n" > file |
|
4557 | 4559 | $ hg commit -m "$wrappabletext" |
|
4558 | 4560 | created new head |
|
4559 | 4561 | |
|
4560 | 4562 | $ hg log --graph -T "{graphwidth}" |
|
4561 | 4563 | @ 3 |
|
4562 | 4564 | | |
|
4563 | 4565 | | o 7 |
|
4564 | 4566 | | |\ |
|
4565 | 4567 | +---o 7 |
|
4566 | 4568 | | | |
|
4567 | 4569 | | o 5 |
|
4568 | 4570 | |/ |
|
4569 | 4571 | o 3 |
|
4570 | 4572 | |
|
4571 | 4573 | |
|
4572 | 4574 | $ hg log --graph -T "{graphwidth}" -r 3 |
|
4573 | 4575 | o 5 |
|
4574 | 4576 | |\ |
|
4575 | 4577 | ~ ~ |
|
4576 | 4578 | |
|
4577 | 4579 | $ hg log --graph -T "{graphwidth}" -r 1 |
|
4578 | 4580 | o 3 |
|
4579 | 4581 | | |
|
4580 | 4582 | ~ |
|
4581 | 4583 | |
|
4582 | 4584 | $ hg merge |
|
4583 | 4585 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4584 | 4586 | (branch merge, don't forget to commit) |
|
4585 | 4587 | $ hg commit -m "$wrappabletext" |
|
4586 | 4588 | |
|
4587 | 4589 | $ printf "seventh\n" >> file |
|
4588 | 4590 | $ hg commit -m "$wrappabletext" |
|
4589 | 4591 | |
|
4590 | 4592 | $ hg log --graph -T "{graphwidth}" |
|
4591 | 4593 | @ 3 |
|
4592 | 4594 | | |
|
4593 | 4595 | o 5 |
|
4594 | 4596 | |\ |
|
4595 | 4597 | | o 5 |
|
4596 | 4598 | | | |
|
4597 | 4599 | o | 7 |
|
4598 | 4600 | |\ \ |
|
4599 | 4601 | | o | 7 |
|
4600 | 4602 | | |/ |
|
4601 | 4603 | o / 5 |
|
4602 | 4604 | |/ |
|
4603 | 4605 | o 3 |
|
4604 | 4606 | |
|
4605 | 4607 | |
|
4606 | 4608 | The point of graphwidth is to allow wrapping that accounts for the space taken |
|
4607 | 4609 | by the graph. |
|
4608 | 4610 | |
|
4609 | 4611 | $ COLUMNS=10 hg log --graph -T "{fill(desc, termwidth - graphwidth)}" |
|
4610 | 4612 | @ a a a a |
|
4611 | 4613 | | a a a a |
|
4612 | 4614 | | a a a a |
|
4613 | 4615 | o a a a |
|
4614 | 4616 | |\ a a a |
|
4615 | 4617 | | | a a a |
|
4616 | 4618 | | | a a a |
|
4617 | 4619 | | o a a a |
|
4618 | 4620 | | | a a a |
|
4619 | 4621 | | | a a a |
|
4620 | 4622 | | | a a a |
|
4621 | 4623 | o | a a |
|
4622 | 4624 | |\ \ a a |
|
4623 | 4625 | | | | a a |
|
4624 | 4626 | | | | a a |
|
4625 | 4627 | | | | a a |
|
4626 | 4628 | | | | a a |
|
4627 | 4629 | | o | a a |
|
4628 | 4630 | | |/ a a |
|
4629 | 4631 | | | a a |
|
4630 | 4632 | | | a a |
|
4631 | 4633 | | | a a |
|
4632 | 4634 | | | a a |
|
4633 | 4635 | o | a a a |
|
4634 | 4636 | |/ a a a |
|
4635 | 4637 | | a a a |
|
4636 | 4638 | | a a a |
|
4637 | 4639 | o a a a a |
|
4638 | 4640 | a a a a |
|
4639 | 4641 | a a a a |
|
4640 | 4642 | |
|
4641 | 4643 | Something tricky happens when there are elided nodes; the next drawn row of |
|
4642 | 4644 | edges can be more than one column wider, but the graph width only increases by |
|
4643 | 4645 | one column. The remaining columns are added in between the nodes. |
|
4644 | 4646 | |
|
4645 | 4647 | $ hg log --graph -T "{graphwidth}" -r "0|2|4|5" |
|
4646 | 4648 | o 5 |
|
4647 | 4649 | |\ |
|
4648 | 4650 | | \ |
|
4649 | 4651 | | :\ |
|
4650 | 4652 | o : : 7 |
|
4651 | 4653 | :/ / |
|
4652 | 4654 | : o 5 |
|
4653 | 4655 | :/ |
|
4654 | 4656 | o 3 |
|
4655 | 4657 | |
|
4656 | 4658 | |
|
4657 | 4659 | $ cd .. |
|
4658 | 4660 |
General Comments 0
You need to be logged in to leave comments.
Login now