##// END OF EJS Templates
templater: introduce one-pass parsing of nested template strings...
Yuya Nishihara -
r25783:1f6878c8 default
parent child Browse files
Show More
@@ -1,887 +1,915
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 i18n import _
9 9 import os, re
10 10 import util, config, templatefilters, templatekw, parser, error
11 11 import revset as revsetmod
12 12 import types
13 13 import minirst
14 14
15 15 # template parsing
16 16
17 17 elements = {
18 18 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
19 19 ",": (2, None, ("list", 2)),
20 20 "|": (5, None, ("|", 5)),
21 21 "%": (6, None, ("%", 6)),
22 22 ")": (0, None, None),
23 23 "integer": (0, ("integer",), None),
24 24 "symbol": (0, ("symbol",), None),
25 25 "string": (0, ("template",), None),
26 26 "rawstring": (0, ("rawstring",), None),
27 "template": (0, ("template",), None),
27 28 "end": (0, None, None),
28 29 }
29 30
30 31 def tokenize(program, start, end):
31 32 pos = start
32 33 while pos < end:
33 34 c = program[pos]
34 35 if c.isspace(): # skip inter-token whitespace
35 36 pass
36 37 elif c in "(,)%|": # handle simple operators
37 38 yield (c, None, pos)
39 elif c in '"\'': # handle quoted templates
40 s = pos + 1
41 data, pos = _parsetemplate(program, s, end, c)
42 yield ('template', data, s)
43 pos -= 1
38 44 elif (c in '"\'' or c == 'r' and
39 45 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
40 46 if c == 'r':
41 47 pos += 1
42 48 c = program[pos]
43 49 decode = False
44 50 else:
45 51 decode = True
46 52 pos += 1
47 53 s = pos
48 54 while pos < end: # find closing quote
49 55 d = program[pos]
50 56 if d == '\\': # skip over escaped characters
51 57 pos += 2
52 58 continue
53 59 if d == c:
54 60 if not decode:
55 61 yield ('rawstring', program[s:pos], s)
56 62 break
57 63 yield ('string', program[s:pos], s)
58 64 break
59 65 pos += 1
60 66 else:
61 67 raise error.ParseError(_("unterminated string"), s)
62 68 elif c.isdigit() or c == '-':
63 69 s = pos
64 70 if c == '-': # simply take negate operator as part of integer
65 71 pos += 1
66 72 if pos >= end or not program[pos].isdigit():
67 73 raise error.ParseError(_("integer literal without digits"), s)
68 74 pos += 1
69 75 while pos < end:
70 76 d = program[pos]
71 77 if not d.isdigit():
72 78 break
73 79 pos += 1
74 80 yield ('integer', program[s:pos], s)
75 81 pos -= 1
76 82 elif (c == '\\' and program[pos:pos + 2] in (r"\'", r'\"')
77 83 or c == 'r' and program[pos:pos + 3] in (r"r\'", r'r\"')):
78 84 # handle escaped quoted strings for compatibility with 2.9.2-3.4,
79 85 # where some of nested templates were preprocessed as strings and
80 86 # then compiled. therefore, \"...\" was allowed. (issue4733)
81 87 #
82 88 # processing flow of _evalifliteral() at 5ab28a2e9962:
83 89 # outer template string -> stringify() -> compiletemplate()
84 90 # ------------------------ ------------ ------------------
85 91 # {f("\\\\ {g(\"\\\"\")}"} \\ {g("\"")} [r'\\', {g("\"")}]
86 92 # ~~~~~~~~
87 93 # escaped quoted string
88 94 if c == 'r':
89 95 pos += 1
90 96 token = 'rawstring'
91 97 else:
92 token = 'string'
98 token = 'template'
93 99 quote = program[pos:pos + 2]
94 100 s = pos = pos + 2
95 101 while pos < end: # find closing escaped quote
96 102 if program.startswith('\\\\\\', pos, end):
97 103 pos += 4 # skip over double escaped characters
98 104 continue
99 105 if program.startswith(quote, pos, end):
100 106 try:
101 107 # interpret as if it were a part of an outer string
102 108 data = program[s:pos].decode('string-escape')
103 109 except ValueError: # unbalanced escapes
104 110 raise error.ParseError(_("syntax error"), s)
111 if token == 'template':
112 data = _parsetemplate(data, 0, len(data))[0]
105 113 yield (token, data, s)
106 114 pos += 1
107 115 break
108 116 pos += 1
109 117 else:
110 118 raise error.ParseError(_("unterminated string"), s)
111 119 elif c.isalnum() or c in '_':
112 120 s = pos
113 121 pos += 1
114 122 while pos < end: # find end of symbol
115 123 d = program[pos]
116 124 if not (d.isalnum() or d == "_"):
117 125 break
118 126 pos += 1
119 127 sym = program[s:pos]
120 128 yield ('symbol', sym, s)
121 129 pos -= 1
122 130 elif c == '}':
123 131 yield ('end', None, pos + 1)
124 132 return
125 133 else:
126 134 raise error.ParseError(_("syntax error"), pos)
127 135 pos += 1
128 136 raise error.ParseError(_("unterminated template expansion"), start)
129 137
130 def _parsetemplate(tmpl, start, stop):
138 def _parsetemplate(tmpl, start, stop, quote=''):
139 r"""
140 >>> _parsetemplate('foo{bar}"baz', 0, 12)
141 ([('string', 'foo'), ('symbol', 'bar'), ('string', '"baz')], 12)
142 >>> _parsetemplate('foo{bar}"baz', 0, 12, quote='"')
143 ([('string', 'foo'), ('symbol', 'bar')], 9)
144 >>> _parsetemplate('foo"{bar}', 0, 9, quote='"')
145 ([('string', 'foo')], 4)
146 >>> _parsetemplate(r'foo\"bar"baz', 0, 12, quote='"')
147 ([('string', 'foo"'), ('string', 'bar')], 9)
148 >>> _parsetemplate(r'foo\\"bar', 0, 10, quote='"')
149 ([('string', 'foo\\\\')], 6)
150 """
131 151 parsed = []
152 sepchars = '{' + quote
132 153 pos = start
133 154 p = parser.parser(elements)
134 155 while pos < stop:
135 n = tmpl.find('{', pos, stop)
156 n = min((tmpl.find(c, pos, stop) for c in sepchars),
157 key=lambda n: (n < 0, n))
136 158 if n < 0:
137 159 parsed.append(('string', tmpl[pos:stop]))
138 160 pos = stop
139 161 break
162 c = tmpl[n]
140 163 bs = (n - pos) - len(tmpl[pos:n].rstrip('\\'))
141 164 if bs % 2 == 1:
142 165 # escaped (e.g. '\{', '\\\{', but not '\\{')
143 parsed.append(('string', (tmpl[pos:n - 1] + "{")))
166 parsed.append(('string', (tmpl[pos:n - 1] + c)))
144 167 pos = n + 1
145 168 continue
146 169 if n > pos:
147 170 parsed.append(('string', tmpl[pos:n]))
171 if c == quote:
172 return parsed, n + 1
148 173
149 174 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop))
150 175 parsed.append(parseres)
176
177 if quote:
178 raise error.ParseError(_("unterminated string"), start)
151 179 return parsed, pos
152 180
153 181 def compiletemplate(tmpl, context):
154 182 parsed, pos = _parsetemplate(tmpl, 0, len(tmpl))
155 183 return [compileexp(e, context, methods) for e in parsed]
156 184
157 185 def compileexp(exp, context, curmethods):
158 186 t = exp[0]
159 187 if t in curmethods:
160 188 return curmethods[t](exp, context)
161 189 raise error.ParseError(_("unknown method '%s'") % t)
162 190
163 191 # template evaluation
164 192
165 193 def getsymbol(exp):
166 194 if exp[0] == 'symbol':
167 195 return exp[1]
168 196 raise error.ParseError(_("expected a symbol, got '%s'") % exp[0])
169 197
170 198 def getlist(x):
171 199 if not x:
172 200 return []
173 201 if x[0] == 'list':
174 202 return getlist(x[1]) + [x[2]]
175 203 return [x]
176 204
177 205 def getfilter(exp, context):
178 206 f = getsymbol(exp)
179 207 if f not in context._filters:
180 208 raise error.ParseError(_("unknown function '%s'") % f)
181 209 return context._filters[f]
182 210
183 211 def gettemplate(exp, context):
184 212 if exp[0] == 'template':
185 return compiletemplate(exp[1], context)
213 return [compileexp(e, context, methods) for e in exp[1]]
186 214 if exp[0] == 'symbol':
187 215 # unlike runsymbol(), here 'symbol' is always taken as template name
188 216 # even if it exists in mapping. this allows us to override mapping
189 217 # by web templates, e.g. 'changelogtag' is redefined in map file.
190 218 return context._load(exp[1])
191 219 raise error.ParseError(_("expected template specifier"))
192 220
193 221 def runinteger(context, mapping, data):
194 222 return int(data)
195 223
196 224 def runstring(context, mapping, data):
197 225 return data.decode("string-escape")
198 226
199 227 def runrawstring(context, mapping, data):
200 228 return data
201 229
202 230 def runsymbol(context, mapping, key):
203 231 v = mapping.get(key)
204 232 if v is None:
205 233 v = context._defaults.get(key)
206 234 if v is None:
207 235 try:
208 236 v = context.process(key, mapping)
209 237 except TemplateNotFound:
210 238 v = ''
211 239 if callable(v):
212 240 return v(**mapping)
213 241 if isinstance(v, types.GeneratorType):
214 242 v = list(v)
215 243 return v
216 244
217 245 def buildtemplate(exp, context):
218 ctmpl = compiletemplate(exp[1], context)
246 ctmpl = [compileexp(e, context, methods) for e in exp[1]]
219 247 if len(ctmpl) == 1:
220 248 return ctmpl[0] # fast path for string with no template fragment
221 249 return (runtemplate, ctmpl)
222 250
223 251 def runtemplate(context, mapping, template):
224 252 for func, data in template:
225 253 yield func(context, mapping, data)
226 254
227 255 def buildfilter(exp, context):
228 256 func, data = compileexp(exp[1], context, methods)
229 257 filt = getfilter(exp[2], context)
230 258 return (runfilter, (func, data, filt))
231 259
232 260 def runfilter(context, mapping, data):
233 261 func, data, filt = data
234 262 # func() may return string, generator of strings or arbitrary object such
235 263 # as date tuple, but filter does not want generator.
236 264 thing = func(context, mapping, data)
237 265 if isinstance(thing, types.GeneratorType):
238 266 thing = stringify(thing)
239 267 try:
240 268 return filt(thing)
241 269 except (ValueError, AttributeError, TypeError):
242 270 if isinstance(data, tuple):
243 271 dt = data[1]
244 272 else:
245 273 dt = data
246 274 raise util.Abort(_("template filter '%s' is not compatible with "
247 275 "keyword '%s'") % (filt.func_name, dt))
248 276
249 277 def buildmap(exp, context):
250 278 func, data = compileexp(exp[1], context, methods)
251 279 ctmpl = gettemplate(exp[2], context)
252 280 return (runmap, (func, data, ctmpl))
253 281
254 282 def runmap(context, mapping, data):
255 283 func, data, ctmpl = data
256 284 d = func(context, mapping, data)
257 285 if callable(d):
258 286 d = d()
259 287
260 288 lm = mapping.copy()
261 289
262 290 for i in d:
263 291 if isinstance(i, dict):
264 292 lm.update(i)
265 293 lm['originalnode'] = mapping.get('node')
266 294 yield runtemplate(context, lm, ctmpl)
267 295 else:
268 296 # v is not an iterable of dicts, this happen when 'key'
269 297 # has been fully expanded already and format is useless.
270 298 # If so, return the expanded value.
271 299 yield i
272 300
273 301 def buildfunc(exp, context):
274 302 n = getsymbol(exp[1])
275 303 args = [compileexp(x, context, exprmethods) for x in getlist(exp[2])]
276 304 if n in funcs:
277 305 f = funcs[n]
278 306 return (f, args)
279 307 if n in context._filters:
280 308 if len(args) != 1:
281 309 raise error.ParseError(_("filter %s expects one argument") % n)
282 310 f = context._filters[n]
283 311 return (runfilter, (args[0][0], args[0][1], f))
284 312 raise error.ParseError(_("unknown function '%s'") % n)
285 313
286 314 def date(context, mapping, args):
287 315 """:date(date[, fmt]): Format a date. See :hg:`help dates` for formatting
288 316 strings."""
289 317 if not (1 <= len(args) <= 2):
290 318 # i18n: "date" is a keyword
291 319 raise error.ParseError(_("date expects one or two arguments"))
292 320
293 321 date = args[0][0](context, mapping, args[0][1])
294 322 fmt = None
295 323 if len(args) == 2:
296 324 fmt = stringify(args[1][0](context, mapping, args[1][1]))
297 325 try:
298 326 if fmt is None:
299 327 return util.datestr(date)
300 328 else:
301 329 return util.datestr(date, fmt)
302 330 except (TypeError, ValueError):
303 331 # i18n: "date" is a keyword
304 332 raise error.ParseError(_("date expects a date information"))
305 333
306 334 def diff(context, mapping, args):
307 335 """:diff([includepattern [, excludepattern]]): Show a diff, optionally
308 336 specifying files to include or exclude."""
309 337 if len(args) > 2:
310 338 # i18n: "diff" is a keyword
311 339 raise error.ParseError(_("diff expects one, two or no arguments"))
312 340
313 341 def getpatterns(i):
314 342 if i < len(args):
315 343 s = stringify(args[i][0](context, mapping, args[i][1])).strip()
316 344 if s:
317 345 return [s]
318 346 return []
319 347
320 348 ctx = mapping['ctx']
321 349 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1)))
322 350
323 351 return ''.join(chunks)
324 352
325 353 def fill(context, mapping, args):
326 354 """:fill(text[, width[, initialident[, hangindent]]]): Fill many
327 355 paragraphs with optional indentation. See the "fill" filter."""
328 356 if not (1 <= len(args) <= 4):
329 357 # i18n: "fill" is a keyword
330 358 raise error.ParseError(_("fill expects one to four arguments"))
331 359
332 360 text = stringify(args[0][0](context, mapping, args[0][1]))
333 361 width = 76
334 362 initindent = ''
335 363 hangindent = ''
336 364 if 2 <= len(args) <= 4:
337 365 try:
338 366 width = int(stringify(args[1][0](context, mapping, args[1][1])))
339 367 except ValueError:
340 368 # i18n: "fill" is a keyword
341 369 raise error.ParseError(_("fill expects an integer width"))
342 370 try:
343 371 initindent = stringify(args[2][0](context, mapping, args[2][1]))
344 372 hangindent = stringify(args[3][0](context, mapping, args[3][1]))
345 373 except IndexError:
346 374 pass
347 375
348 376 return templatefilters.fill(text, width, initindent, hangindent)
349 377
350 378 def pad(context, mapping, args):
351 379 """:pad(text, width[, fillchar=' '[, right=False]]): Pad text with a
352 380 fill character."""
353 381 if not (2 <= len(args) <= 4):
354 382 # i18n: "pad" is a keyword
355 383 raise error.ParseError(_("pad() expects two to four arguments"))
356 384
357 385 width = int(args[1][1])
358 386
359 387 text = stringify(args[0][0](context, mapping, args[0][1]))
360 388
361 389 right = False
362 390 fillchar = ' '
363 391 if len(args) > 2:
364 392 fillchar = stringify(args[2][0](context, mapping, args[2][1]))
365 393 if len(args) > 3:
366 394 right = util.parsebool(args[3][1])
367 395
368 396 if right:
369 397 return text.rjust(width, fillchar)
370 398 else:
371 399 return text.ljust(width, fillchar)
372 400
373 401 def indent(context, mapping, args):
374 402 """:indent(text, indentchars[, firstline]): Indents all non-empty lines
375 403 with the characters given in the indentchars string. An optional
376 404 third parameter will override the indent for the first line only
377 405 if present."""
378 406 if not (2 <= len(args) <= 3):
379 407 # i18n: "indent" is a keyword
380 408 raise error.ParseError(_("indent() expects two or three arguments"))
381 409
382 410 text = stringify(args[0][0](context, mapping, args[0][1]))
383 411 indent = stringify(args[1][0](context, mapping, args[1][1]))
384 412
385 413 if len(args) == 3:
386 414 firstline = stringify(args[2][0](context, mapping, args[2][1]))
387 415 else:
388 416 firstline = indent
389 417
390 418 # the indent function doesn't indent the first line, so we do it here
391 419 return templatefilters.indent(firstline + text, indent)
392 420
393 421 def get(context, mapping, args):
394 422 """:get(dict, key): Get an attribute/key from an object. Some keywords
395 423 are complex types. This function allows you to obtain the value of an
396 424 attribute on these type."""
397 425 if len(args) != 2:
398 426 # i18n: "get" is a keyword
399 427 raise error.ParseError(_("get() expects two arguments"))
400 428
401 429 dictarg = args[0][0](context, mapping, args[0][1])
402 430 if not util.safehasattr(dictarg, 'get'):
403 431 # i18n: "get" is a keyword
404 432 raise error.ParseError(_("get() expects a dict as first argument"))
405 433
406 434 key = args[1][0](context, mapping, args[1][1])
407 435 yield dictarg.get(key)
408 436
409 437 def if_(context, mapping, args):
410 438 """:if(expr, then[, else]): Conditionally execute based on the result of
411 439 an expression."""
412 440 if not (2 <= len(args) <= 3):
413 441 # i18n: "if" is a keyword
414 442 raise error.ParseError(_("if expects two or three arguments"))
415 443
416 444 test = stringify(args[0][0](context, mapping, args[0][1]))
417 445 if test:
418 446 yield args[1][0](context, mapping, args[1][1])
419 447 elif len(args) == 3:
420 448 yield args[2][0](context, mapping, args[2][1])
421 449
422 450 def ifcontains(context, mapping, args):
423 451 """:ifcontains(search, thing, then[, else]): Conditionally execute based
424 452 on whether the item "search" is in "thing"."""
425 453 if not (3 <= len(args) <= 4):
426 454 # i18n: "ifcontains" is a keyword
427 455 raise error.ParseError(_("ifcontains expects three or four arguments"))
428 456
429 457 item = stringify(args[0][0](context, mapping, args[0][1]))
430 458 items = args[1][0](context, mapping, args[1][1])
431 459
432 460 if item in items:
433 461 yield args[2][0](context, mapping, args[2][1])
434 462 elif len(args) == 4:
435 463 yield args[3][0](context, mapping, args[3][1])
436 464
437 465 def ifeq(context, mapping, args):
438 466 """:ifeq(expr1, expr2, then[, else]): Conditionally execute based on
439 467 whether 2 items are equivalent."""
440 468 if not (3 <= len(args) <= 4):
441 469 # i18n: "ifeq" is a keyword
442 470 raise error.ParseError(_("ifeq expects three or four arguments"))
443 471
444 472 test = stringify(args[0][0](context, mapping, args[0][1]))
445 473 match = stringify(args[1][0](context, mapping, args[1][1]))
446 474 if test == match:
447 475 yield args[2][0](context, mapping, args[2][1])
448 476 elif len(args) == 4:
449 477 yield args[3][0](context, mapping, args[3][1])
450 478
451 479 def join(context, mapping, args):
452 480 """:join(list, sep): Join items in a list with a delimiter."""
453 481 if not (1 <= len(args) <= 2):
454 482 # i18n: "join" is a keyword
455 483 raise error.ParseError(_("join expects one or two arguments"))
456 484
457 485 joinset = args[0][0](context, mapping, args[0][1])
458 486 if callable(joinset):
459 487 jf = joinset.joinfmt
460 488 joinset = [jf(x) for x in joinset()]
461 489
462 490 joiner = " "
463 491 if len(args) > 1:
464 492 joiner = stringify(args[1][0](context, mapping, args[1][1]))
465 493
466 494 first = True
467 495 for x in joinset:
468 496 if first:
469 497 first = False
470 498 else:
471 499 yield joiner
472 500 yield x
473 501
474 502 def label(context, mapping, args):
475 503 """:label(label, expr): Apply a label to generated content. Content with
476 504 a label applied can result in additional post-processing, such as
477 505 automatic colorization."""
478 506 if len(args) != 2:
479 507 # i18n: "label" is a keyword
480 508 raise error.ParseError(_("label expects two arguments"))
481 509
482 510 # ignore args[0] (the label string) since this is supposed to be a a no-op
483 511 yield args[1][0](context, mapping, args[1][1])
484 512
485 513 def revset(context, mapping, args):
486 514 """:revset(query[, formatargs...]): Execute a revision set query. See
487 515 :hg:`help revset`."""
488 516 if not len(args) > 0:
489 517 # i18n: "revset" is a keyword
490 518 raise error.ParseError(_("revset expects one or more arguments"))
491 519
492 520 raw = stringify(args[0][0](context, mapping, args[0][1]))
493 521 ctx = mapping['ctx']
494 522 repo = ctx.repo()
495 523
496 524 def query(expr):
497 525 m = revsetmod.match(repo.ui, expr)
498 526 return m(repo)
499 527
500 528 if len(args) > 1:
501 529 formatargs = list([a[0](context, mapping, a[1]) for a in args[1:]])
502 530 revs = query(revsetmod.formatspec(raw, *formatargs))
503 531 revs = list([str(r) for r in revs])
504 532 else:
505 533 revsetcache = mapping['cache'].setdefault("revsetcache", {})
506 534 if raw in revsetcache:
507 535 revs = revsetcache[raw]
508 536 else:
509 537 revs = query(raw)
510 538 revs = list([str(r) for r in revs])
511 539 revsetcache[raw] = revs
512 540
513 541 return templatekw.showlist("revision", revs, **mapping)
514 542
515 543 def rstdoc(context, mapping, args):
516 544 """:rstdoc(text, style): Format ReStructuredText."""
517 545 if len(args) != 2:
518 546 # i18n: "rstdoc" is a keyword
519 547 raise error.ParseError(_("rstdoc expects two arguments"))
520 548
521 549 text = stringify(args[0][0](context, mapping, args[0][1]))
522 550 style = stringify(args[1][0](context, mapping, args[1][1]))
523 551
524 552 return minirst.format(text, style=style, keep=['verbose'])
525 553
526 554 def shortest(context, mapping, args):
527 555 """:shortest(node, minlength=4): Obtain the shortest representation of
528 556 a node."""
529 557 if not (1 <= len(args) <= 2):
530 558 # i18n: "shortest" is a keyword
531 559 raise error.ParseError(_("shortest() expects one or two arguments"))
532 560
533 561 node = stringify(args[0][0](context, mapping, args[0][1]))
534 562
535 563 minlength = 4
536 564 if len(args) > 1:
537 565 minlength = int(args[1][1])
538 566
539 567 cl = mapping['ctx']._repo.changelog
540 568 def isvalid(test):
541 569 try:
542 570 try:
543 571 cl.index.partialmatch(test)
544 572 except AttributeError:
545 573 # Pure mercurial doesn't support partialmatch on the index.
546 574 # Fallback to the slow way.
547 575 if cl._partialmatch(test) is None:
548 576 return False
549 577
550 578 try:
551 579 i = int(test)
552 580 # if we are a pure int, then starting with zero will not be
553 581 # confused as a rev; or, obviously, if the int is larger than
554 582 # the value of the tip rev
555 583 if test[0] == '0' or i > len(cl):
556 584 return True
557 585 return False
558 586 except ValueError:
559 587 return True
560 588 except error.RevlogError:
561 589 return False
562 590
563 591 shortest = node
564 592 startlength = max(6, minlength)
565 593 length = startlength
566 594 while True:
567 595 test = node[:length]
568 596 if isvalid(test):
569 597 shortest = test
570 598 if length == minlength or length > startlength:
571 599 return shortest
572 600 length -= 1
573 601 else:
574 602 length += 1
575 603 if len(shortest) <= length:
576 604 return shortest
577 605
578 606 def strip(context, mapping, args):
579 607 """:strip(text[, chars]): Strip characters from a string."""
580 608 if not (1 <= len(args) <= 2):
581 609 # i18n: "strip" is a keyword
582 610 raise error.ParseError(_("strip expects one or two arguments"))
583 611
584 612 text = stringify(args[0][0](context, mapping, args[0][1]))
585 613 if len(args) == 2:
586 614 chars = stringify(args[1][0](context, mapping, args[1][1]))
587 615 return text.strip(chars)
588 616 return text.strip()
589 617
590 618 def sub(context, mapping, args):
591 619 """:sub(pattern, replacement, expression): Perform text substitution
592 620 using regular expressions."""
593 621 if len(args) != 3:
594 622 # i18n: "sub" is a keyword
595 623 raise error.ParseError(_("sub expects three arguments"))
596 624
597 625 pat = stringify(args[0][0](context, mapping, args[0][1]))
598 626 rpl = stringify(args[1][0](context, mapping, args[1][1]))
599 627 src = stringify(args[2][0](context, mapping, args[2][1]))
600 628 yield re.sub(pat, rpl, src)
601 629
602 630 def startswith(context, mapping, args):
603 631 """:startswith(pattern, text): Returns the value from the "text" argument
604 632 if it begins with the content from the "pattern" argument."""
605 633 if len(args) != 2:
606 634 # i18n: "startswith" is a keyword
607 635 raise error.ParseError(_("startswith expects two arguments"))
608 636
609 637 patn = stringify(args[0][0](context, mapping, args[0][1]))
610 638 text = stringify(args[1][0](context, mapping, args[1][1]))
611 639 if text.startswith(patn):
612 640 return text
613 641 return ''
614 642
615 643
616 644 def word(context, mapping, args):
617 645 """:word(number, text[, separator]): Return the nth word from a string."""
618 646 if not (2 <= len(args) <= 3):
619 647 # i18n: "word" is a keyword
620 648 raise error.ParseError(_("word expects two or three arguments, got %d")
621 649 % len(args))
622 650
623 651 try:
624 652 num = int(stringify(args[0][0](context, mapping, args[0][1])))
625 653 except ValueError:
626 654 # i18n: "word" is a keyword
627 655 raise error.ParseError(_("word expects an integer index"))
628 656 text = stringify(args[1][0](context, mapping, args[1][1]))
629 657 if len(args) == 3:
630 658 splitter = stringify(args[2][0](context, mapping, args[2][1]))
631 659 else:
632 660 splitter = None
633 661
634 662 tokens = text.split(splitter)
635 663 if num >= len(tokens):
636 664 return ''
637 665 else:
638 666 return tokens[num]
639 667
640 668 # methods to interpret function arguments or inner expressions (e.g. {_(x)})
641 669 exprmethods = {
642 670 "integer": lambda e, c: (runinteger, e[1]),
643 671 "string": lambda e, c: (runstring, e[1]),
644 672 "rawstring": lambda e, c: (runrawstring, e[1]),
645 673 "symbol": lambda e, c: (runsymbol, e[1]),
646 674 "template": buildtemplate,
647 675 "group": lambda e, c: compileexp(e[1], c, exprmethods),
648 676 # ".": buildmember,
649 677 "|": buildfilter,
650 678 "%": buildmap,
651 679 "func": buildfunc,
652 680 }
653 681
654 682 # methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"})
655 683 methods = exprmethods.copy()
656 684 methods["integer"] = exprmethods["symbol"] # '{1}' as variable
657 685
658 686 funcs = {
659 687 "date": date,
660 688 "diff": diff,
661 689 "fill": fill,
662 690 "get": get,
663 691 "if": if_,
664 692 "ifcontains": ifcontains,
665 693 "ifeq": ifeq,
666 694 "indent": indent,
667 695 "join": join,
668 696 "label": label,
669 697 "pad": pad,
670 698 "revset": revset,
671 699 "rstdoc": rstdoc,
672 700 "shortest": shortest,
673 701 "startswith": startswith,
674 702 "strip": strip,
675 703 "sub": sub,
676 704 "word": word,
677 705 }
678 706
679 707 # template engine
680 708
681 709 stringify = templatefilters.stringify
682 710
683 711 def _flatten(thing):
684 712 '''yield a single stream from a possibly nested set of iterators'''
685 713 if isinstance(thing, str):
686 714 yield thing
687 715 elif not util.safehasattr(thing, '__iter__'):
688 716 if thing is not None:
689 717 yield str(thing)
690 718 else:
691 719 for i in thing:
692 720 if isinstance(i, str):
693 721 yield i
694 722 elif not util.safehasattr(i, '__iter__'):
695 723 if i is not None:
696 724 yield str(i)
697 725 elif i is not None:
698 726 for j in _flatten(i):
699 727 yield j
700 728
701 729 def unquotestring(s):
702 730 '''unwrap quotes'''
703 731 if len(s) < 2 or s[0] != s[-1]:
704 732 raise SyntaxError(_('unmatched quotes'))
705 733 return s[1:-1]
706 734
707 735 class engine(object):
708 736 '''template expansion engine.
709 737
710 738 template expansion works like this. a map file contains key=value
711 739 pairs. if value is quoted, it is treated as string. otherwise, it
712 740 is treated as name of template file.
713 741
714 742 templater is asked to expand a key in map. it looks up key, and
715 743 looks for strings like this: {foo}. it expands {foo} by looking up
716 744 foo in map, and substituting it. expansion is recursive: it stops
717 745 when there is no more {foo} to replace.
718 746
719 747 expansion also allows formatting and filtering.
720 748
721 749 format uses key to expand each item in list. syntax is
722 750 {key%format}.
723 751
724 752 filter uses function to transform value. syntax is
725 753 {key|filter1|filter2|...}.'''
726 754
727 755 def __init__(self, loader, filters={}, defaults={}):
728 756 self._loader = loader
729 757 self._filters = filters
730 758 self._defaults = defaults
731 759 self._cache = {}
732 760
733 761 def _load(self, t):
734 762 '''load, parse, and cache a template'''
735 763 if t not in self._cache:
736 764 self._cache[t] = compiletemplate(self._loader(t), self)
737 765 return self._cache[t]
738 766
739 767 def process(self, t, mapping):
740 768 '''Perform expansion. t is name of map element to expand.
741 769 mapping contains added elements for use during expansion. Is a
742 770 generator.'''
743 771 return _flatten(runtemplate(self, mapping, self._load(t)))
744 772
745 773 engines = {'default': engine}
746 774
747 775 def stylelist():
748 776 paths = templatepaths()
749 777 if not paths:
750 778 return _('no templates found, try `hg debuginstall` for more info')
751 779 dirlist = os.listdir(paths[0])
752 780 stylelist = []
753 781 for file in dirlist:
754 782 split = file.split(".")
755 783 if split[0] == "map-cmdline":
756 784 stylelist.append(split[1])
757 785 return ", ".join(sorted(stylelist))
758 786
759 787 class TemplateNotFound(util.Abort):
760 788 pass
761 789
762 790 class templater(object):
763 791
764 792 def __init__(self, mapfile, filters={}, defaults={}, cache={},
765 793 minchunk=1024, maxchunk=65536):
766 794 '''set up template engine.
767 795 mapfile is name of file to read map definitions from.
768 796 filters is dict of functions. each transforms a value into another.
769 797 defaults is dict of default map definitions.'''
770 798 self.mapfile = mapfile or 'template'
771 799 self.cache = cache.copy()
772 800 self.map = {}
773 801 if mapfile:
774 802 self.base = os.path.dirname(mapfile)
775 803 else:
776 804 self.base = ''
777 805 self.filters = templatefilters.filters.copy()
778 806 self.filters.update(filters)
779 807 self.defaults = defaults
780 808 self.minchunk, self.maxchunk = minchunk, maxchunk
781 809 self.ecache = {}
782 810
783 811 if not mapfile:
784 812 return
785 813 if not os.path.exists(mapfile):
786 814 raise util.Abort(_("style '%s' not found") % mapfile,
787 815 hint=_("available styles: %s") % stylelist())
788 816
789 817 conf = config.config(includepaths=templatepaths())
790 818 conf.read(mapfile)
791 819
792 820 for key, val in conf[''].items():
793 821 if not val:
794 822 raise SyntaxError(_('%s: missing value') % conf.source('', key))
795 823 if val[0] in "'\"":
796 824 try:
797 825 self.cache[key] = unquotestring(val)
798 826 except SyntaxError as inst:
799 827 raise SyntaxError('%s: %s' %
800 828 (conf.source('', key), inst.args[0]))
801 829 else:
802 830 val = 'default', val
803 831 if ':' in val[1]:
804 832 val = val[1].split(':', 1)
805 833 self.map[key] = val[0], os.path.join(self.base, val[1])
806 834
807 835 def __contains__(self, key):
808 836 return key in self.cache or key in self.map
809 837
810 838 def load(self, t):
811 839 '''Get the template for the given template name. Use a local cache.'''
812 840 if t not in self.cache:
813 841 try:
814 842 self.cache[t] = util.readfile(self.map[t][1])
815 843 except KeyError as inst:
816 844 raise TemplateNotFound(_('"%s" not in template map') %
817 845 inst.args[0])
818 846 except IOError as inst:
819 847 raise IOError(inst.args[0], _('template file %s: %s') %
820 848 (self.map[t][1], inst.args[1]))
821 849 return self.cache[t]
822 850
823 851 def __call__(self, t, **mapping):
824 852 ttype = t in self.map and self.map[t][0] or 'default'
825 853 if ttype not in self.ecache:
826 854 self.ecache[ttype] = engines[ttype](self.load,
827 855 self.filters, self.defaults)
828 856 proc = self.ecache[ttype]
829 857
830 858 stream = proc.process(t, mapping)
831 859 if self.minchunk:
832 860 stream = util.increasingchunks(stream, min=self.minchunk,
833 861 max=self.maxchunk)
834 862 return stream
835 863
836 864 def templatepaths():
837 865 '''return locations used for template files.'''
838 866 pathsrel = ['templates']
839 867 paths = [os.path.normpath(os.path.join(util.datapath, f))
840 868 for f in pathsrel]
841 869 return [p for p in paths if os.path.isdir(p)]
842 870
843 871 def templatepath(name):
844 872 '''return location of template file. returns None if not found.'''
845 873 for p in templatepaths():
846 874 f = os.path.join(p, name)
847 875 if os.path.exists(f):
848 876 return f
849 877 return None
850 878
851 879 def stylemap(styles, paths=None):
852 880 """Return path to mapfile for a given style.
853 881
854 882 Searches mapfile in the following locations:
855 883 1. templatepath/style/map
856 884 2. templatepath/map-style
857 885 3. templatepath/map
858 886 """
859 887
860 888 if paths is None:
861 889 paths = templatepaths()
862 890 elif isinstance(paths, str):
863 891 paths = [paths]
864 892
865 893 if isinstance(styles, str):
866 894 styles = [styles]
867 895
868 896 for style in styles:
869 897 # only plain name is allowed to honor template paths
870 898 if (not style
871 899 or style in (os.curdir, os.pardir)
872 900 or os.sep in style
873 901 or os.altsep and os.altsep in style):
874 902 continue
875 903 locations = [os.path.join(style, 'map'), 'map-' + style]
876 904 locations.append('map')
877 905
878 906 for path in paths:
879 907 for location in locations:
880 908 mapfile = os.path.join(path, location)
881 909 if os.path.isfile(mapfile):
882 910 return style, mapfile
883 911
884 912 raise RuntimeError("No hgweb templates found in %r" % paths)
885 913
886 914 # tell hggettext to extract docstrings from these functions:
887 915 i18nfunctions = funcs.values()
@@ -1,3409 +1,3427
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 Second branch starting at nullrev:
33 33
34 34 $ hg update null
35 35 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
36 36 $ echo second > second
37 37 $ hg add second
38 38 $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
39 39 created new head
40 40
41 41 $ echo third > third
42 42 $ hg add third
43 43 $ hg mv second fourth
44 44 $ hg commit -m third -d "2020-01-01 10:01"
45 45
46 46 $ hg log --template '{join(file_copies, ",\n")}\n' -r .
47 47 fourth (second)
48 48 $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r .
49 49 second -> fourth
50 50 $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7
51 51 8 t
52 52 7 f
53 53
54 54 Working-directory revision has special identifiers, though they are still
55 55 experimental:
56 56
57 57 $ hg log -r 'wdir()' -T '{rev}:{node}\n'
58 58 2147483647:ffffffffffffffffffffffffffffffffffffffff
59 59
60 60 Some keywords are invalid for working-directory revision, but they should
61 61 never cause crash:
62 62
63 63 $ hg log -r 'wdir()' -T '{manifest}\n'
64 64
65 65
66 66 Quoting for ui.logtemplate
67 67
68 68 $ hg tip --config "ui.logtemplate={rev}\n"
69 69 8
70 70 $ hg tip --config "ui.logtemplate='{rev}\n'"
71 71 8
72 72 $ hg tip --config 'ui.logtemplate="{rev}\n"'
73 73 8
74 74
75 75 Make sure user/global hgrc does not affect tests
76 76
77 77 $ echo '[ui]' > .hg/hgrc
78 78 $ echo 'logtemplate =' >> .hg/hgrc
79 79 $ echo 'style =' >> .hg/hgrc
80 80
81 81 Add some simple styles to settings
82 82
83 83 $ echo '[templates]' >> .hg/hgrc
84 84 $ printf 'simple = "{rev}\\n"\n' >> .hg/hgrc
85 85 $ printf 'simple2 = {rev}\\n\n' >> .hg/hgrc
86 86
87 87 $ hg log -l1 -Tsimple
88 88 8
89 89 $ hg log -l1 -Tsimple2
90 90 8
91 91
92 92 Test templates and style maps in files:
93 93
94 94 $ echo "{rev}" > tmpl
95 95 $ hg log -l1 -T./tmpl
96 96 8
97 97 $ hg log -l1 -Tblah/blah
98 98 blah/blah (no-eol)
99 99
100 100 $ printf 'changeset = "{rev}\\n"\n' > map-simple
101 101 $ hg log -l1 -T./map-simple
102 102 8
103 103
104 104 Template should precede style option
105 105
106 106 $ hg log -l1 --style default -T '{rev}\n'
107 107 8
108 108
109 109 Add a commit with empty description, to ensure that the templates
110 110 below will omit the description line.
111 111
112 112 $ echo c >> c
113 113 $ hg add c
114 114 $ hg commit -qm ' '
115 115
116 116 Default style is like normal output. Phases style should be the same
117 117 as default style, except for extra phase lines.
118 118
119 119 $ hg log > log.out
120 120 $ hg log --style default > style.out
121 121 $ cmp log.out style.out || diff -u log.out style.out
122 122 $ hg log -T phases > phases.out
123 123 $ diff -U 0 log.out phases.out | grep -v '^---\|^+++'
124 124 @@ -2,0 +3 @@
125 125 +phase: draft
126 126 @@ -6,0 +8 @@
127 127 +phase: draft
128 128 @@ -11,0 +14 @@
129 129 +phase: draft
130 130 @@ -17,0 +21 @@
131 131 +phase: draft
132 132 @@ -24,0 +29 @@
133 133 +phase: draft
134 134 @@ -31,0 +37 @@
135 135 +phase: draft
136 136 @@ -36,0 +43 @@
137 137 +phase: draft
138 138 @@ -41,0 +49 @@
139 139 +phase: draft
140 140 @@ -46,0 +55 @@
141 141 +phase: draft
142 142 @@ -51,0 +61 @@
143 143 +phase: draft
144 144
145 145 $ hg log -v > log.out
146 146 $ hg log -v --style default > style.out
147 147 $ cmp log.out style.out || diff -u log.out style.out
148 148 $ hg log -v -T phases > phases.out
149 149 $ diff -U 0 log.out phases.out | grep -v '^---\|^+++'
150 150 @@ -2,0 +3 @@
151 151 +phase: draft
152 152 @@ -7,0 +9 @@
153 153 +phase: draft
154 154 @@ -15,0 +18 @@
155 155 +phase: draft
156 156 @@ -24,0 +28 @@
157 157 +phase: draft
158 158 @@ -33,0 +38 @@
159 159 +phase: draft
160 160 @@ -43,0 +49 @@
161 161 +phase: draft
162 162 @@ -50,0 +57 @@
163 163 +phase: draft
164 164 @@ -58,0 +66 @@
165 165 +phase: draft
166 166 @@ -66,0 +75 @@
167 167 +phase: draft
168 168 @@ -77,0 +87 @@
169 169 +phase: draft
170 170
171 171 $ hg log -q > log.out
172 172 $ hg log -q --style default > style.out
173 173 $ cmp log.out style.out || diff -u log.out style.out
174 174 $ hg log -q -T phases > phases.out
175 175 $ cmp log.out phases.out || diff -u log.out phases.out
176 176
177 177 $ hg log --debug > log.out
178 178 $ hg log --debug --style default > style.out
179 179 $ cmp log.out style.out || diff -u log.out style.out
180 180 $ hg log --debug -T phases > phases.out
181 181 $ cmp log.out phases.out || diff -u log.out phases.out
182 182
183 183 Default style of working-directory revision should also be the same (but
184 184 date may change while running tests):
185 185
186 186 $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out
187 187 $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out
188 188 $ cmp log.out style.out || diff -u log.out style.out
189 189
190 190 $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out
191 191 $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out
192 192 $ cmp log.out style.out || diff -u log.out style.out
193 193
194 194 $ hg log -r 'wdir()' -q > log.out
195 195 $ hg log -r 'wdir()' -q --style default > style.out
196 196 $ cmp log.out style.out || diff -u log.out style.out
197 197
198 198 $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out
199 199 $ hg log -r 'wdir()' --debug --style default \
200 200 > | sed 's|^date:.*|date:|' > style.out
201 201 $ cmp log.out style.out || diff -u log.out style.out
202 202
203 203 Default style should also preserve color information (issue2866):
204 204
205 205 $ cp $HGRCPATH $HGRCPATH-bak
206 206 $ cat <<EOF >> $HGRCPATH
207 207 > [extensions]
208 208 > color=
209 209 > EOF
210 210
211 211 $ hg --color=debug log > log.out
212 212 $ hg --color=debug log --style default > style.out
213 213 $ cmp log.out style.out || diff -u log.out style.out
214 214 $ hg --color=debug log -T phases > phases.out
215 215 $ diff -U 0 log.out phases.out | grep -v '^---\|^+++'
216 216 @@ -2,0 +3 @@
217 217 +[log.phase|phase: draft]
218 218 @@ -6,0 +8 @@
219 219 +[log.phase|phase: draft]
220 220 @@ -11,0 +14 @@
221 221 +[log.phase|phase: draft]
222 222 @@ -17,0 +21 @@
223 223 +[log.phase|phase: draft]
224 224 @@ -24,0 +29 @@
225 225 +[log.phase|phase: draft]
226 226 @@ -31,0 +37 @@
227 227 +[log.phase|phase: draft]
228 228 @@ -36,0 +43 @@
229 229 +[log.phase|phase: draft]
230 230 @@ -41,0 +49 @@
231 231 +[log.phase|phase: draft]
232 232 @@ -46,0 +55 @@
233 233 +[log.phase|phase: draft]
234 234 @@ -51,0 +61 @@
235 235 +[log.phase|phase: draft]
236 236
237 237 $ hg --color=debug -v log > log.out
238 238 $ hg --color=debug -v log --style default > style.out
239 239 $ cmp log.out style.out || diff -u log.out style.out
240 240 $ hg --color=debug -v log -T phases > phases.out
241 241 $ diff -U 0 log.out phases.out | grep -v '^---\|^+++'
242 242 @@ -2,0 +3 @@
243 243 +[log.phase|phase: draft]
244 244 @@ -7,0 +9 @@
245 245 +[log.phase|phase: draft]
246 246 @@ -15,0 +18 @@
247 247 +[log.phase|phase: draft]
248 248 @@ -24,0 +28 @@
249 249 +[log.phase|phase: draft]
250 250 @@ -33,0 +38 @@
251 251 +[log.phase|phase: draft]
252 252 @@ -43,0 +49 @@
253 253 +[log.phase|phase: draft]
254 254 @@ -50,0 +57 @@
255 255 +[log.phase|phase: draft]
256 256 @@ -58,0 +66 @@
257 257 +[log.phase|phase: draft]
258 258 @@ -66,0 +75 @@
259 259 +[log.phase|phase: draft]
260 260 @@ -77,0 +87 @@
261 261 +[log.phase|phase: draft]
262 262
263 263 $ hg --color=debug -q log > log.out
264 264 $ hg --color=debug -q log --style default > style.out
265 265 $ cmp log.out style.out || diff -u log.out style.out
266 266 $ hg --color=debug -q log -T phases > phases.out
267 267 $ cmp log.out phases.out || diff -u log.out phases.out
268 268
269 269 $ hg --color=debug --debug log > log.out
270 270 $ hg --color=debug --debug log --style default > style.out
271 271 $ cmp log.out style.out || diff -u log.out style.out
272 272 $ hg --color=debug --debug log -T phases > phases.out
273 273 $ cmp log.out phases.out || diff -u log.out phases.out
274 274
275 275 $ mv $HGRCPATH-bak $HGRCPATH
276 276
277 277 Remove commit with empty commit message, so as to not pollute further
278 278 tests.
279 279
280 280 $ hg --config extensions.strip= strip -q .
281 281
282 282 Revision with no copies (used to print a traceback):
283 283
284 284 $ hg tip -v --template '\n'
285 285
286 286
287 287 Compact style works:
288 288
289 289 $ hg log -Tcompact
290 290 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
291 291 third
292 292
293 293 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user
294 294 second
295 295
296 296 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
297 297 merge
298 298
299 299 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
300 300 new head
301 301
302 302 4 bbe44766e73d 1970-01-17 04:53 +0000 person
303 303 new branch
304 304
305 305 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
306 306 no user, no domain
307 307
308 308 2 97054abb4ab8 1970-01-14 21:20 +0000 other
309 309 no person
310 310
311 311 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other
312 312 other 1
313 313
314 314 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user
315 315 line 1
316 316
317 317
318 318 $ hg log -v --style compact
319 319 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
320 320 third
321 321
322 322 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
323 323 second
324 324
325 325 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
326 326 merge
327 327
328 328 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
329 329 new head
330 330
331 331 4 bbe44766e73d 1970-01-17 04:53 +0000 person
332 332 new branch
333 333
334 334 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
335 335 no user, no domain
336 336
337 337 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place
338 338 no person
339 339
340 340 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
341 341 other 1
342 342 other 2
343 343
344 344 other 3
345 345
346 346 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
347 347 line 1
348 348 line 2
349 349
350 350
351 351 $ hg log --debug --style compact
352 352 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test
353 353 third
354 354
355 355 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
356 356 second
357 357
358 358 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
359 359 merge
360 360
361 361 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person
362 362 new head
363 363
364 364 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person
365 365 new branch
366 366
367 367 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person
368 368 no user, no domain
369 369
370 370 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place
371 371 no person
372 372
373 373 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
374 374 other 1
375 375 other 2
376 376
377 377 other 3
378 378
379 379 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
380 380 line 1
381 381 line 2
382 382
383 383
384 384 Test xml styles:
385 385
386 386 $ hg log --style xml
387 387 <?xml version="1.0"?>
388 388 <log>
389 389 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
390 390 <tag>tip</tag>
391 391 <author email="test">test</author>
392 392 <date>2020-01-01T10:01:00+00:00</date>
393 393 <msg xml:space="preserve">third</msg>
394 394 </logentry>
395 395 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
396 396 <parent revision="-1" node="0000000000000000000000000000000000000000" />
397 397 <author email="user@hostname">User Name</author>
398 398 <date>1970-01-12T13:46:40+00:00</date>
399 399 <msg xml:space="preserve">second</msg>
400 400 </logentry>
401 401 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
402 402 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
403 403 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
404 404 <author email="person">person</author>
405 405 <date>1970-01-18T08:40:01+00:00</date>
406 406 <msg xml:space="preserve">merge</msg>
407 407 </logentry>
408 408 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
409 409 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
410 410 <author email="person">person</author>
411 411 <date>1970-01-18T08:40:00+00:00</date>
412 412 <msg xml:space="preserve">new head</msg>
413 413 </logentry>
414 414 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
415 415 <branch>foo</branch>
416 416 <author email="person">person</author>
417 417 <date>1970-01-17T04:53:20+00:00</date>
418 418 <msg xml:space="preserve">new branch</msg>
419 419 </logentry>
420 420 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
421 421 <author email="person">person</author>
422 422 <date>1970-01-16T01:06:40+00:00</date>
423 423 <msg xml:space="preserve">no user, no domain</msg>
424 424 </logentry>
425 425 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
426 426 <author email="other@place">other</author>
427 427 <date>1970-01-14T21:20:00+00:00</date>
428 428 <msg xml:space="preserve">no person</msg>
429 429 </logentry>
430 430 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
431 431 <author email="other@place">A. N. Other</author>
432 432 <date>1970-01-13T17:33:20+00:00</date>
433 433 <msg xml:space="preserve">other 1
434 434 other 2
435 435
436 436 other 3</msg>
437 437 </logentry>
438 438 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
439 439 <author email="user@hostname">User Name</author>
440 440 <date>1970-01-12T13:46:40+00:00</date>
441 441 <msg xml:space="preserve">line 1
442 442 line 2</msg>
443 443 </logentry>
444 444 </log>
445 445
446 446 $ hg log -v --style xml
447 447 <?xml version="1.0"?>
448 448 <log>
449 449 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
450 450 <tag>tip</tag>
451 451 <author email="test">test</author>
452 452 <date>2020-01-01T10:01:00+00:00</date>
453 453 <msg xml:space="preserve">third</msg>
454 454 <paths>
455 455 <path action="A">fourth</path>
456 456 <path action="A">third</path>
457 457 <path action="R">second</path>
458 458 </paths>
459 459 <copies>
460 460 <copy source="second">fourth</copy>
461 461 </copies>
462 462 </logentry>
463 463 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
464 464 <parent revision="-1" node="0000000000000000000000000000000000000000" />
465 465 <author email="user@hostname">User Name</author>
466 466 <date>1970-01-12T13:46:40+00:00</date>
467 467 <msg xml:space="preserve">second</msg>
468 468 <paths>
469 469 <path action="A">second</path>
470 470 </paths>
471 471 </logentry>
472 472 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
473 473 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
474 474 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
475 475 <author email="person">person</author>
476 476 <date>1970-01-18T08:40:01+00:00</date>
477 477 <msg xml:space="preserve">merge</msg>
478 478 <paths>
479 479 </paths>
480 480 </logentry>
481 481 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
482 482 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
483 483 <author email="person">person</author>
484 484 <date>1970-01-18T08:40:00+00:00</date>
485 485 <msg xml:space="preserve">new head</msg>
486 486 <paths>
487 487 <path action="A">d</path>
488 488 </paths>
489 489 </logentry>
490 490 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
491 491 <branch>foo</branch>
492 492 <author email="person">person</author>
493 493 <date>1970-01-17T04:53:20+00:00</date>
494 494 <msg xml:space="preserve">new branch</msg>
495 495 <paths>
496 496 </paths>
497 497 </logentry>
498 498 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
499 499 <author email="person">person</author>
500 500 <date>1970-01-16T01:06:40+00:00</date>
501 501 <msg xml:space="preserve">no user, no domain</msg>
502 502 <paths>
503 503 <path action="M">c</path>
504 504 </paths>
505 505 </logentry>
506 506 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
507 507 <author email="other@place">other</author>
508 508 <date>1970-01-14T21:20:00+00:00</date>
509 509 <msg xml:space="preserve">no person</msg>
510 510 <paths>
511 511 <path action="A">c</path>
512 512 </paths>
513 513 </logentry>
514 514 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
515 515 <author email="other@place">A. N. Other</author>
516 516 <date>1970-01-13T17:33:20+00:00</date>
517 517 <msg xml:space="preserve">other 1
518 518 other 2
519 519
520 520 other 3</msg>
521 521 <paths>
522 522 <path action="A">b</path>
523 523 </paths>
524 524 </logentry>
525 525 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
526 526 <author email="user@hostname">User Name</author>
527 527 <date>1970-01-12T13:46:40+00:00</date>
528 528 <msg xml:space="preserve">line 1
529 529 line 2</msg>
530 530 <paths>
531 531 <path action="A">a</path>
532 532 </paths>
533 533 </logentry>
534 534 </log>
535 535
536 536 $ hg log --debug --style xml
537 537 <?xml version="1.0"?>
538 538 <log>
539 539 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
540 540 <tag>tip</tag>
541 541 <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" />
542 542 <parent revision="-1" node="0000000000000000000000000000000000000000" />
543 543 <author email="test">test</author>
544 544 <date>2020-01-01T10:01:00+00:00</date>
545 545 <msg xml:space="preserve">third</msg>
546 546 <paths>
547 547 <path action="A">fourth</path>
548 548 <path action="A">third</path>
549 549 <path action="R">second</path>
550 550 </paths>
551 551 <copies>
552 552 <copy source="second">fourth</copy>
553 553 </copies>
554 554 <extra key="branch">default</extra>
555 555 </logentry>
556 556 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
557 557 <parent revision="-1" node="0000000000000000000000000000000000000000" />
558 558 <parent revision="-1" node="0000000000000000000000000000000000000000" />
559 559 <author email="user@hostname">User Name</author>
560 560 <date>1970-01-12T13:46:40+00:00</date>
561 561 <msg xml:space="preserve">second</msg>
562 562 <paths>
563 563 <path action="A">second</path>
564 564 </paths>
565 565 <extra key="branch">default</extra>
566 566 </logentry>
567 567 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
568 568 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
569 569 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
570 570 <author email="person">person</author>
571 571 <date>1970-01-18T08:40:01+00:00</date>
572 572 <msg xml:space="preserve">merge</msg>
573 573 <paths>
574 574 </paths>
575 575 <extra key="branch">default</extra>
576 576 </logentry>
577 577 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
578 578 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
579 579 <parent revision="-1" node="0000000000000000000000000000000000000000" />
580 580 <author email="person">person</author>
581 581 <date>1970-01-18T08:40:00+00:00</date>
582 582 <msg xml:space="preserve">new head</msg>
583 583 <paths>
584 584 <path action="A">d</path>
585 585 </paths>
586 586 <extra key="branch">default</extra>
587 587 </logentry>
588 588 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
589 589 <branch>foo</branch>
590 590 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
591 591 <parent revision="-1" node="0000000000000000000000000000000000000000" />
592 592 <author email="person">person</author>
593 593 <date>1970-01-17T04:53:20+00:00</date>
594 594 <msg xml:space="preserve">new branch</msg>
595 595 <paths>
596 596 </paths>
597 597 <extra key="branch">foo</extra>
598 598 </logentry>
599 599 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
600 600 <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" />
601 601 <parent revision="-1" node="0000000000000000000000000000000000000000" />
602 602 <author email="person">person</author>
603 603 <date>1970-01-16T01:06:40+00:00</date>
604 604 <msg xml:space="preserve">no user, no domain</msg>
605 605 <paths>
606 606 <path action="M">c</path>
607 607 </paths>
608 608 <extra key="branch">default</extra>
609 609 </logentry>
610 610 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
611 611 <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" />
612 612 <parent revision="-1" node="0000000000000000000000000000000000000000" />
613 613 <author email="other@place">other</author>
614 614 <date>1970-01-14T21:20:00+00:00</date>
615 615 <msg xml:space="preserve">no person</msg>
616 616 <paths>
617 617 <path action="A">c</path>
618 618 </paths>
619 619 <extra key="branch">default</extra>
620 620 </logentry>
621 621 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
622 622 <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" />
623 623 <parent revision="-1" node="0000000000000000000000000000000000000000" />
624 624 <author email="other@place">A. N. Other</author>
625 625 <date>1970-01-13T17:33:20+00:00</date>
626 626 <msg xml:space="preserve">other 1
627 627 other 2
628 628
629 629 other 3</msg>
630 630 <paths>
631 631 <path action="A">b</path>
632 632 </paths>
633 633 <extra key="branch">default</extra>
634 634 </logentry>
635 635 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
636 636 <parent revision="-1" node="0000000000000000000000000000000000000000" />
637 637 <parent revision="-1" node="0000000000000000000000000000000000000000" />
638 638 <author email="user@hostname">User Name</author>
639 639 <date>1970-01-12T13:46:40+00:00</date>
640 640 <msg xml:space="preserve">line 1
641 641 line 2</msg>
642 642 <paths>
643 643 <path action="A">a</path>
644 644 </paths>
645 645 <extra key="branch">default</extra>
646 646 </logentry>
647 647 </log>
648 648
649 649
650 650 Test JSON style:
651 651
652 652 $ hg log -k nosuch -Tjson
653 653 []
654 654
655 655 $ hg log -qr . -Tjson
656 656 [
657 657 {
658 658 "rev": 8,
659 659 "node": "95c24699272ef57d062b8bccc32c878bf841784a"
660 660 }
661 661 ]
662 662
663 663 $ hg log -vpr . -Tjson --stat
664 664 [
665 665 {
666 666 "rev": 8,
667 667 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
668 668 "branch": "default",
669 669 "phase": "draft",
670 670 "user": "test",
671 671 "date": [1577872860, 0],
672 672 "desc": "third",
673 673 "bookmarks": [],
674 674 "tags": ["tip"],
675 675 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
676 676 "files": ["fourth", "second", "third"],
677 677 "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n",
678 678 "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"
679 679 }
680 680 ]
681 681
682 682 honor --git but not format-breaking diffopts
683 683 $ hg --config diff.noprefix=True log --git -vpr . -Tjson
684 684 [
685 685 {
686 686 "rev": 8,
687 687 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
688 688 "branch": "default",
689 689 "phase": "draft",
690 690 "user": "test",
691 691 "date": [1577872860, 0],
692 692 "desc": "third",
693 693 "bookmarks": [],
694 694 "tags": ["tip"],
695 695 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
696 696 "files": ["fourth", "second", "third"],
697 697 "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"
698 698 }
699 699 ]
700 700
701 701 $ hg log -T json
702 702 [
703 703 {
704 704 "rev": 8,
705 705 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
706 706 "branch": "default",
707 707 "phase": "draft",
708 708 "user": "test",
709 709 "date": [1577872860, 0],
710 710 "desc": "third",
711 711 "bookmarks": [],
712 712 "tags": ["tip"],
713 713 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"]
714 714 },
715 715 {
716 716 "rev": 7,
717 717 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
718 718 "branch": "default",
719 719 "phase": "draft",
720 720 "user": "User Name <user@hostname>",
721 721 "date": [1000000, 0],
722 722 "desc": "second",
723 723 "bookmarks": [],
724 724 "tags": [],
725 725 "parents": ["0000000000000000000000000000000000000000"]
726 726 },
727 727 {
728 728 "rev": 6,
729 729 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
730 730 "branch": "default",
731 731 "phase": "draft",
732 732 "user": "person",
733 733 "date": [1500001, 0],
734 734 "desc": "merge",
735 735 "bookmarks": [],
736 736 "tags": [],
737 737 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"]
738 738 },
739 739 {
740 740 "rev": 5,
741 741 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
742 742 "branch": "default",
743 743 "phase": "draft",
744 744 "user": "person",
745 745 "date": [1500000, 0],
746 746 "desc": "new head",
747 747 "bookmarks": [],
748 748 "tags": [],
749 749 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
750 750 },
751 751 {
752 752 "rev": 4,
753 753 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
754 754 "branch": "foo",
755 755 "phase": "draft",
756 756 "user": "person",
757 757 "date": [1400000, 0],
758 758 "desc": "new branch",
759 759 "bookmarks": [],
760 760 "tags": [],
761 761 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
762 762 },
763 763 {
764 764 "rev": 3,
765 765 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
766 766 "branch": "default",
767 767 "phase": "draft",
768 768 "user": "person",
769 769 "date": [1300000, 0],
770 770 "desc": "no user, no domain",
771 771 "bookmarks": [],
772 772 "tags": [],
773 773 "parents": ["97054abb4ab824450e9164180baf491ae0078465"]
774 774 },
775 775 {
776 776 "rev": 2,
777 777 "node": "97054abb4ab824450e9164180baf491ae0078465",
778 778 "branch": "default",
779 779 "phase": "draft",
780 780 "user": "other@place",
781 781 "date": [1200000, 0],
782 782 "desc": "no person",
783 783 "bookmarks": [],
784 784 "tags": [],
785 785 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"]
786 786 },
787 787 {
788 788 "rev": 1,
789 789 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
790 790 "branch": "default",
791 791 "phase": "draft",
792 792 "user": "A. N. Other <other@place>",
793 793 "date": [1100000, 0],
794 794 "desc": "other 1\nother 2\n\nother 3",
795 795 "bookmarks": [],
796 796 "tags": [],
797 797 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"]
798 798 },
799 799 {
800 800 "rev": 0,
801 801 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
802 802 "branch": "default",
803 803 "phase": "draft",
804 804 "user": "User Name <user@hostname>",
805 805 "date": [1000000, 0],
806 806 "desc": "line 1\nline 2",
807 807 "bookmarks": [],
808 808 "tags": [],
809 809 "parents": ["0000000000000000000000000000000000000000"]
810 810 }
811 811 ]
812 812
813 813 $ hg heads -v -Tjson
814 814 [
815 815 {
816 816 "rev": 8,
817 817 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
818 818 "branch": "default",
819 819 "phase": "draft",
820 820 "user": "test",
821 821 "date": [1577872860, 0],
822 822 "desc": "third",
823 823 "bookmarks": [],
824 824 "tags": ["tip"],
825 825 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
826 826 "files": ["fourth", "second", "third"]
827 827 },
828 828 {
829 829 "rev": 6,
830 830 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
831 831 "branch": "default",
832 832 "phase": "draft",
833 833 "user": "person",
834 834 "date": [1500001, 0],
835 835 "desc": "merge",
836 836 "bookmarks": [],
837 837 "tags": [],
838 838 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
839 839 "files": []
840 840 },
841 841 {
842 842 "rev": 4,
843 843 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
844 844 "branch": "foo",
845 845 "phase": "draft",
846 846 "user": "person",
847 847 "date": [1400000, 0],
848 848 "desc": "new branch",
849 849 "bookmarks": [],
850 850 "tags": [],
851 851 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
852 852 "files": []
853 853 }
854 854 ]
855 855
856 856 $ hg log --debug -Tjson
857 857 [
858 858 {
859 859 "rev": 8,
860 860 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
861 861 "branch": "default",
862 862 "phase": "draft",
863 863 "user": "test",
864 864 "date": [1577872860, 0],
865 865 "desc": "third",
866 866 "bookmarks": [],
867 867 "tags": ["tip"],
868 868 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
869 869 "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64",
870 870 "extra": {"branch": "default"},
871 871 "modified": [],
872 872 "added": ["fourth", "third"],
873 873 "removed": ["second"]
874 874 },
875 875 {
876 876 "rev": 7,
877 877 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
878 878 "branch": "default",
879 879 "phase": "draft",
880 880 "user": "User Name <user@hostname>",
881 881 "date": [1000000, 0],
882 882 "desc": "second",
883 883 "bookmarks": [],
884 884 "tags": [],
885 885 "parents": ["0000000000000000000000000000000000000000"],
886 886 "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf",
887 887 "extra": {"branch": "default"},
888 888 "modified": [],
889 889 "added": ["second"],
890 890 "removed": []
891 891 },
892 892 {
893 893 "rev": 6,
894 894 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
895 895 "branch": "default",
896 896 "phase": "draft",
897 897 "user": "person",
898 898 "date": [1500001, 0],
899 899 "desc": "merge",
900 900 "bookmarks": [],
901 901 "tags": [],
902 902 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
903 903 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
904 904 "extra": {"branch": "default"},
905 905 "modified": [],
906 906 "added": [],
907 907 "removed": []
908 908 },
909 909 {
910 910 "rev": 5,
911 911 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
912 912 "branch": "default",
913 913 "phase": "draft",
914 914 "user": "person",
915 915 "date": [1500000, 0],
916 916 "desc": "new head",
917 917 "bookmarks": [],
918 918 "tags": [],
919 919 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
920 920 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
921 921 "extra": {"branch": "default"},
922 922 "modified": [],
923 923 "added": ["d"],
924 924 "removed": []
925 925 },
926 926 {
927 927 "rev": 4,
928 928 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
929 929 "branch": "foo",
930 930 "phase": "draft",
931 931 "user": "person",
932 932 "date": [1400000, 0],
933 933 "desc": "new branch",
934 934 "bookmarks": [],
935 935 "tags": [],
936 936 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
937 937 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
938 938 "extra": {"branch": "foo"},
939 939 "modified": [],
940 940 "added": [],
941 941 "removed": []
942 942 },
943 943 {
944 944 "rev": 3,
945 945 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
946 946 "branch": "default",
947 947 "phase": "draft",
948 948 "user": "person",
949 949 "date": [1300000, 0],
950 950 "desc": "no user, no domain",
951 951 "bookmarks": [],
952 952 "tags": [],
953 953 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
954 954 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
955 955 "extra": {"branch": "default"},
956 956 "modified": ["c"],
957 957 "added": [],
958 958 "removed": []
959 959 },
960 960 {
961 961 "rev": 2,
962 962 "node": "97054abb4ab824450e9164180baf491ae0078465",
963 963 "branch": "default",
964 964 "phase": "draft",
965 965 "user": "other@place",
966 966 "date": [1200000, 0],
967 967 "desc": "no person",
968 968 "bookmarks": [],
969 969 "tags": [],
970 970 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
971 971 "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1",
972 972 "extra": {"branch": "default"},
973 973 "modified": [],
974 974 "added": ["c"],
975 975 "removed": []
976 976 },
977 977 {
978 978 "rev": 1,
979 979 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
980 980 "branch": "default",
981 981 "phase": "draft",
982 982 "user": "A. N. Other <other@place>",
983 983 "date": [1100000, 0],
984 984 "desc": "other 1\nother 2\n\nother 3",
985 985 "bookmarks": [],
986 986 "tags": [],
987 987 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
988 988 "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55",
989 989 "extra": {"branch": "default"},
990 990 "modified": [],
991 991 "added": ["b"],
992 992 "removed": []
993 993 },
994 994 {
995 995 "rev": 0,
996 996 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
997 997 "branch": "default",
998 998 "phase": "draft",
999 999 "user": "User Name <user@hostname>",
1000 1000 "date": [1000000, 0],
1001 1001 "desc": "line 1\nline 2",
1002 1002 "bookmarks": [],
1003 1003 "tags": [],
1004 1004 "parents": ["0000000000000000000000000000000000000000"],
1005 1005 "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0",
1006 1006 "extra": {"branch": "default"},
1007 1007 "modified": [],
1008 1008 "added": ["a"],
1009 1009 "removed": []
1010 1010 }
1011 1011 ]
1012 1012
1013 1013 Error if style not readable:
1014 1014
1015 1015 #if unix-permissions no-root
1016 1016 $ touch q
1017 1017 $ chmod 0 q
1018 1018 $ hg log --style ./q
1019 1019 abort: Permission denied: ./q
1020 1020 [255]
1021 1021 #endif
1022 1022
1023 1023 Error if no style:
1024 1024
1025 1025 $ hg log --style notexist
1026 1026 abort: style 'notexist' not found
1027 1027 (available styles: bisect, changelog, compact, default, phases, status, xml)
1028 1028 [255]
1029 1029
1030 1030 $ hg log -T list
1031 1031 available styles: bisect, changelog, compact, default, phases, status, xml
1032 1032 abort: specify a template
1033 1033 [255]
1034 1034
1035 1035 Error if style missing key:
1036 1036
1037 1037 $ echo 'q = q' > t
1038 1038 $ hg log --style ./t
1039 1039 abort: "changeset" not in template map
1040 1040 [255]
1041 1041
1042 1042 Error if style missing value:
1043 1043
1044 1044 $ echo 'changeset =' > t
1045 1045 $ hg log --style t
1046 1046 abort: t:1: missing value
1047 1047 [255]
1048 1048
1049 1049 Error if include fails:
1050 1050
1051 1051 $ echo 'changeset = q' >> t
1052 1052 #if unix-permissions no-root
1053 1053 $ hg log --style ./t
1054 1054 abort: template file ./q: Permission denied
1055 1055 [255]
1056 1056 $ rm q
1057 1057 #endif
1058 1058
1059 1059 Include works:
1060 1060
1061 1061 $ echo '{rev}' > q
1062 1062 $ hg log --style ./t
1063 1063 8
1064 1064 7
1065 1065 6
1066 1066 5
1067 1067 4
1068 1068 3
1069 1069 2
1070 1070 1
1071 1071 0
1072 1072
1073 1073 Check that {phase} works correctly on parents:
1074 1074
1075 1075 $ cat << EOF > parentphase
1076 1076 > changeset_debug = '{rev} ({phase}):{parents}\n'
1077 1077 > parent = ' {rev} ({phase})'
1078 1078 > EOF
1079 1079 $ hg phase -r 5 --public
1080 1080 $ hg phase -r 7 --secret --force
1081 1081 $ hg log --debug -G --style ./parentphase
1082 1082 @ 8 (secret): 7 (secret) -1 (public)
1083 1083 |
1084 1084 o 7 (secret): -1 (public) -1 (public)
1085 1085
1086 1086 o 6 (draft): 5 (public) 4 (draft)
1087 1087 |\
1088 1088 | o 5 (public): 3 (public) -1 (public)
1089 1089 | |
1090 1090 o | 4 (draft): 3 (public) -1 (public)
1091 1091 |/
1092 1092 o 3 (public): 2 (public) -1 (public)
1093 1093 |
1094 1094 o 2 (public): 1 (public) -1 (public)
1095 1095 |
1096 1096 o 1 (public): 0 (public) -1 (public)
1097 1097 |
1098 1098 o 0 (public): -1 (public) -1 (public)
1099 1099
1100 1100
1101 1101 Missing non-standard names give no error (backward compatibility):
1102 1102
1103 1103 $ echo "changeset = '{c}'" > t
1104 1104 $ hg log --style ./t
1105 1105
1106 1106 Defining non-standard name works:
1107 1107
1108 1108 $ cat <<EOF > t
1109 1109 > changeset = '{c}'
1110 1110 > c = q
1111 1111 > EOF
1112 1112 $ hg log --style ./t
1113 1113 8
1114 1114 7
1115 1115 6
1116 1116 5
1117 1117 4
1118 1118 3
1119 1119 2
1120 1120 1
1121 1121 0
1122 1122
1123 1123 ui.style works:
1124 1124
1125 1125 $ echo '[ui]' > .hg/hgrc
1126 1126 $ echo 'style = t' >> .hg/hgrc
1127 1127 $ hg log
1128 1128 8
1129 1129 7
1130 1130 6
1131 1131 5
1132 1132 4
1133 1133 3
1134 1134 2
1135 1135 1
1136 1136 0
1137 1137
1138 1138
1139 1139 Issue338:
1140 1140
1141 1141 $ hg log --style=changelog > changelog
1142 1142
1143 1143 $ cat changelog
1144 1144 2020-01-01 test <test>
1145 1145
1146 1146 * fourth, second, third:
1147 1147 third
1148 1148 [95c24699272e] [tip]
1149 1149
1150 1150 1970-01-12 User Name <user@hostname>
1151 1151
1152 1152 * second:
1153 1153 second
1154 1154 [29114dbae42b]
1155 1155
1156 1156 1970-01-18 person <person>
1157 1157
1158 1158 * merge
1159 1159 [d41e714fe50d]
1160 1160
1161 1161 * d:
1162 1162 new head
1163 1163 [13207e5a10d9]
1164 1164
1165 1165 1970-01-17 person <person>
1166 1166
1167 1167 * new branch
1168 1168 [bbe44766e73d] <foo>
1169 1169
1170 1170 1970-01-16 person <person>
1171 1171
1172 1172 * c:
1173 1173 no user, no domain
1174 1174 [10e46f2dcbf4]
1175 1175
1176 1176 1970-01-14 other <other@place>
1177 1177
1178 1178 * c:
1179 1179 no person
1180 1180 [97054abb4ab8]
1181 1181
1182 1182 1970-01-13 A. N. Other <other@place>
1183 1183
1184 1184 * b:
1185 1185 other 1 other 2
1186 1186
1187 1187 other 3
1188 1188 [b608e9d1a3f0]
1189 1189
1190 1190 1970-01-12 User Name <user@hostname>
1191 1191
1192 1192 * a:
1193 1193 line 1 line 2
1194 1194 [1e4e1b8f71e0]
1195 1195
1196 1196
1197 1197 Issue2130: xml output for 'hg heads' is malformed
1198 1198
1199 1199 $ hg heads --style changelog
1200 1200 2020-01-01 test <test>
1201 1201
1202 1202 * fourth, second, third:
1203 1203 third
1204 1204 [95c24699272e] [tip]
1205 1205
1206 1206 1970-01-18 person <person>
1207 1207
1208 1208 * merge
1209 1209 [d41e714fe50d]
1210 1210
1211 1211 1970-01-17 person <person>
1212 1212
1213 1213 * new branch
1214 1214 [bbe44766e73d] <foo>
1215 1215
1216 1216
1217 1217 Keys work:
1218 1218
1219 1219 $ for key in author branch branches date desc file_adds file_dels file_mods \
1220 1220 > file_copies file_copies_switch files \
1221 1221 > manifest node parents rev tags diffstat extras \
1222 1222 > p1rev p2rev p1node p2node; do
1223 1223 > for mode in '' --verbose --debug; do
1224 1224 > hg log $mode --template "$key$mode: {$key}\n"
1225 1225 > done
1226 1226 > done
1227 1227 author: test
1228 1228 author: User Name <user@hostname>
1229 1229 author: person
1230 1230 author: person
1231 1231 author: person
1232 1232 author: person
1233 1233 author: other@place
1234 1234 author: A. N. Other <other@place>
1235 1235 author: User Name <user@hostname>
1236 1236 author--verbose: test
1237 1237 author--verbose: User Name <user@hostname>
1238 1238 author--verbose: person
1239 1239 author--verbose: person
1240 1240 author--verbose: person
1241 1241 author--verbose: person
1242 1242 author--verbose: other@place
1243 1243 author--verbose: A. N. Other <other@place>
1244 1244 author--verbose: User Name <user@hostname>
1245 1245 author--debug: test
1246 1246 author--debug: User Name <user@hostname>
1247 1247 author--debug: person
1248 1248 author--debug: person
1249 1249 author--debug: person
1250 1250 author--debug: person
1251 1251 author--debug: other@place
1252 1252 author--debug: A. N. Other <other@place>
1253 1253 author--debug: User Name <user@hostname>
1254 1254 branch: default
1255 1255 branch: default
1256 1256 branch: default
1257 1257 branch: default
1258 1258 branch: foo
1259 1259 branch: default
1260 1260 branch: default
1261 1261 branch: default
1262 1262 branch: default
1263 1263 branch--verbose: default
1264 1264 branch--verbose: default
1265 1265 branch--verbose: default
1266 1266 branch--verbose: default
1267 1267 branch--verbose: foo
1268 1268 branch--verbose: default
1269 1269 branch--verbose: default
1270 1270 branch--verbose: default
1271 1271 branch--verbose: default
1272 1272 branch--debug: default
1273 1273 branch--debug: default
1274 1274 branch--debug: default
1275 1275 branch--debug: default
1276 1276 branch--debug: foo
1277 1277 branch--debug: default
1278 1278 branch--debug: default
1279 1279 branch--debug: default
1280 1280 branch--debug: default
1281 1281 branches:
1282 1282 branches:
1283 1283 branches:
1284 1284 branches:
1285 1285 branches: foo
1286 1286 branches:
1287 1287 branches:
1288 1288 branches:
1289 1289 branches:
1290 1290 branches--verbose:
1291 1291 branches--verbose:
1292 1292 branches--verbose:
1293 1293 branches--verbose:
1294 1294 branches--verbose: foo
1295 1295 branches--verbose:
1296 1296 branches--verbose:
1297 1297 branches--verbose:
1298 1298 branches--verbose:
1299 1299 branches--debug:
1300 1300 branches--debug:
1301 1301 branches--debug:
1302 1302 branches--debug:
1303 1303 branches--debug: foo
1304 1304 branches--debug:
1305 1305 branches--debug:
1306 1306 branches--debug:
1307 1307 branches--debug:
1308 1308 date: 1577872860.00
1309 1309 date: 1000000.00
1310 1310 date: 1500001.00
1311 1311 date: 1500000.00
1312 1312 date: 1400000.00
1313 1313 date: 1300000.00
1314 1314 date: 1200000.00
1315 1315 date: 1100000.00
1316 1316 date: 1000000.00
1317 1317 date--verbose: 1577872860.00
1318 1318 date--verbose: 1000000.00
1319 1319 date--verbose: 1500001.00
1320 1320 date--verbose: 1500000.00
1321 1321 date--verbose: 1400000.00
1322 1322 date--verbose: 1300000.00
1323 1323 date--verbose: 1200000.00
1324 1324 date--verbose: 1100000.00
1325 1325 date--verbose: 1000000.00
1326 1326 date--debug: 1577872860.00
1327 1327 date--debug: 1000000.00
1328 1328 date--debug: 1500001.00
1329 1329 date--debug: 1500000.00
1330 1330 date--debug: 1400000.00
1331 1331 date--debug: 1300000.00
1332 1332 date--debug: 1200000.00
1333 1333 date--debug: 1100000.00
1334 1334 date--debug: 1000000.00
1335 1335 desc: third
1336 1336 desc: second
1337 1337 desc: merge
1338 1338 desc: new head
1339 1339 desc: new branch
1340 1340 desc: no user, no domain
1341 1341 desc: no person
1342 1342 desc: other 1
1343 1343 other 2
1344 1344
1345 1345 other 3
1346 1346 desc: line 1
1347 1347 line 2
1348 1348 desc--verbose: third
1349 1349 desc--verbose: second
1350 1350 desc--verbose: merge
1351 1351 desc--verbose: new head
1352 1352 desc--verbose: new branch
1353 1353 desc--verbose: no user, no domain
1354 1354 desc--verbose: no person
1355 1355 desc--verbose: other 1
1356 1356 other 2
1357 1357
1358 1358 other 3
1359 1359 desc--verbose: line 1
1360 1360 line 2
1361 1361 desc--debug: third
1362 1362 desc--debug: second
1363 1363 desc--debug: merge
1364 1364 desc--debug: new head
1365 1365 desc--debug: new branch
1366 1366 desc--debug: no user, no domain
1367 1367 desc--debug: no person
1368 1368 desc--debug: other 1
1369 1369 other 2
1370 1370
1371 1371 other 3
1372 1372 desc--debug: line 1
1373 1373 line 2
1374 1374 file_adds: fourth third
1375 1375 file_adds: second
1376 1376 file_adds:
1377 1377 file_adds: d
1378 1378 file_adds:
1379 1379 file_adds:
1380 1380 file_adds: c
1381 1381 file_adds: b
1382 1382 file_adds: a
1383 1383 file_adds--verbose: fourth third
1384 1384 file_adds--verbose: second
1385 1385 file_adds--verbose:
1386 1386 file_adds--verbose: d
1387 1387 file_adds--verbose:
1388 1388 file_adds--verbose:
1389 1389 file_adds--verbose: c
1390 1390 file_adds--verbose: b
1391 1391 file_adds--verbose: a
1392 1392 file_adds--debug: fourth third
1393 1393 file_adds--debug: second
1394 1394 file_adds--debug:
1395 1395 file_adds--debug: d
1396 1396 file_adds--debug:
1397 1397 file_adds--debug:
1398 1398 file_adds--debug: c
1399 1399 file_adds--debug: b
1400 1400 file_adds--debug: a
1401 1401 file_dels: second
1402 1402 file_dels:
1403 1403 file_dels:
1404 1404 file_dels:
1405 1405 file_dels:
1406 1406 file_dels:
1407 1407 file_dels:
1408 1408 file_dels:
1409 1409 file_dels:
1410 1410 file_dels--verbose: second
1411 1411 file_dels--verbose:
1412 1412 file_dels--verbose:
1413 1413 file_dels--verbose:
1414 1414 file_dels--verbose:
1415 1415 file_dels--verbose:
1416 1416 file_dels--verbose:
1417 1417 file_dels--verbose:
1418 1418 file_dels--verbose:
1419 1419 file_dels--debug: second
1420 1420 file_dels--debug:
1421 1421 file_dels--debug:
1422 1422 file_dels--debug:
1423 1423 file_dels--debug:
1424 1424 file_dels--debug:
1425 1425 file_dels--debug:
1426 1426 file_dels--debug:
1427 1427 file_dels--debug:
1428 1428 file_mods:
1429 1429 file_mods:
1430 1430 file_mods:
1431 1431 file_mods:
1432 1432 file_mods:
1433 1433 file_mods: c
1434 1434 file_mods:
1435 1435 file_mods:
1436 1436 file_mods:
1437 1437 file_mods--verbose:
1438 1438 file_mods--verbose:
1439 1439 file_mods--verbose:
1440 1440 file_mods--verbose:
1441 1441 file_mods--verbose:
1442 1442 file_mods--verbose: c
1443 1443 file_mods--verbose:
1444 1444 file_mods--verbose:
1445 1445 file_mods--verbose:
1446 1446 file_mods--debug:
1447 1447 file_mods--debug:
1448 1448 file_mods--debug:
1449 1449 file_mods--debug:
1450 1450 file_mods--debug:
1451 1451 file_mods--debug: c
1452 1452 file_mods--debug:
1453 1453 file_mods--debug:
1454 1454 file_mods--debug:
1455 1455 file_copies: fourth (second)
1456 1456 file_copies:
1457 1457 file_copies:
1458 1458 file_copies:
1459 1459 file_copies:
1460 1460 file_copies:
1461 1461 file_copies:
1462 1462 file_copies:
1463 1463 file_copies:
1464 1464 file_copies--verbose: fourth (second)
1465 1465 file_copies--verbose:
1466 1466 file_copies--verbose:
1467 1467 file_copies--verbose:
1468 1468 file_copies--verbose:
1469 1469 file_copies--verbose:
1470 1470 file_copies--verbose:
1471 1471 file_copies--verbose:
1472 1472 file_copies--verbose:
1473 1473 file_copies--debug: fourth (second)
1474 1474 file_copies--debug:
1475 1475 file_copies--debug:
1476 1476 file_copies--debug:
1477 1477 file_copies--debug:
1478 1478 file_copies--debug:
1479 1479 file_copies--debug:
1480 1480 file_copies--debug:
1481 1481 file_copies--debug:
1482 1482 file_copies_switch:
1483 1483 file_copies_switch:
1484 1484 file_copies_switch:
1485 1485 file_copies_switch:
1486 1486 file_copies_switch:
1487 1487 file_copies_switch:
1488 1488 file_copies_switch:
1489 1489 file_copies_switch:
1490 1490 file_copies_switch:
1491 1491 file_copies_switch--verbose:
1492 1492 file_copies_switch--verbose:
1493 1493 file_copies_switch--verbose:
1494 1494 file_copies_switch--verbose:
1495 1495 file_copies_switch--verbose:
1496 1496 file_copies_switch--verbose:
1497 1497 file_copies_switch--verbose:
1498 1498 file_copies_switch--verbose:
1499 1499 file_copies_switch--verbose:
1500 1500 file_copies_switch--debug:
1501 1501 file_copies_switch--debug:
1502 1502 file_copies_switch--debug:
1503 1503 file_copies_switch--debug:
1504 1504 file_copies_switch--debug:
1505 1505 file_copies_switch--debug:
1506 1506 file_copies_switch--debug:
1507 1507 file_copies_switch--debug:
1508 1508 file_copies_switch--debug:
1509 1509 files: fourth second third
1510 1510 files: second
1511 1511 files:
1512 1512 files: d
1513 1513 files:
1514 1514 files: c
1515 1515 files: c
1516 1516 files: b
1517 1517 files: a
1518 1518 files--verbose: fourth second third
1519 1519 files--verbose: second
1520 1520 files--verbose:
1521 1521 files--verbose: d
1522 1522 files--verbose:
1523 1523 files--verbose: c
1524 1524 files--verbose: c
1525 1525 files--verbose: b
1526 1526 files--verbose: a
1527 1527 files--debug: fourth second third
1528 1528 files--debug: second
1529 1529 files--debug:
1530 1530 files--debug: d
1531 1531 files--debug:
1532 1532 files--debug: c
1533 1533 files--debug: c
1534 1534 files--debug: b
1535 1535 files--debug: a
1536 1536 manifest: 6:94961b75a2da
1537 1537 manifest: 5:f2dbc354b94e
1538 1538 manifest: 4:4dc3def4f9b4
1539 1539 manifest: 4:4dc3def4f9b4
1540 1540 manifest: 3:cb5a1327723b
1541 1541 manifest: 3:cb5a1327723b
1542 1542 manifest: 2:6e0e82995c35
1543 1543 manifest: 1:4e8d705b1e53
1544 1544 manifest: 0:a0c8bcbbb45c
1545 1545 manifest--verbose: 6:94961b75a2da
1546 1546 manifest--verbose: 5:f2dbc354b94e
1547 1547 manifest--verbose: 4:4dc3def4f9b4
1548 1548 manifest--verbose: 4:4dc3def4f9b4
1549 1549 manifest--verbose: 3:cb5a1327723b
1550 1550 manifest--verbose: 3:cb5a1327723b
1551 1551 manifest--verbose: 2:6e0e82995c35
1552 1552 manifest--verbose: 1:4e8d705b1e53
1553 1553 manifest--verbose: 0:a0c8bcbbb45c
1554 1554 manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64
1555 1555 manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf
1556 1556 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1557 1557 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1558 1558 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1559 1559 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1560 1560 manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
1561 1561 manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
1562 1562 manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
1563 1563 node: 95c24699272ef57d062b8bccc32c878bf841784a
1564 1564 node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1565 1565 node: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1566 1566 node: 13207e5a10d9fd28ec424934298e176197f2c67f
1567 1567 node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1568 1568 node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1569 1569 node: 97054abb4ab824450e9164180baf491ae0078465
1570 1570 node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1571 1571 node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1572 1572 node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a
1573 1573 node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1574 1574 node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1575 1575 node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1576 1576 node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1577 1577 node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1578 1578 node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1579 1579 node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1580 1580 node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
1581 1581 node--debug: 95c24699272ef57d062b8bccc32c878bf841784a
1582 1582 node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1583 1583 node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1584 1584 node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
1585 1585 node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1586 1586 node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1587 1587 node--debug: 97054abb4ab824450e9164180baf491ae0078465
1588 1588 node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1589 1589 node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
1590 1590 parents:
1591 1591 parents: -1:000000000000
1592 1592 parents: 5:13207e5a10d9 4:bbe44766e73d
1593 1593 parents: 3:10e46f2dcbf4
1594 1594 parents:
1595 1595 parents:
1596 1596 parents:
1597 1597 parents:
1598 1598 parents:
1599 1599 parents--verbose:
1600 1600 parents--verbose: -1:000000000000
1601 1601 parents--verbose: 5:13207e5a10d9 4:bbe44766e73d
1602 1602 parents--verbose: 3:10e46f2dcbf4
1603 1603 parents--verbose:
1604 1604 parents--verbose:
1605 1605 parents--verbose:
1606 1606 parents--verbose:
1607 1607 parents--verbose:
1608 1608 parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000
1609 1609 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1610 1610 parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1611 1611 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1612 1612 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1613 1613 parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000
1614 1614 parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000
1615 1615 parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000
1616 1616 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1617 1617 rev: 8
1618 1618 rev: 7
1619 1619 rev: 6
1620 1620 rev: 5
1621 1621 rev: 4
1622 1622 rev: 3
1623 1623 rev: 2
1624 1624 rev: 1
1625 1625 rev: 0
1626 1626 rev--verbose: 8
1627 1627 rev--verbose: 7
1628 1628 rev--verbose: 6
1629 1629 rev--verbose: 5
1630 1630 rev--verbose: 4
1631 1631 rev--verbose: 3
1632 1632 rev--verbose: 2
1633 1633 rev--verbose: 1
1634 1634 rev--verbose: 0
1635 1635 rev--debug: 8
1636 1636 rev--debug: 7
1637 1637 rev--debug: 6
1638 1638 rev--debug: 5
1639 1639 rev--debug: 4
1640 1640 rev--debug: 3
1641 1641 rev--debug: 2
1642 1642 rev--debug: 1
1643 1643 rev--debug: 0
1644 1644 tags: tip
1645 1645 tags:
1646 1646 tags:
1647 1647 tags:
1648 1648 tags:
1649 1649 tags:
1650 1650 tags:
1651 1651 tags:
1652 1652 tags:
1653 1653 tags--verbose: tip
1654 1654 tags--verbose:
1655 1655 tags--verbose:
1656 1656 tags--verbose:
1657 1657 tags--verbose:
1658 1658 tags--verbose:
1659 1659 tags--verbose:
1660 1660 tags--verbose:
1661 1661 tags--verbose:
1662 1662 tags--debug: tip
1663 1663 tags--debug:
1664 1664 tags--debug:
1665 1665 tags--debug:
1666 1666 tags--debug:
1667 1667 tags--debug:
1668 1668 tags--debug:
1669 1669 tags--debug:
1670 1670 tags--debug:
1671 1671 diffstat: 3: +2/-1
1672 1672 diffstat: 1: +1/-0
1673 1673 diffstat: 0: +0/-0
1674 1674 diffstat: 1: +1/-0
1675 1675 diffstat: 0: +0/-0
1676 1676 diffstat: 1: +1/-0
1677 1677 diffstat: 1: +4/-0
1678 1678 diffstat: 1: +2/-0
1679 1679 diffstat: 1: +1/-0
1680 1680 diffstat--verbose: 3: +2/-1
1681 1681 diffstat--verbose: 1: +1/-0
1682 1682 diffstat--verbose: 0: +0/-0
1683 1683 diffstat--verbose: 1: +1/-0
1684 1684 diffstat--verbose: 0: +0/-0
1685 1685 diffstat--verbose: 1: +1/-0
1686 1686 diffstat--verbose: 1: +4/-0
1687 1687 diffstat--verbose: 1: +2/-0
1688 1688 diffstat--verbose: 1: +1/-0
1689 1689 diffstat--debug: 3: +2/-1
1690 1690 diffstat--debug: 1: +1/-0
1691 1691 diffstat--debug: 0: +0/-0
1692 1692 diffstat--debug: 1: +1/-0
1693 1693 diffstat--debug: 0: +0/-0
1694 1694 diffstat--debug: 1: +1/-0
1695 1695 diffstat--debug: 1: +4/-0
1696 1696 diffstat--debug: 1: +2/-0
1697 1697 diffstat--debug: 1: +1/-0
1698 1698 extras: branch=default
1699 1699 extras: branch=default
1700 1700 extras: branch=default
1701 1701 extras: branch=default
1702 1702 extras: branch=foo
1703 1703 extras: branch=default
1704 1704 extras: branch=default
1705 1705 extras: branch=default
1706 1706 extras: branch=default
1707 1707 extras--verbose: branch=default
1708 1708 extras--verbose: branch=default
1709 1709 extras--verbose: branch=default
1710 1710 extras--verbose: branch=default
1711 1711 extras--verbose: branch=foo
1712 1712 extras--verbose: branch=default
1713 1713 extras--verbose: branch=default
1714 1714 extras--verbose: branch=default
1715 1715 extras--verbose: branch=default
1716 1716 extras--debug: branch=default
1717 1717 extras--debug: branch=default
1718 1718 extras--debug: branch=default
1719 1719 extras--debug: branch=default
1720 1720 extras--debug: branch=foo
1721 1721 extras--debug: branch=default
1722 1722 extras--debug: branch=default
1723 1723 extras--debug: branch=default
1724 1724 extras--debug: branch=default
1725 1725 p1rev: 7
1726 1726 p1rev: -1
1727 1727 p1rev: 5
1728 1728 p1rev: 3
1729 1729 p1rev: 3
1730 1730 p1rev: 2
1731 1731 p1rev: 1
1732 1732 p1rev: 0
1733 1733 p1rev: -1
1734 1734 p1rev--verbose: 7
1735 1735 p1rev--verbose: -1
1736 1736 p1rev--verbose: 5
1737 1737 p1rev--verbose: 3
1738 1738 p1rev--verbose: 3
1739 1739 p1rev--verbose: 2
1740 1740 p1rev--verbose: 1
1741 1741 p1rev--verbose: 0
1742 1742 p1rev--verbose: -1
1743 1743 p1rev--debug: 7
1744 1744 p1rev--debug: -1
1745 1745 p1rev--debug: 5
1746 1746 p1rev--debug: 3
1747 1747 p1rev--debug: 3
1748 1748 p1rev--debug: 2
1749 1749 p1rev--debug: 1
1750 1750 p1rev--debug: 0
1751 1751 p1rev--debug: -1
1752 1752 p2rev: -1
1753 1753 p2rev: -1
1754 1754 p2rev: 4
1755 1755 p2rev: -1
1756 1756 p2rev: -1
1757 1757 p2rev: -1
1758 1758 p2rev: -1
1759 1759 p2rev: -1
1760 1760 p2rev: -1
1761 1761 p2rev--verbose: -1
1762 1762 p2rev--verbose: -1
1763 1763 p2rev--verbose: 4
1764 1764 p2rev--verbose: -1
1765 1765 p2rev--verbose: -1
1766 1766 p2rev--verbose: -1
1767 1767 p2rev--verbose: -1
1768 1768 p2rev--verbose: -1
1769 1769 p2rev--verbose: -1
1770 1770 p2rev--debug: -1
1771 1771 p2rev--debug: -1
1772 1772 p2rev--debug: 4
1773 1773 p2rev--debug: -1
1774 1774 p2rev--debug: -1
1775 1775 p2rev--debug: -1
1776 1776 p2rev--debug: -1
1777 1777 p2rev--debug: -1
1778 1778 p2rev--debug: -1
1779 1779 p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1780 1780 p1node: 0000000000000000000000000000000000000000
1781 1781 p1node: 13207e5a10d9fd28ec424934298e176197f2c67f
1782 1782 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1783 1783 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1784 1784 p1node: 97054abb4ab824450e9164180baf491ae0078465
1785 1785 p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1786 1786 p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1787 1787 p1node: 0000000000000000000000000000000000000000
1788 1788 p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1789 1789 p1node--verbose: 0000000000000000000000000000000000000000
1790 1790 p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1791 1791 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1792 1792 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1793 1793 p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1794 1794 p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1795 1795 p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
1796 1796 p1node--verbose: 0000000000000000000000000000000000000000
1797 1797 p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1798 1798 p1node--debug: 0000000000000000000000000000000000000000
1799 1799 p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
1800 1800 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1801 1801 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1802 1802 p1node--debug: 97054abb4ab824450e9164180baf491ae0078465
1803 1803 p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1804 1804 p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
1805 1805 p1node--debug: 0000000000000000000000000000000000000000
1806 1806 p2node: 0000000000000000000000000000000000000000
1807 1807 p2node: 0000000000000000000000000000000000000000
1808 1808 p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1809 1809 p2node: 0000000000000000000000000000000000000000
1810 1810 p2node: 0000000000000000000000000000000000000000
1811 1811 p2node: 0000000000000000000000000000000000000000
1812 1812 p2node: 0000000000000000000000000000000000000000
1813 1813 p2node: 0000000000000000000000000000000000000000
1814 1814 p2node: 0000000000000000000000000000000000000000
1815 1815 p2node--verbose: 0000000000000000000000000000000000000000
1816 1816 p2node--verbose: 0000000000000000000000000000000000000000
1817 1817 p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1818 1818 p2node--verbose: 0000000000000000000000000000000000000000
1819 1819 p2node--verbose: 0000000000000000000000000000000000000000
1820 1820 p2node--verbose: 0000000000000000000000000000000000000000
1821 1821 p2node--verbose: 0000000000000000000000000000000000000000
1822 1822 p2node--verbose: 0000000000000000000000000000000000000000
1823 1823 p2node--verbose: 0000000000000000000000000000000000000000
1824 1824 p2node--debug: 0000000000000000000000000000000000000000
1825 1825 p2node--debug: 0000000000000000000000000000000000000000
1826 1826 p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1827 1827 p2node--debug: 0000000000000000000000000000000000000000
1828 1828 p2node--debug: 0000000000000000000000000000000000000000
1829 1829 p2node--debug: 0000000000000000000000000000000000000000
1830 1830 p2node--debug: 0000000000000000000000000000000000000000
1831 1831 p2node--debug: 0000000000000000000000000000000000000000
1832 1832 p2node--debug: 0000000000000000000000000000000000000000
1833 1833
1834 1834 Filters work:
1835 1835
1836 1836 $ hg log --template '{author|domain}\n'
1837 1837
1838 1838 hostname
1839 1839
1840 1840
1841 1841
1842 1842
1843 1843 place
1844 1844 place
1845 1845 hostname
1846 1846
1847 1847 $ hg log --template '{author|person}\n'
1848 1848 test
1849 1849 User Name
1850 1850 person
1851 1851 person
1852 1852 person
1853 1853 person
1854 1854 other
1855 1855 A. N. Other
1856 1856 User Name
1857 1857
1858 1858 $ hg log --template '{author|user}\n'
1859 1859 test
1860 1860 user
1861 1861 person
1862 1862 person
1863 1863 person
1864 1864 person
1865 1865 other
1866 1866 other
1867 1867 user
1868 1868
1869 1869 $ hg log --template '{date|date}\n'
1870 1870 Wed Jan 01 10:01:00 2020 +0000
1871 1871 Mon Jan 12 13:46:40 1970 +0000
1872 1872 Sun Jan 18 08:40:01 1970 +0000
1873 1873 Sun Jan 18 08:40:00 1970 +0000
1874 1874 Sat Jan 17 04:53:20 1970 +0000
1875 1875 Fri Jan 16 01:06:40 1970 +0000
1876 1876 Wed Jan 14 21:20:00 1970 +0000
1877 1877 Tue Jan 13 17:33:20 1970 +0000
1878 1878 Mon Jan 12 13:46:40 1970 +0000
1879 1879
1880 1880 $ hg log --template '{date|isodate}\n'
1881 1881 2020-01-01 10:01 +0000
1882 1882 1970-01-12 13:46 +0000
1883 1883 1970-01-18 08:40 +0000
1884 1884 1970-01-18 08:40 +0000
1885 1885 1970-01-17 04:53 +0000
1886 1886 1970-01-16 01:06 +0000
1887 1887 1970-01-14 21:20 +0000
1888 1888 1970-01-13 17:33 +0000
1889 1889 1970-01-12 13:46 +0000
1890 1890
1891 1891 $ hg log --template '{date|isodatesec}\n'
1892 1892 2020-01-01 10:01:00 +0000
1893 1893 1970-01-12 13:46:40 +0000
1894 1894 1970-01-18 08:40:01 +0000
1895 1895 1970-01-18 08:40:00 +0000
1896 1896 1970-01-17 04:53:20 +0000
1897 1897 1970-01-16 01:06:40 +0000
1898 1898 1970-01-14 21:20:00 +0000
1899 1899 1970-01-13 17:33:20 +0000
1900 1900 1970-01-12 13:46:40 +0000
1901 1901
1902 1902 $ hg log --template '{date|rfc822date}\n'
1903 1903 Wed, 01 Jan 2020 10:01:00 +0000
1904 1904 Mon, 12 Jan 1970 13:46:40 +0000
1905 1905 Sun, 18 Jan 1970 08:40:01 +0000
1906 1906 Sun, 18 Jan 1970 08:40:00 +0000
1907 1907 Sat, 17 Jan 1970 04:53:20 +0000
1908 1908 Fri, 16 Jan 1970 01:06:40 +0000
1909 1909 Wed, 14 Jan 1970 21:20:00 +0000
1910 1910 Tue, 13 Jan 1970 17:33:20 +0000
1911 1911 Mon, 12 Jan 1970 13:46:40 +0000
1912 1912
1913 1913 $ hg log --template '{desc|firstline}\n'
1914 1914 third
1915 1915 second
1916 1916 merge
1917 1917 new head
1918 1918 new branch
1919 1919 no user, no domain
1920 1920 no person
1921 1921 other 1
1922 1922 line 1
1923 1923
1924 1924 $ hg log --template '{node|short}\n'
1925 1925 95c24699272e
1926 1926 29114dbae42b
1927 1927 d41e714fe50d
1928 1928 13207e5a10d9
1929 1929 bbe44766e73d
1930 1930 10e46f2dcbf4
1931 1931 97054abb4ab8
1932 1932 b608e9d1a3f0
1933 1933 1e4e1b8f71e0
1934 1934
1935 1935 $ hg log --template '<changeset author="{author|xmlescape}"/>\n'
1936 1936 <changeset author="test"/>
1937 1937 <changeset author="User Name &lt;user@hostname&gt;"/>
1938 1938 <changeset author="person"/>
1939 1939 <changeset author="person"/>
1940 1940 <changeset author="person"/>
1941 1941 <changeset author="person"/>
1942 1942 <changeset author="other@place"/>
1943 1943 <changeset author="A. N. Other &lt;other@place&gt;"/>
1944 1944 <changeset author="User Name &lt;user@hostname&gt;"/>
1945 1945
1946 1946 $ hg log --template '{rev}: {children}\n'
1947 1947 8:
1948 1948 7: 8:95c24699272e
1949 1949 6:
1950 1950 5: 6:d41e714fe50d
1951 1951 4: 6:d41e714fe50d
1952 1952 3: 4:bbe44766e73d 5:13207e5a10d9
1953 1953 2: 3:10e46f2dcbf4
1954 1954 1: 2:97054abb4ab8
1955 1955 0: 1:b608e9d1a3f0
1956 1956
1957 1957 Formatnode filter works:
1958 1958
1959 1959 $ hg -q log -r 0 --template '{node|formatnode}\n'
1960 1960 1e4e1b8f71e0
1961 1961
1962 1962 $ hg log -r 0 --template '{node|formatnode}\n'
1963 1963 1e4e1b8f71e0
1964 1964
1965 1965 $ hg -v log -r 0 --template '{node|formatnode}\n'
1966 1966 1e4e1b8f71e0
1967 1967
1968 1968 $ hg --debug log -r 0 --template '{node|formatnode}\n'
1969 1969 1e4e1b8f71e05681d422154f5421e385fec3454f
1970 1970
1971 1971 Age filter:
1972 1972
1973 1973 $ hg init unstable-hash
1974 1974 $ cd unstable-hash
1975 1975 $ hg log --template '{date|age}\n' > /dev/null || exit 1
1976 1976
1977 1977 >>> from datetime import datetime, timedelta
1978 1978 >>> fp = open('a', 'w')
1979 1979 >>> n = datetime.now() + timedelta(366 * 7)
1980 1980 >>> fp.write('%d-%d-%d 00:00' % (n.year, n.month, n.day))
1981 1981 >>> fp.close()
1982 1982 $ hg add a
1983 1983 $ hg commit -m future -d "`cat a`"
1984 1984
1985 1985 $ hg log -l1 --template '{date|age}\n'
1986 1986 7 years from now
1987 1987
1988 1988 $ cd ..
1989 1989 $ rm -rf unstable-hash
1990 1990
1991 1991 Add a dummy commit to make up for the instability of the above:
1992 1992
1993 1993 $ echo a > a
1994 1994 $ hg add a
1995 1995 $ hg ci -m future
1996 1996
1997 1997 Count filter:
1998 1998
1999 1999 $ hg log -l1 --template '{node|count} {node|short|count}\n'
2000 2000 40 12
2001 2001
2002 2002 $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n'
2003 2003 0 1 4
2004 2004
2005 2005 $ hg log -G --template '{rev}: children: {children|count}, \
2006 2006 > tags: {tags|count}, file_adds: {file_adds|count}, \
2007 2007 > ancestors: {revset("ancestors(%s)", rev)|count}'
2008 2008 @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3
2009 2009 |
2010 2010 o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2
2011 2011 |
2012 2012 o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1
2013 2013
2014 2014 o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7
2015 2015 |\
2016 2016 | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5
2017 2017 | |
2018 2018 o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5
2019 2019 |/
2020 2020 o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4
2021 2021 |
2022 2022 o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3
2023 2023 |
2024 2024 o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2
2025 2025 |
2026 2026 o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1
2027 2027
2028 2028
2029 2029 Upper/lower filters:
2030 2030
2031 2031 $ hg log -r0 --template '{branch|upper}\n'
2032 2032 DEFAULT
2033 2033 $ hg log -r0 --template '{author|lower}\n'
2034 2034 user name <user@hostname>
2035 2035 $ hg log -r0 --template '{date|upper}\n'
2036 2036 abort: template filter 'upper' is not compatible with keyword 'date'
2037 2037 [255]
2038 2038
2039 2039 Add a commit that does all possible modifications at once
2040 2040
2041 2041 $ echo modify >> third
2042 2042 $ touch b
2043 2043 $ hg add b
2044 2044 $ hg mv fourth fifth
2045 2045 $ hg rm a
2046 2046 $ hg ci -m "Modify, add, remove, rename"
2047 2047
2048 2048 Check the status template
2049 2049
2050 2050 $ cat <<EOF >> $HGRCPATH
2051 2051 > [extensions]
2052 2052 > color=
2053 2053 > EOF
2054 2054
2055 2055 $ hg log -T status -r 10
2056 2056 changeset: 10:0f9759ec227a
2057 2057 tag: tip
2058 2058 user: test
2059 2059 date: Thu Jan 01 00:00:00 1970 +0000
2060 2060 summary: Modify, add, remove, rename
2061 2061 files:
2062 2062 M third
2063 2063 A b
2064 2064 A fifth
2065 2065 R a
2066 2066 R fourth
2067 2067
2068 2068 $ hg log -T status -C -r 10
2069 2069 changeset: 10:0f9759ec227a
2070 2070 tag: tip
2071 2071 user: test
2072 2072 date: Thu Jan 01 00:00:00 1970 +0000
2073 2073 summary: Modify, add, remove, rename
2074 2074 files:
2075 2075 M third
2076 2076 A b
2077 2077 A fifth
2078 2078 fourth
2079 2079 R a
2080 2080 R fourth
2081 2081
2082 2082 $ hg log -T status -C -r 10 -v
2083 2083 changeset: 10:0f9759ec227a
2084 2084 tag: tip
2085 2085 user: test
2086 2086 date: Thu Jan 01 00:00:00 1970 +0000
2087 2087 description:
2088 2088 Modify, add, remove, rename
2089 2089
2090 2090 files:
2091 2091 M third
2092 2092 A b
2093 2093 A fifth
2094 2094 fourth
2095 2095 R a
2096 2096 R fourth
2097 2097
2098 2098 $ hg log -T status -C -r 10 --debug
2099 2099 changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c
2100 2100 tag: tip
2101 2101 phase: secret
2102 2102 parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066
2103 2103 parent: -1:0000000000000000000000000000000000000000
2104 2104 manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567
2105 2105 user: test
2106 2106 date: Thu Jan 01 00:00:00 1970 +0000
2107 2107 extra: branch=default
2108 2108 description:
2109 2109 Modify, add, remove, rename
2110 2110
2111 2111 files:
2112 2112 M third
2113 2113 A b
2114 2114 A fifth
2115 2115 fourth
2116 2116 R a
2117 2117 R fourth
2118 2118
2119 2119 $ hg log -T status -C -r 10 --quiet
2120 2120 10:0f9759ec227a
2121 2121 $ hg --color=debug log -T status -r 10
2122 2122 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2123 2123 [log.tag|tag: tip]
2124 2124 [log.user|user: test]
2125 2125 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2126 2126 [log.summary|summary: Modify, add, remove, rename]
2127 2127 [ui.note log.files|files:]
2128 2128 [status.modified|M third]
2129 2129 [status.added|A b]
2130 2130 [status.added|A fifth]
2131 2131 [status.removed|R a]
2132 2132 [status.removed|R fourth]
2133 2133
2134 2134 $ hg --color=debug log -T status -C -r 10
2135 2135 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2136 2136 [log.tag|tag: tip]
2137 2137 [log.user|user: test]
2138 2138 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2139 2139 [log.summary|summary: Modify, add, remove, rename]
2140 2140 [ui.note log.files|files:]
2141 2141 [status.modified|M third]
2142 2142 [status.added|A b]
2143 2143 [status.added|A fifth]
2144 2144 [status.copied| fourth]
2145 2145 [status.removed|R a]
2146 2146 [status.removed|R fourth]
2147 2147
2148 2148 $ hg --color=debug log -T status -C -r 10 -v
2149 2149 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2150 2150 [log.tag|tag: tip]
2151 2151 [log.user|user: test]
2152 2152 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2153 2153 [ui.note log.description|description:]
2154 2154 [ui.note log.description|Modify, add, remove, rename]
2155 2155
2156 2156 [ui.note log.files|files:]
2157 2157 [status.modified|M third]
2158 2158 [status.added|A b]
2159 2159 [status.added|A fifth]
2160 2160 [status.copied| fourth]
2161 2161 [status.removed|R a]
2162 2162 [status.removed|R fourth]
2163 2163
2164 2164 $ hg --color=debug log -T status -C -r 10 --debug
2165 2165 [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c]
2166 2166 [log.tag|tag: tip]
2167 2167 [log.phase|phase: secret]
2168 2168 [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066]
2169 2169 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2170 2170 [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567]
2171 2171 [log.user|user: test]
2172 2172 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2173 2173 [ui.debug log.extra|extra: branch=default]
2174 2174 [ui.note log.description|description:]
2175 2175 [ui.note log.description|Modify, add, remove, rename]
2176 2176
2177 2177 [ui.note log.files|files:]
2178 2178 [status.modified|M third]
2179 2179 [status.added|A b]
2180 2180 [status.added|A fifth]
2181 2181 [status.copied| fourth]
2182 2182 [status.removed|R a]
2183 2183 [status.removed|R fourth]
2184 2184
2185 2185 $ hg --color=debug log -T status -C -r 10 --quiet
2186 2186 [log.node|10:0f9759ec227a]
2187 2187
2188 2188 Check the bisect template
2189 2189
2190 2190 $ hg bisect -g 1
2191 2191 $ hg bisect -b 3 --noupdate
2192 2192 Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests)
2193 2193 $ hg log -T bisect -r 0:4
2194 2194 changeset: 0:1e4e1b8f71e0
2195 2195 bisect: good (implicit)
2196 2196 user: User Name <user@hostname>
2197 2197 date: Mon Jan 12 13:46:40 1970 +0000
2198 2198 summary: line 1
2199 2199
2200 2200 changeset: 1:b608e9d1a3f0
2201 2201 bisect: good
2202 2202 user: A. N. Other <other@place>
2203 2203 date: Tue Jan 13 17:33:20 1970 +0000
2204 2204 summary: other 1
2205 2205
2206 2206 changeset: 2:97054abb4ab8
2207 2207 bisect: untested
2208 2208 user: other@place
2209 2209 date: Wed Jan 14 21:20:00 1970 +0000
2210 2210 summary: no person
2211 2211
2212 2212 changeset: 3:10e46f2dcbf4
2213 2213 bisect: bad
2214 2214 user: person
2215 2215 date: Fri Jan 16 01:06:40 1970 +0000
2216 2216 summary: no user, no domain
2217 2217
2218 2218 changeset: 4:bbe44766e73d
2219 2219 bisect: bad (implicit)
2220 2220 branch: foo
2221 2221 user: person
2222 2222 date: Sat Jan 17 04:53:20 1970 +0000
2223 2223 summary: new branch
2224 2224
2225 2225 $ hg log --debug -T bisect -r 0:4
2226 2226 changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2227 2227 bisect: good (implicit)
2228 2228 phase: public
2229 2229 parent: -1:0000000000000000000000000000000000000000
2230 2230 parent: -1:0000000000000000000000000000000000000000
2231 2231 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
2232 2232 user: User Name <user@hostname>
2233 2233 date: Mon Jan 12 13:46:40 1970 +0000
2234 2234 files+: a
2235 2235 extra: branch=default
2236 2236 description:
2237 2237 line 1
2238 2238 line 2
2239 2239
2240 2240
2241 2241 changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2242 2242 bisect: good
2243 2243 phase: public
2244 2244 parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2245 2245 parent: -1:0000000000000000000000000000000000000000
2246 2246 manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
2247 2247 user: A. N. Other <other@place>
2248 2248 date: Tue Jan 13 17:33:20 1970 +0000
2249 2249 files+: b
2250 2250 extra: branch=default
2251 2251 description:
2252 2252 other 1
2253 2253 other 2
2254 2254
2255 2255 other 3
2256 2256
2257 2257
2258 2258 changeset: 2:97054abb4ab824450e9164180baf491ae0078465
2259 2259 bisect: untested
2260 2260 phase: public
2261 2261 parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2262 2262 parent: -1:0000000000000000000000000000000000000000
2263 2263 manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
2264 2264 user: other@place
2265 2265 date: Wed Jan 14 21:20:00 1970 +0000
2266 2266 files+: c
2267 2267 extra: branch=default
2268 2268 description:
2269 2269 no person
2270 2270
2271 2271
2272 2272 changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2273 2273 bisect: bad
2274 2274 phase: public
2275 2275 parent: 2:97054abb4ab824450e9164180baf491ae0078465
2276 2276 parent: -1:0000000000000000000000000000000000000000
2277 2277 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2278 2278 user: person
2279 2279 date: Fri Jan 16 01:06:40 1970 +0000
2280 2280 files: c
2281 2281 extra: branch=default
2282 2282 description:
2283 2283 no user, no domain
2284 2284
2285 2285
2286 2286 changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
2287 2287 bisect: bad (implicit)
2288 2288 branch: foo
2289 2289 phase: draft
2290 2290 parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2291 2291 parent: -1:0000000000000000000000000000000000000000
2292 2292 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2293 2293 user: person
2294 2294 date: Sat Jan 17 04:53:20 1970 +0000
2295 2295 extra: branch=foo
2296 2296 description:
2297 2297 new branch
2298 2298
2299 2299
2300 2300 $ hg log -v -T bisect -r 0:4
2301 2301 changeset: 0:1e4e1b8f71e0
2302 2302 bisect: good (implicit)
2303 2303 user: User Name <user@hostname>
2304 2304 date: Mon Jan 12 13:46:40 1970 +0000
2305 2305 files: a
2306 2306 description:
2307 2307 line 1
2308 2308 line 2
2309 2309
2310 2310
2311 2311 changeset: 1:b608e9d1a3f0
2312 2312 bisect: good
2313 2313 user: A. N. Other <other@place>
2314 2314 date: Tue Jan 13 17:33:20 1970 +0000
2315 2315 files: b
2316 2316 description:
2317 2317 other 1
2318 2318 other 2
2319 2319
2320 2320 other 3
2321 2321
2322 2322
2323 2323 changeset: 2:97054abb4ab8
2324 2324 bisect: untested
2325 2325 user: other@place
2326 2326 date: Wed Jan 14 21:20:00 1970 +0000
2327 2327 files: c
2328 2328 description:
2329 2329 no person
2330 2330
2331 2331
2332 2332 changeset: 3:10e46f2dcbf4
2333 2333 bisect: bad
2334 2334 user: person
2335 2335 date: Fri Jan 16 01:06:40 1970 +0000
2336 2336 files: c
2337 2337 description:
2338 2338 no user, no domain
2339 2339
2340 2340
2341 2341 changeset: 4:bbe44766e73d
2342 2342 bisect: bad (implicit)
2343 2343 branch: foo
2344 2344 user: person
2345 2345 date: Sat Jan 17 04:53:20 1970 +0000
2346 2346 description:
2347 2347 new branch
2348 2348
2349 2349
2350 2350 $ hg --color=debug log -T bisect -r 0:4
2351 2351 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2352 2352 [log.bisect bisect.good|bisect: good (implicit)]
2353 2353 [log.user|user: User Name <user@hostname>]
2354 2354 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2355 2355 [log.summary|summary: line 1]
2356 2356
2357 2357 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2358 2358 [log.bisect bisect.good|bisect: good]
2359 2359 [log.user|user: A. N. Other <other@place>]
2360 2360 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2361 2361 [log.summary|summary: other 1]
2362 2362
2363 2363 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2364 2364 [log.bisect bisect.untested|bisect: untested]
2365 2365 [log.user|user: other@place]
2366 2366 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2367 2367 [log.summary|summary: no person]
2368 2368
2369 2369 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2370 2370 [log.bisect bisect.bad|bisect: bad]
2371 2371 [log.user|user: person]
2372 2372 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2373 2373 [log.summary|summary: no user, no domain]
2374 2374
2375 2375 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2376 2376 [log.bisect bisect.bad|bisect: bad (implicit)]
2377 2377 [log.branch|branch: foo]
2378 2378 [log.user|user: person]
2379 2379 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2380 2380 [log.summary|summary: new branch]
2381 2381
2382 2382 $ hg --color=debug log --debug -T bisect -r 0:4
2383 2383 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2384 2384 [log.bisect bisect.good|bisect: good (implicit)]
2385 2385 [log.phase|phase: public]
2386 2386 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2387 2387 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2388 2388 [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0]
2389 2389 [log.user|user: User Name <user@hostname>]
2390 2390 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2391 2391 [ui.debug log.files|files+: a]
2392 2392 [ui.debug log.extra|extra: branch=default]
2393 2393 [ui.note log.description|description:]
2394 2394 [ui.note log.description|line 1
2395 2395 line 2]
2396 2396
2397 2397
2398 2398 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2399 2399 [log.bisect bisect.good|bisect: good]
2400 2400 [log.phase|phase: public]
2401 2401 [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2402 2402 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2403 2403 [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55]
2404 2404 [log.user|user: A. N. Other <other@place>]
2405 2405 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2406 2406 [ui.debug log.files|files+: b]
2407 2407 [ui.debug log.extra|extra: branch=default]
2408 2408 [ui.note log.description|description:]
2409 2409 [ui.note log.description|other 1
2410 2410 other 2
2411 2411
2412 2412 other 3]
2413 2413
2414 2414
2415 2415 [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465]
2416 2416 [log.bisect bisect.untested|bisect: untested]
2417 2417 [log.phase|phase: public]
2418 2418 [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2419 2419 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2420 2420 [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1]
2421 2421 [log.user|user: other@place]
2422 2422 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2423 2423 [ui.debug log.files|files+: c]
2424 2424 [ui.debug log.extra|extra: branch=default]
2425 2425 [ui.note log.description|description:]
2426 2426 [ui.note log.description|no person]
2427 2427
2428 2428
2429 2429 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2430 2430 [log.bisect bisect.bad|bisect: bad]
2431 2431 [log.phase|phase: public]
2432 2432 [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465]
2433 2433 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2434 2434 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2435 2435 [log.user|user: person]
2436 2436 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2437 2437 [ui.debug log.files|files: c]
2438 2438 [ui.debug log.extra|extra: branch=default]
2439 2439 [ui.note log.description|description:]
2440 2440 [ui.note log.description|no user, no domain]
2441 2441
2442 2442
2443 2443 [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74]
2444 2444 [log.bisect bisect.bad|bisect: bad (implicit)]
2445 2445 [log.branch|branch: foo]
2446 2446 [log.phase|phase: draft]
2447 2447 [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2448 2448 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2449 2449 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2450 2450 [log.user|user: person]
2451 2451 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2452 2452 [ui.debug log.extra|extra: branch=foo]
2453 2453 [ui.note log.description|description:]
2454 2454 [ui.note log.description|new branch]
2455 2455
2456 2456
2457 2457 $ hg --color=debug log -v -T bisect -r 0:4
2458 2458 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2459 2459 [log.bisect bisect.good|bisect: good (implicit)]
2460 2460 [log.user|user: User Name <user@hostname>]
2461 2461 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2462 2462 [ui.note log.files|files: a]
2463 2463 [ui.note log.description|description:]
2464 2464 [ui.note log.description|line 1
2465 2465 line 2]
2466 2466
2467 2467
2468 2468 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2469 2469 [log.bisect bisect.good|bisect: good]
2470 2470 [log.user|user: A. N. Other <other@place>]
2471 2471 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2472 2472 [ui.note log.files|files: b]
2473 2473 [ui.note log.description|description:]
2474 2474 [ui.note log.description|other 1
2475 2475 other 2
2476 2476
2477 2477 other 3]
2478 2478
2479 2479
2480 2480 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2481 2481 [log.bisect bisect.untested|bisect: untested]
2482 2482 [log.user|user: other@place]
2483 2483 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2484 2484 [ui.note log.files|files: c]
2485 2485 [ui.note log.description|description:]
2486 2486 [ui.note log.description|no person]
2487 2487
2488 2488
2489 2489 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2490 2490 [log.bisect bisect.bad|bisect: bad]
2491 2491 [log.user|user: person]
2492 2492 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2493 2493 [ui.note log.files|files: c]
2494 2494 [ui.note log.description|description:]
2495 2495 [ui.note log.description|no user, no domain]
2496 2496
2497 2497
2498 2498 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2499 2499 [log.bisect bisect.bad|bisect: bad (implicit)]
2500 2500 [log.branch|branch: foo]
2501 2501 [log.user|user: person]
2502 2502 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2503 2503 [ui.note log.description|description:]
2504 2504 [ui.note log.description|new branch]
2505 2505
2506 2506
2507 2507 $ hg bisect --reset
2508 2508
2509 2509 Error on syntax:
2510 2510
2511 2511 $ echo 'x = "f' >> t
2512 2512 $ hg log
2513 2513 abort: t:3: unmatched quotes
2514 2514 [255]
2515 2515
2516 2516 $ hg log -T '{date'
2517 2517 hg: parse error at 1: unterminated template expansion
2518 2518 [255]
2519 2519
2520 2520 Behind the scenes, this will throw TypeError
2521 2521
2522 2522 $ hg log -l 3 --template '{date|obfuscate}\n'
2523 2523 abort: template filter 'obfuscate' is not compatible with keyword 'date'
2524 2524 [255]
2525 2525
2526 2526 Behind the scenes, this will throw a ValueError
2527 2527
2528 2528 $ hg log -l 3 --template 'line: {desc|shortdate}\n'
2529 2529 abort: template filter 'shortdate' is not compatible with keyword 'desc'
2530 2530 [255]
2531 2531
2532 2532 Behind the scenes, this will throw AttributeError
2533 2533
2534 2534 $ hg log -l 3 --template 'line: {date|escape}\n'
2535 2535 abort: template filter 'escape' is not compatible with keyword 'date'
2536 2536 [255]
2537 2537
2538 2538 Behind the scenes, this will throw ValueError
2539 2539
2540 2540 $ hg tip --template '{author|email|date}\n'
2541 2541 abort: template filter 'datefilter' is not compatible with keyword 'author'
2542 2542 [255]
2543 2543
2544 Error in nested template:
2545
2546 $ hg log -T '{"date'
2547 hg: parse error at 2: unterminated string
2548 [255]
2549
2550 $ hg log -T '{"foo{date|=}"}'
2551 hg: parse error at 11: syntax error
2552 [255]
2553
2544 2554 Thrown an error if a template function doesn't exist
2545 2555
2546 2556 $ hg tip --template '{foo()}\n'
2547 2557 hg: parse error: unknown function 'foo'
2548 2558 [255]
2549 2559
2550 2560 Pass generator object created by template function to filter
2551 2561
2552 2562 $ hg log -l 1 --template '{if(author, author)|user}\n'
2553 2563 test
2554 2564
2555 2565 Test diff function:
2556 2566
2557 2567 $ hg diff -c 8
2558 2568 diff -r 29114dbae42b -r 95c24699272e fourth
2559 2569 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2560 2570 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2561 2571 @@ -0,0 +1,1 @@
2562 2572 +second
2563 2573 diff -r 29114dbae42b -r 95c24699272e second
2564 2574 --- a/second Mon Jan 12 13:46:40 1970 +0000
2565 2575 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2566 2576 @@ -1,1 +0,0 @@
2567 2577 -second
2568 2578 diff -r 29114dbae42b -r 95c24699272e third
2569 2579 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2570 2580 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2571 2581 @@ -0,0 +1,1 @@
2572 2582 +third
2573 2583
2574 2584 $ hg log -r 8 -T "{diff()}"
2575 2585 diff -r 29114dbae42b -r 95c24699272e fourth
2576 2586 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2577 2587 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2578 2588 @@ -0,0 +1,1 @@
2579 2589 +second
2580 2590 diff -r 29114dbae42b -r 95c24699272e second
2581 2591 --- a/second Mon Jan 12 13:46:40 1970 +0000
2582 2592 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2583 2593 @@ -1,1 +0,0 @@
2584 2594 -second
2585 2595 diff -r 29114dbae42b -r 95c24699272e third
2586 2596 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2587 2597 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2588 2598 @@ -0,0 +1,1 @@
2589 2599 +third
2590 2600
2591 2601 $ hg log -r 8 -T "{diff('glob:f*')}"
2592 2602 diff -r 29114dbae42b -r 95c24699272e fourth
2593 2603 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2594 2604 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2595 2605 @@ -0,0 +1,1 @@
2596 2606 +second
2597 2607
2598 2608 $ hg log -r 8 -T "{diff('', 'glob:f*')}"
2599 2609 diff -r 29114dbae42b -r 95c24699272e second
2600 2610 --- a/second Mon Jan 12 13:46:40 1970 +0000
2601 2611 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2602 2612 @@ -1,1 +0,0 @@
2603 2613 -second
2604 2614 diff -r 29114dbae42b -r 95c24699272e third
2605 2615 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2606 2616 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2607 2617 @@ -0,0 +1,1 @@
2608 2618 +third
2609 2619
2610 2620 $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
2611 2621 diff -r 29114dbae42b -r 95c24699272e fourth
2612 2622 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2613 2623 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2614 2624 @@ -0,0 +1,1 @@
2615 2625 +second
2616 2626
2617 2627 $ cd ..
2618 2628
2619 2629
2620 2630 latesttag:
2621 2631
2622 2632 $ hg init latesttag
2623 2633 $ cd latesttag
2624 2634
2625 2635 $ echo a > file
2626 2636 $ hg ci -Am a -d '0 0'
2627 2637 adding file
2628 2638
2629 2639 $ echo b >> file
2630 2640 $ hg ci -m b -d '1 0'
2631 2641
2632 2642 $ echo c >> head1
2633 2643 $ hg ci -Am h1c -d '2 0'
2634 2644 adding head1
2635 2645
2636 2646 $ hg update -q 1
2637 2647 $ echo d >> head2
2638 2648 $ hg ci -Am h2d -d '3 0'
2639 2649 adding head2
2640 2650 created new head
2641 2651
2642 2652 $ echo e >> head2
2643 2653 $ hg ci -m h2e -d '4 0'
2644 2654
2645 2655 $ hg merge -q
2646 2656 $ hg ci -m merge -d '5 -3600'
2647 2657
2648 2658 No tag set:
2649 2659
2650 2660 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
2651 2661 5: null+5
2652 2662 4: null+4
2653 2663 3: null+3
2654 2664 2: null+3
2655 2665 1: null+2
2656 2666 0: null+1
2657 2667
2658 2668 One common tag: longest path wins:
2659 2669
2660 2670 $ hg tag -r 1 -m t1 -d '6 0' t1
2661 2671 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
2662 2672 6: t1+4
2663 2673 5: t1+3
2664 2674 4: t1+2
2665 2675 3: t1+1
2666 2676 2: t1+1
2667 2677 1: t1+0
2668 2678 0: null+1
2669 2679
2670 2680 One ancestor tag: more recent wins:
2671 2681
2672 2682 $ hg tag -r 2 -m t2 -d '7 0' t2
2673 2683 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
2674 2684 7: t2+3
2675 2685 6: t2+2
2676 2686 5: t2+1
2677 2687 4: t1+2
2678 2688 3: t1+1
2679 2689 2: t2+0
2680 2690 1: t1+0
2681 2691 0: null+1
2682 2692
2683 2693 Two branch tags: more recent wins:
2684 2694
2685 2695 $ hg tag -r 3 -m t3 -d '8 0' t3
2686 2696 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
2687 2697 8: t3+5
2688 2698 7: t3+4
2689 2699 6: t3+3
2690 2700 5: t3+2
2691 2701 4: t3+1
2692 2702 3: t3+0
2693 2703 2: t2+0
2694 2704 1: t1+0
2695 2705 0: null+1
2696 2706
2697 2707 Merged tag overrides:
2698 2708
2699 2709 $ hg tag -r 5 -m t5 -d '9 0' t5
2700 2710 $ hg tag -r 3 -m at3 -d '10 0' at3
2701 2711 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
2702 2712 10: t5+5
2703 2713 9: t5+4
2704 2714 8: t5+3
2705 2715 7: t5+2
2706 2716 6: t5+1
2707 2717 5: t5+0
2708 2718 4: at3:t3+1
2709 2719 3: at3:t3+0
2710 2720 2: t2+0
2711 2721 1: t1+0
2712 2722 0: null+1
2713 2723
2714 2724 $ cd ..
2715 2725
2716 2726
2717 2727 Style path expansion: issue1948 - ui.style option doesn't work on OSX
2718 2728 if it is a relative path
2719 2729
2720 2730 $ mkdir -p home/styles
2721 2731
2722 2732 $ cat > home/styles/teststyle <<EOF
2723 2733 > changeset = 'test {rev}:{node|short}\n'
2724 2734 > EOF
2725 2735
2726 2736 $ HOME=`pwd`/home; export HOME
2727 2737
2728 2738 $ cat > latesttag/.hg/hgrc <<EOF
2729 2739 > [ui]
2730 2740 > style = ~/styles/teststyle
2731 2741 > EOF
2732 2742
2733 2743 $ hg -R latesttag tip
2734 2744 test 10:9b4a630e5f5f
2735 2745
2736 2746 Test recursive showlist template (issue1989):
2737 2747
2738 2748 $ cat > style1989 <<EOF
2739 2749 > changeset = '{file_mods}{manifest}{extras}'
2740 2750 > file_mod = 'M|{author|person}\n'
2741 2751 > manifest = '{rev},{author}\n'
2742 2752 > extra = '{key}: {author}\n'
2743 2753 > EOF
2744 2754
2745 2755 $ hg -R latesttag log -r tip --style=style1989
2746 2756 M|test
2747 2757 10,test
2748 2758 branch: test
2749 2759
2750 2760 Test new-style inline templating:
2751 2761
2752 2762 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
2753 2763 modified files: .hgtags
2754 2764
2755 2765 Test the sub function of templating for expansion:
2756 2766
2757 2767 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
2758 2768 xx
2759 2769
2760 2770 Test the strip function with chars specified:
2761 2771
2762 2772 $ hg log -R latesttag --template '{desc}\n'
2763 2773 at3
2764 2774 t5
2765 2775 t3
2766 2776 t2
2767 2777 t1
2768 2778 merge
2769 2779 h2e
2770 2780 h2d
2771 2781 h1c
2772 2782 b
2773 2783 a
2774 2784
2775 2785 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
2776 2786 at3
2777 2787 5
2778 2788 3
2779 2789 2
2780 2790 1
2781 2791 merg
2782 2792 h2
2783 2793 h2d
2784 2794 h1c
2785 2795 b
2786 2796 a
2787 2797
2788 2798 Test date format:
2789 2799
2790 2800 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
2791 2801 date: 70 01 01 10 +0000
2792 2802 date: 70 01 01 09 +0000
2793 2803 date: 70 01 01 08 +0000
2794 2804 date: 70 01 01 07 +0000
2795 2805 date: 70 01 01 06 +0000
2796 2806 date: 70 01 01 05 +0100
2797 2807 date: 70 01 01 04 +0000
2798 2808 date: 70 01 01 03 +0000
2799 2809 date: 70 01 01 02 +0000
2800 2810 date: 70 01 01 01 +0000
2801 2811 date: 70 01 01 00 +0000
2802 2812
2803 2813 Test invalid date:
2804 2814
2805 2815 $ hg log -R latesttag -T '{date(rev)}\n'
2806 2816 hg: parse error: date expects a date information
2807 2817 [255]
2808 2818
2809 2819 Test integer literal:
2810 2820
2811 2821 $ hg log -Ra -r0 -T '{(0)}\n'
2812 2822 0
2813 2823 $ hg log -Ra -r0 -T '{(123)}\n'
2814 2824 123
2815 2825 $ hg log -Ra -r0 -T '{(-4)}\n'
2816 2826 -4
2817 2827 $ hg log -Ra -r0 -T '{(-)}\n'
2818 2828 hg: parse error at 2: integer literal without digits
2819 2829 [255]
2820 2830 $ hg log -Ra -r0 -T '{(-a)}\n'
2821 2831 hg: parse error at 2: integer literal without digits
2822 2832 [255]
2823 2833
2824 2834 top-level integer literal is interpreted as symbol (i.e. variable name):
2825 2835
2826 2836 $ hg log -Ra -r0 -T '{1}\n'
2827 2837
2828 2838 $ hg log -Ra -r0 -T '{if("t", "{1}")}\n'
2829 2839
2830 2840 $ hg log -Ra -r0 -T '{1|stringify}\n'
2831 2841
2832 2842
2833 2843 unless explicit symbol is expected:
2834 2844
2835 2845 $ hg log -Ra -r0 -T '{desc|1}\n'
2836 2846 hg: parse error: expected a symbol, got 'integer'
2837 2847 [255]
2838 2848 $ hg log -Ra -r0 -T '{1()}\n'
2839 2849 hg: parse error: expected a symbol, got 'integer'
2840 2850 [255]
2841 2851
2842 2852 Test string literal:
2843 2853
2844 2854 $ hg log -Ra -r0 -T '{"string with no template fragment"}\n'
2845 2855 string with no template fragment
2846 2856 $ hg log -Ra -r0 -T '{"template: {rev}"}\n'
2847 2857 template: 0
2848 2858 $ hg log -Ra -r0 -T '{r"rawstring: {rev}"}\n'
2849 2859 rawstring: {rev}
2850 2860
2851 2861 because map operation requires template, raw string can't be used
2852 2862
2853 2863 $ hg log -Ra -r0 -T '{files % r"rawstring"}\n'
2854 2864 hg: parse error: expected template specifier
2855 2865 [255]
2856 2866
2857 2867 Test string escaping:
2858 2868
2859 2869 $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2860 2870 >
2861 2871 <>\n<[>
2862 2872 <>\n<]>
2863 2873 <>\n<
2864 2874
2865 2875 $ hg log -R latesttag -r 0 \
2866 2876 > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2867 2877 >
2868 2878 <>\n<[>
2869 2879 <>\n<]>
2870 2880 <>\n<
2871 2881
2872 2882 $ hg log -R latesttag -r 0 -T esc \
2873 2883 > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2874 2884 >
2875 2885 <>\n<[>
2876 2886 <>\n<]>
2877 2887 <>\n<
2878 2888
2879 2889 $ cat <<'EOF' > esctmpl
2880 2890 > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2881 2891 > EOF
2882 2892 $ hg log -R latesttag -r 0 --style ./esctmpl
2883 2893 >
2884 2894 <>\n<[>
2885 2895 <>\n<]>
2886 2896 <>\n<
2887 2897
2888 2898 Test string escaping of quotes:
2889 2899
2890 2900 $ hg log -Ra -r0 -T '{"\""}\n'
2891 2901 "
2892 2902 $ hg log -Ra -r0 -T '{"\\\""}\n'
2893 2903 \"
2894 2904 $ hg log -Ra -r0 -T '{r"\""}\n'
2895 2905 \"
2896 2906 $ hg log -Ra -r0 -T '{r"\\\""}\n'
2897 2907 \\\"
2898 2908
2899 2909
2900 2910 $ hg log -Ra -r0 -T '{"\""}\n'
2901 2911 "
2902 2912 $ hg log -Ra -r0 -T '{"\\\""}\n'
2903 2913 \"
2904 2914 $ hg log -Ra -r0 -T '{r"\""}\n'
2905 2915 \"
2906 2916 $ hg log -Ra -r0 -T '{r"\\\""}\n'
2907 2917 \\\"
2908 2918
2909 2919 Test exception in quoted template. single backslash before quotation mark is
2910 2920 stripped before parsing:
2911 2921
2912 2922 $ cat <<'EOF' > escquotetmpl
2913 2923 > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n"
2914 2924 > EOF
2915 2925 $ cd latesttag
2916 2926 $ hg log -r 2 --style ../escquotetmpl
2917 2927 " \" \" \\" head1
2918 2928
2919 2929 $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"'
2920 2930 valid
2921 2931 $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'"
2922 2932 valid
2923 2933
2924 2934 Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested
2925 2935 _evalifliteral() templates (issue4733):
2926 2936
2927 2937 $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n'
2928 2938 "2
2929 2939 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n'
2930 2940 "2
2931 2941 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n'
2932 2942 "2
2933 2943
2934 2944 $ hg log -r 2 -T '{if(rev, "\\\"")}\n'
2935 2945 \"
2936 2946 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n'
2937 2947 \"
2938 2948 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
2939 2949 \"
2940 2950
2941 2951 $ hg log -r 2 -T '{if(rev, r"\\\"")}\n'
2942 2952 \\\"
2943 2953 $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n'
2944 2954 \\\"
2945 2955 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
2946 2956 \\\"
2947 2957
2948 2958 escaped single quotes and errors:
2949 2959
2950 2960 $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n'
2951 2961 foo
2952 2962 $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n'
2953 2963 foo
2954 2964 $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n'
2955 hg: parse error at 11: unterminated string
2965 hg: parse error at 21: unterminated string
2956 2966 [255]
2957 2967 $ hg log -r 2 -T '{if(rev, \"\\"")}\n'
2958 2968 hg: parse error at 11: syntax error
2959 2969 [255]
2960 2970 $ hg log -r 2 -T '{if(rev, r\"\\"")}\n'
2961 2971 hg: parse error at 12: syntax error
2962 2972 [255]
2963 2973
2964 2974 $ cd ..
2965 2975
2966 2976 Test leading backslashes:
2967 2977
2968 2978 $ cd latesttag
2969 2979 $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n'
2970 2980 {rev} {file}
2971 2981 $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n'
2972 2982 \2 \head1
2973 2983 $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n'
2974 2984 \{rev} \{file}
2975 2985 $ cd ..
2976 2986
2977 2987 Test leading backslashes in "if" expression (issue4714):
2978 2988
2979 2989 $ cd latesttag
2980 2990 $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n'
2981 2991 {rev} \{rev}
2982 2992 $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n'
2983 2993 \2 \\{rev}
2984 2994 $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n'
2985 2995 \{rev} \\\{rev}
2986 2996 $ cd ..
2987 2997
2988 2998 "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
2989 2999
2990 3000 $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
2991 3001 \x6e
2992 3002 $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
2993 3003 \x5c\x786e
2994 3004 $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
2995 3005 \x6e
2996 3006 $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
2997 3007 \x5c\x786e
2998 3008
2999 3009 $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
3000 3010 \x6e
3001 3011 $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
3002 3012 \x5c\x786e
3003 3013 $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
3004 3014 \x6e
3005 3015 $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
3006 3016 \x5c\x786e
3007 3017
3008 3018 $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
3009 3019 fourth
3010 3020 second
3011 3021 third
3012 3022 $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
3013 3023 fourth\nsecond\nthird
3014 3024
3015 3025 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
3016 3026 <p>
3017 3027 1st
3018 3028 </p>
3019 3029 <p>
3020 3030 2nd
3021 3031 </p>
3022 3032 $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
3023 3033 <p>
3024 3034 1st\n\n2nd
3025 3035 </p>
3026 3036 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
3027 3037 1st
3028 3038
3029 3039 2nd
3030 3040
3031 3041 $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
3032 3042 o perso
3033 3043 $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
3034 3044 no person
3035 3045 $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
3036 3046 o perso
3037 3047 $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
3038 3048 no perso
3039 3049
3040 3050 $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
3041 3051 -o perso-
3042 3052 $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
3043 3053 no person
3044 3054 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
3045 3055 \x2do perso\x2d
3046 3056 $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
3047 3057 -o perso-
3048 3058 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
3049 3059 \x2do perso\x6e
3050 3060
3051 3061 $ hg log -R a -r 8 --template '{files % "{file}\n"}'
3052 3062 fourth
3053 3063 second
3054 3064 third
3055 3065
3056 3066 Test string escaping in nested expression:
3057 3067
3058 3068 $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
3059 3069 fourth\x6esecond\x6ethird
3060 3070 $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
3061 3071 fourth\x6esecond\x6ethird
3062 3072
3063 3073 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
3064 3074 fourth\x6esecond\x6ethird
3065 3075 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
3066 3076 fourth\x5c\x786esecond\x5c\x786ethird
3067 3077
3068 3078 $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
3069 3079 3:\x6eo user, \x6eo domai\x6e
3070 3080 4:\x5c\x786eew bra\x5c\x786ech
3071 3081
3082 Test quotes in nested expression are evaluated just like a $(command)
3083 substitution in POSIX shells:
3084
3085 $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n'
3086 8:95c24699272e
3087 $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n'
3088 {8} "95c24699272e"
3089
3072 3090 Test recursive evaluation:
3073 3091
3074 3092 $ hg init r
3075 3093 $ cd r
3076 3094 $ echo a > a
3077 3095 $ hg ci -Am '{rev}'
3078 3096 adding a
3079 3097 $ hg log -r 0 --template '{if(rev, desc)}\n'
3080 3098 {rev}
3081 3099 $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n'
3082 3100 test 0
3083 3101
3084 3102 $ hg branch -q 'text.{rev}'
3085 3103 $ echo aa >> aa
3086 3104 $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
3087 3105
3088 3106 $ hg log -l1 --template '{fill(desc, "20", author, branch)}'
3089 3107 {node|short}desc to
3090 3108 text.{rev}be wrapped
3091 3109 text.{rev}desc to be
3092 3110 text.{rev}wrapped (no-eol)
3093 3111 $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}'
3094 3112 bcc7ff960b8e:desc to
3095 3113 text.1:be wrapped
3096 3114 text.1:desc to be
3097 3115 text.1:wrapped (no-eol)
3098 3116
3099 3117 $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}'
3100 3118 {node|short} (no-eol)
3101 3119 $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}'
3102 3120 bcc-ff---b-e (no-eol)
3103 3121
3104 3122 $ cat >> .hg/hgrc <<EOF
3105 3123 > [extensions]
3106 3124 > color=
3107 3125 > [color]
3108 3126 > mode=ansi
3109 3127 > text.{rev} = red
3110 3128 > text.1 = green
3111 3129 > EOF
3112 3130 $ hg log --color=always -l 1 --template '{label(branch, "text\n")}'
3113 3131 \x1b[0;31mtext\x1b[0m (esc)
3114 3132 $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}'
3115 3133 \x1b[0;32mtext\x1b[0m (esc)
3116 3134
3117 3135 Test branches inside if statement:
3118 3136
3119 3137 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
3120 3138 no
3121 3139
3122 3140 Test get function:
3123 3141
3124 3142 $ hg log -r 0 --template '{get(extras, "branch")}\n'
3125 3143 default
3126 3144 $ hg log -r 0 --template '{get(files, "should_fail")}\n'
3127 3145 hg: parse error: get() expects a dict as first argument
3128 3146 [255]
3129 3147
3130 3148 Test shortest(node) function:
3131 3149
3132 3150 $ echo b > b
3133 3151 $ hg ci -qAm b
3134 3152 $ hg log --template '{shortest(node)}\n'
3135 3153 e777
3136 3154 bcc7
3137 3155 f776
3138 3156 $ hg log --template '{shortest(node, 10)}\n'
3139 3157 e777603221
3140 3158 bcc7ff960b
3141 3159 f7769ec2ab
3142 3160
3143 3161 Test pad function
3144 3162
3145 3163 $ hg log --template '{pad(rev, 20)} {author|user}\n'
3146 3164 2 test
3147 3165 1 {node|short}
3148 3166 0 test
3149 3167
3150 3168 $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n'
3151 3169 2 test
3152 3170 1 {node|short}
3153 3171 0 test
3154 3172
3155 3173 $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n'
3156 3174 2------------------- test
3157 3175 1------------------- {node|short}
3158 3176 0------------------- test
3159 3177
3160 3178 Test template string in pad function
3161 3179
3162 3180 $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n'
3163 3181 {0} test
3164 3182
3165 3183 $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n'
3166 3184 \{rev} test
3167 3185
3168 3186 Test ifcontains function
3169 3187
3170 3188 $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n'
3171 3189 2 is in the string
3172 3190 1 is not
3173 3191 0 is in the string
3174 3192
3175 3193 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
3176 3194 2 did not add a
3177 3195 1 did not add a
3178 3196 0 added a
3179 3197
3180 3198 Test revset function
3181 3199
3182 3200 $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n'
3183 3201 2 current rev
3184 3202 1 not current rev
3185 3203 0 not current rev
3186 3204
3187 3205 $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n'
3188 3206 2 match rev
3189 3207 1 match rev
3190 3208 0 not match rev
3191 3209
3192 3210 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n'
3193 3211 2 Parents: 1
3194 3212 1 Parents: 0
3195 3213 0 Parents:
3196 3214
3197 3215 $ cat >> .hg/hgrc <<EOF
3198 3216 > [revsetalias]
3199 3217 > myparents(\$1) = parents(\$1)
3200 3218 > EOF
3201 3219 $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n'
3202 3220 2 Parents: 1
3203 3221 1 Parents: 0
3204 3222 0 Parents:
3205 3223
3206 3224 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
3207 3225 Rev: 2
3208 3226 Ancestor: 0
3209 3227 Ancestor: 1
3210 3228 Ancestor: 2
3211 3229
3212 3230 Rev: 1
3213 3231 Ancestor: 0
3214 3232 Ancestor: 1
3215 3233
3216 3234 Rev: 0
3217 3235 Ancestor: 0
3218 3236
3219 3237 $ hg log --template '{revset("TIP"|lower)}\n' -l1
3220 3238 2
3221 3239
3222 3240 Test active bookmark templating
3223 3241
3224 3242 $ hg book foo
3225 3243 $ hg book bar
3226 3244 $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n"
3227 3245 2 bar* foo
3228 3246 1
3229 3247 0
3230 3248 $ hg log --template "{rev} {activebookmark}\n"
3231 3249 2 bar
3232 3250 1
3233 3251 0
3234 3252 $ hg bookmarks --inactive bar
3235 3253 $ hg log --template "{rev} {activebookmark}\n"
3236 3254 2
3237 3255 1
3238 3256 0
3239 3257 $ hg book -r1 baz
3240 3258 $ hg log --template "{rev} {join(bookmarks, ' ')}\n"
3241 3259 2 bar foo
3242 3260 1 baz
3243 3261 0
3244 3262 $ hg log --template "{rev} {ifcontains('foo', bookmarks, 't', 'f')}\n"
3245 3263 2 t
3246 3264 1 f
3247 3265 0 f
3248 3266
3249 3267 Test stringify on sub expressions
3250 3268
3251 3269 $ cd ..
3252 3270 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
3253 3271 fourth, second, third
3254 3272 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
3255 3273 abc
3256 3274
3257 3275 Test splitlines
3258 3276
3259 3277 $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}"
3260 3278 @ foo Modify, add, remove, rename
3261 3279 |
3262 3280 o foo future
3263 3281 |
3264 3282 o foo third
3265 3283 |
3266 3284 o foo second
3267 3285
3268 3286 o foo merge
3269 3287 |\
3270 3288 | o foo new head
3271 3289 | |
3272 3290 o | foo new branch
3273 3291 |/
3274 3292 o foo no user, no domain
3275 3293 |
3276 3294 o foo no person
3277 3295 |
3278 3296 o foo other 1
3279 3297 | foo other 2
3280 3298 | foo
3281 3299 | foo other 3
3282 3300 o foo line 1
3283 3301 foo line 2
3284 3302
3285 3303 Test startswith
3286 3304 $ hg log -Gv -R a --template "{startswith(desc)}"
3287 3305 hg: parse error: startswith expects two arguments
3288 3306 [255]
3289 3307
3290 3308 $ hg log -Gv -R a --template "{startswith('line', desc)}"
3291 3309 @
3292 3310 |
3293 3311 o
3294 3312 |
3295 3313 o
3296 3314 |
3297 3315 o
3298 3316
3299 3317 o
3300 3318 |\
3301 3319 | o
3302 3320 | |
3303 3321 o |
3304 3322 |/
3305 3323 o
3306 3324 |
3307 3325 o
3308 3326 |
3309 3327 o
3310 3328 |
3311 3329 o line 1
3312 3330 line 2
3313 3331
3314 3332 Test bad template with better error message
3315 3333
3316 3334 $ hg log -Gv -R a --template '{desc|user()}'
3317 3335 hg: parse error: expected a symbol, got 'func'
3318 3336 [255]
3319 3337
3320 3338 Test word function (including index out of bounds graceful failure)
3321 3339
3322 3340 $ hg log -Gv -R a --template "{word('1', desc)}"
3323 3341 @ add,
3324 3342 |
3325 3343 o
3326 3344 |
3327 3345 o
3328 3346 |
3329 3347 o
3330 3348
3331 3349 o
3332 3350 |\
3333 3351 | o head
3334 3352 | |
3335 3353 o | branch
3336 3354 |/
3337 3355 o user,
3338 3356 |
3339 3357 o person
3340 3358 |
3341 3359 o 1
3342 3360 |
3343 3361 o 1
3344 3362
3345 3363
3346 3364 Test word third parameter used as splitter
3347 3365
3348 3366 $ hg log -Gv -R a --template "{word('0', desc, 'o')}"
3349 3367 @ M
3350 3368 |
3351 3369 o future
3352 3370 |
3353 3371 o third
3354 3372 |
3355 3373 o sec
3356 3374
3357 3375 o merge
3358 3376 |\
3359 3377 | o new head
3360 3378 | |
3361 3379 o | new branch
3362 3380 |/
3363 3381 o n
3364 3382 |
3365 3383 o n
3366 3384 |
3367 3385 o
3368 3386 |
3369 3387 o line 1
3370 3388 line 2
3371 3389
3372 3390 Test word error messages for not enough and too many arguments
3373 3391
3374 3392 $ hg log -Gv -R a --template "{word('0')}"
3375 3393 hg: parse error: word expects two or three arguments, got 1
3376 3394 [255]
3377 3395
3378 3396 $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}"
3379 3397 hg: parse error: word expects two or three arguments, got 7
3380 3398 [255]
3381 3399
3382 3400 Test word for integer literal
3383 3401
3384 3402 $ hg log -R a --template "{word(2, desc)}\n" -r0
3385 3403 line
3386 3404
3387 3405 Test word for invalid numbers
3388 3406
3389 3407 $ hg log -Gv -R a --template "{word('a', desc)}"
3390 3408 hg: parse error: word expects an integer index
3391 3409 [255]
3392 3410
3393 3411 Test indent and not adding to empty lines
3394 3412
3395 3413 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
3396 3414 -----
3397 3415 > line 1
3398 3416 >> line 2
3399 3417 -----
3400 3418 > other 1
3401 3419 >> other 2
3402 3420
3403 3421 >> other 3
3404 3422
3405 3423 Test with non-strings like dates
3406 3424
3407 3425 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a
3408 3426 1200000.00
3409 3427 1300000.00
@@ -1,36 +1,37
1 1 # this is hack to make sure no escape characters are inserted into the output
2 2 import os, sys
3 3 if 'TERM' in os.environ:
4 4 del os.environ['TERM']
5 5 import doctest
6 6
7 7 def testmod(name, optionflags=0, testtarget=None):
8 8 __import__(name)
9 9 mod = sys.modules[name]
10 10 if testtarget is not None:
11 11 mod = getattr(mod, testtarget)
12 12 doctest.testmod(mod, optionflags=optionflags)
13 13
14 14 testmod('mercurial.changelog')
15 15 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
16 16 testmod('mercurial.dispatch')
17 17 testmod('mercurial.encoding')
18 18 testmod('mercurial.hg')
19 19 testmod('mercurial.hgweb.hgwebdir_mod')
20 20 testmod('mercurial.match')
21 21 testmod('mercurial.minirst')
22 22 testmod('mercurial.patch')
23 23 testmod('mercurial.pathutil')
24 24 testmod('mercurial.parser')
25 25 testmod('mercurial.revset')
26 26 testmod('mercurial.store')
27 27 testmod('mercurial.subrepo')
28 28 testmod('mercurial.templatefilters')
29 testmod('mercurial.templater')
29 30 testmod('mercurial.ui')
30 31 testmod('mercurial.url')
31 32 testmod('mercurial.util')
32 33 testmod('mercurial.util', testtarget='platform')
33 34 testmod('hgext.convert.cvsps')
34 35 testmod('hgext.convert.filemap')
35 36 testmod('hgext.convert.subversion')
36 37 testmod('hgext.mq')
General Comments 0
You need to be logged in to leave comments. Login now