##// END OF EJS Templates
templater: raise error for unknown func...
Sean Farley -
r20857:6eb55310 stable
parent child Browse files
Show More
@@ -1,588 +1,589 b''
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 sys, os, re
10 10 import util, config, templatefilters, parser, error
11 11 import types
12 12 import minirst
13 13
14 14 # template parsing
15 15
16 16 elements = {
17 17 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
18 18 ",": (2, None, ("list", 2)),
19 19 "|": (5, None, ("|", 5)),
20 20 "%": (6, None, ("%", 6)),
21 21 ")": (0, None, None),
22 22 "symbol": (0, ("symbol",), None),
23 23 "string": (0, ("string",), None),
24 24 "rawstring": (0, ("rawstring",), None),
25 25 "end": (0, None, None),
26 26 }
27 27
28 28 def tokenizer(data):
29 29 program, start, end = data
30 30 pos = start
31 31 while pos < end:
32 32 c = program[pos]
33 33 if c.isspace(): # skip inter-token whitespace
34 34 pass
35 35 elif c in "(,)%|": # handle simple operators
36 36 yield (c, None, pos)
37 37 elif (c in '"\'' or c == 'r' and
38 38 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
39 39 if c == 'r':
40 40 pos += 1
41 41 c = program[pos]
42 42 decode = False
43 43 else:
44 44 decode = True
45 45 pos += 1
46 46 s = pos
47 47 while pos < end: # find closing quote
48 48 d = program[pos]
49 49 if decode and d == '\\': # skip over escaped characters
50 50 pos += 2
51 51 continue
52 52 if d == c:
53 53 if not decode:
54 54 yield ('rawstring', program[s:pos], s)
55 55 break
56 56 yield ('string', program[s:pos], s)
57 57 break
58 58 pos += 1
59 59 else:
60 60 raise error.ParseError(_("unterminated string"), s)
61 61 elif c.isalnum() or c in '_':
62 62 s = pos
63 63 pos += 1
64 64 while pos < end: # find end of symbol
65 65 d = program[pos]
66 66 if not (d.isalnum() or d == "_"):
67 67 break
68 68 pos += 1
69 69 sym = program[s:pos]
70 70 yield ('symbol', sym, s)
71 71 pos -= 1
72 72 elif c == '}':
73 73 pos += 1
74 74 break
75 75 else:
76 76 raise error.ParseError(_("syntax error"), pos)
77 77 pos += 1
78 78 yield ('end', None, pos)
79 79
80 80 def compiletemplate(tmpl, context, strtoken="string"):
81 81 parsed = []
82 82 pos, stop = 0, len(tmpl)
83 83 p = parser.parser(tokenizer, elements)
84 84 while pos < stop:
85 85 n = tmpl.find('{', pos)
86 86 if n < 0:
87 87 parsed.append((strtoken, tmpl[pos:]))
88 88 break
89 89 if n > 0 and tmpl[n - 1] == '\\':
90 90 # escaped
91 91 parsed.append((strtoken, (tmpl[pos:n - 1] + "{")))
92 92 pos = n + 1
93 93 continue
94 94 if n > pos:
95 95 parsed.append((strtoken, tmpl[pos:n]))
96 96
97 97 pd = [tmpl, n + 1, stop]
98 98 parseres, pos = p.parse(pd)
99 99 parsed.append(parseres)
100 100
101 101 return [compileexp(e, context) for e in parsed]
102 102
103 103 def compileexp(exp, context):
104 104 t = exp[0]
105 105 if t in methods:
106 106 return methods[t](exp, context)
107 107 raise error.ParseError(_("unknown method '%s'") % t)
108 108
109 109 # template evaluation
110 110
111 111 def getsymbol(exp):
112 112 if exp[0] == 'symbol':
113 113 return exp[1]
114 114 raise error.ParseError(_("expected a symbol"))
115 115
116 116 def getlist(x):
117 117 if not x:
118 118 return []
119 119 if x[0] == 'list':
120 120 return getlist(x[1]) + [x[2]]
121 121 return [x]
122 122
123 123 def getfilter(exp, context):
124 124 f = getsymbol(exp)
125 125 if f not in context._filters:
126 126 raise error.ParseError(_("unknown function '%s'") % f)
127 127 return context._filters[f]
128 128
129 129 def gettemplate(exp, context):
130 130 if exp[0] == 'string' or exp[0] == 'rawstring':
131 131 return compiletemplate(exp[1], context, strtoken=exp[0])
132 132 if exp[0] == 'symbol':
133 133 return context._load(exp[1])
134 134 raise error.ParseError(_("expected template specifier"))
135 135
136 136 def runstring(context, mapping, data):
137 137 return data.decode("string-escape")
138 138
139 139 def runrawstring(context, mapping, data):
140 140 return data
141 141
142 142 def runsymbol(context, mapping, key):
143 143 v = mapping.get(key)
144 144 if v is None:
145 145 v = context._defaults.get(key)
146 146 if v is None:
147 147 try:
148 148 v = context.process(key, mapping)
149 149 except TemplateNotFound:
150 150 v = ''
151 151 if util.safehasattr(v, '__call__'):
152 152 return v(**mapping)
153 153 if isinstance(v, types.GeneratorType):
154 154 v = list(v)
155 155 mapping[key] = v
156 156 return v
157 157 return v
158 158
159 159 def buildfilter(exp, context):
160 160 func, data = compileexp(exp[1], context)
161 161 filt = getfilter(exp[2], context)
162 162 return (runfilter, (func, data, filt))
163 163
164 164 def runfilter(context, mapping, data):
165 165 func, data, filt = data
166 166 try:
167 167 return filt(func(context, mapping, data))
168 168 except (ValueError, AttributeError, TypeError):
169 169 if isinstance(data, tuple):
170 170 dt = data[1]
171 171 else:
172 172 dt = data
173 173 raise util.Abort(_("template filter '%s' is not compatible with "
174 174 "keyword '%s'") % (filt.func_name, dt))
175 175
176 176 def buildmap(exp, context):
177 177 func, data = compileexp(exp[1], context)
178 178 ctmpl = gettemplate(exp[2], context)
179 179 return (runmap, (func, data, ctmpl))
180 180
181 181 def runtemplate(context, mapping, template):
182 182 for func, data in template:
183 183 yield func(context, mapping, data)
184 184
185 185 def runmap(context, mapping, data):
186 186 func, data, ctmpl = data
187 187 d = func(context, mapping, data)
188 188 if util.safehasattr(d, '__call__'):
189 189 d = d()
190 190
191 191 lm = mapping.copy()
192 192
193 193 for i in d:
194 194 if isinstance(i, dict):
195 195 lm.update(i)
196 196 lm['originalnode'] = mapping.get('node')
197 197 yield runtemplate(context, lm, ctmpl)
198 198 else:
199 199 # v is not an iterable of dicts, this happen when 'key'
200 200 # has been fully expanded already and format is useless.
201 201 # If so, return the expanded value.
202 202 yield i
203 203
204 204 def buildfunc(exp, context):
205 205 n = getsymbol(exp[1])
206 206 args = [compileexp(x, context) for x in getlist(exp[2])]
207 207 if n in funcs:
208 208 f = funcs[n]
209 209 return (f, args)
210 210 if n in context._filters:
211 211 if len(args) != 1:
212 212 raise error.ParseError(_("filter %s expects one argument") % n)
213 213 f = context._filters[n]
214 214 return (runfilter, (args[0][0], args[0][1], f))
215 raise error.ParseError(_("unknown function '%s'") % n)
215 216
216 217 def date(context, mapping, args):
217 218 if not (1 <= len(args) <= 2):
218 219 raise error.ParseError(_("date expects one or two arguments"))
219 220
220 221 date = args[0][0](context, mapping, args[0][1])
221 222 if len(args) == 2:
222 223 fmt = stringify(args[1][0](context, mapping, args[1][1]))
223 224 return util.datestr(date, fmt)
224 225 return util.datestr(date)
225 226
226 227 def fill(context, mapping, args):
227 228 if not (1 <= len(args) <= 4):
228 229 raise error.ParseError(_("fill expects one to four arguments"))
229 230
230 231 text = stringify(args[0][0](context, mapping, args[0][1]))
231 232 width = 76
232 233 initindent = ''
233 234 hangindent = ''
234 235 if 2 <= len(args) <= 4:
235 236 try:
236 237 width = int(stringify(args[1][0](context, mapping, args[1][1])))
237 238 except ValueError:
238 239 raise error.ParseError(_("fill expects an integer width"))
239 240 try:
240 241 initindent = stringify(_evalifliteral(args[2], context, mapping))
241 242 hangindent = stringify(_evalifliteral(args[3], context, mapping))
242 243 except IndexError:
243 244 pass
244 245
245 246 return templatefilters.fill(text, width, initindent, hangindent)
246 247
247 248 def get(context, mapping, args):
248 249 if len(args) != 2:
249 250 # i18n: "get" is a keyword
250 251 raise error.ParseError(_("get() expects two arguments"))
251 252
252 253 dictarg = args[0][0](context, mapping, args[0][1])
253 254 if not util.safehasattr(dictarg, 'get'):
254 255 # i18n: "get" is a keyword
255 256 raise error.ParseError(_("get() expects a dict as first argument"))
256 257
257 258 key = args[1][0](context, mapping, args[1][1])
258 259 yield dictarg.get(key)
259 260
260 261 def _evalifliteral(arg, context, mapping):
261 262 t = stringify(arg[0](context, mapping, arg[1]))
262 263 if arg[0] == runstring or arg[0] == runrawstring:
263 264 yield runtemplate(context, mapping,
264 265 compiletemplate(t, context, strtoken='rawstring'))
265 266 else:
266 267 yield t
267 268
268 269 def if_(context, mapping, args):
269 270 if not (2 <= len(args) <= 3):
270 271 # i18n: "if" is a keyword
271 272 raise error.ParseError(_("if expects two or three arguments"))
272 273
273 274 test = stringify(args[0][0](context, mapping, args[0][1]))
274 275 if test:
275 276 yield _evalifliteral(args[1], context, mapping)
276 277 elif len(args) == 3:
277 278 yield _evalifliteral(args[2], context, mapping)
278 279
279 280 def ifeq(context, mapping, args):
280 281 if not (3 <= len(args) <= 4):
281 282 # i18n: "ifeq" is a keyword
282 283 raise error.ParseError(_("ifeq expects three or four arguments"))
283 284
284 285 test = stringify(args[0][0](context, mapping, args[0][1]))
285 286 match = stringify(args[1][0](context, mapping, args[1][1]))
286 287 if test == match:
287 288 yield _evalifliteral(args[2], context, mapping)
288 289 elif len(args) == 4:
289 290 yield _evalifliteral(args[3], context, mapping)
290 291
291 292 def join(context, mapping, args):
292 293 if not (1 <= len(args) <= 2):
293 294 # i18n: "join" is a keyword
294 295 raise error.ParseError(_("join expects one or two arguments"))
295 296
296 297 joinset = args[0][0](context, mapping, args[0][1])
297 298 if util.safehasattr(joinset, '__call__'):
298 299 jf = joinset.joinfmt
299 300 joinset = [jf(x) for x in joinset()]
300 301
301 302 joiner = " "
302 303 if len(args) > 1:
303 304 joiner = stringify(args[1][0](context, mapping, args[1][1]))
304 305
305 306 first = True
306 307 for x in joinset:
307 308 if first:
308 309 first = False
309 310 else:
310 311 yield joiner
311 312 yield x
312 313
313 314 def label(context, mapping, args):
314 315 if len(args) != 2:
315 316 # i18n: "label" is a keyword
316 317 raise error.ParseError(_("label expects two arguments"))
317 318
318 319 # ignore args[0] (the label string) since this is supposed to be a a no-op
319 320 yield _evalifliteral(args[1], context, mapping)
320 321
321 322 def rstdoc(context, mapping, args):
322 323 if len(args) != 2:
323 324 # i18n: "rstdoc" is a keyword
324 325 raise error.ParseError(_("rstdoc expects two arguments"))
325 326
326 327 text = stringify(args[0][0](context, mapping, args[0][1]))
327 328 style = stringify(args[1][0](context, mapping, args[1][1]))
328 329
329 330 return minirst.format(text, style=style, keep=['verbose'])
330 331
331 332 def strip(context, mapping, args):
332 333 if not (1 <= len(args) <= 2):
333 334 raise error.ParseError(_("strip expects one or two arguments"))
334 335
335 336 text = stringify(args[0][0](context, mapping, args[0][1]))
336 337 if len(args) == 2:
337 338 chars = stringify(args[1][0](context, mapping, args[1][1]))
338 339 return text.strip(chars)
339 340 return text.strip()
340 341
341 342 def sub(context, mapping, args):
342 343 if len(args) != 3:
343 344 # i18n: "sub" is a keyword
344 345 raise error.ParseError(_("sub expects three arguments"))
345 346
346 347 pat = stringify(args[0][0](context, mapping, args[0][1]))
347 348 rpl = stringify(args[1][0](context, mapping, args[1][1]))
348 349 src = stringify(_evalifliteral(args[2], context, mapping))
349 350 yield re.sub(pat, rpl, src)
350 351
351 352 methods = {
352 353 "string": lambda e, c: (runstring, e[1]),
353 354 "rawstring": lambda e, c: (runrawstring, e[1]),
354 355 "symbol": lambda e, c: (runsymbol, e[1]),
355 356 "group": lambda e, c: compileexp(e[1], c),
356 357 # ".": buildmember,
357 358 "|": buildfilter,
358 359 "%": buildmap,
359 360 "func": buildfunc,
360 361 }
361 362
362 363 funcs = {
363 364 "date": date,
364 365 "fill": fill,
365 366 "get": get,
366 367 "if": if_,
367 368 "ifeq": ifeq,
368 369 "join": join,
369 370 "label": label,
370 371 "rstdoc": rstdoc,
371 372 "strip": strip,
372 373 "sub": sub,
373 374 }
374 375
375 376 # template engine
376 377
377 378 path = ['templates', '../templates']
378 379 stringify = templatefilters.stringify
379 380
380 381 def _flatten(thing):
381 382 '''yield a single stream from a possibly nested set of iterators'''
382 383 if isinstance(thing, str):
383 384 yield thing
384 385 elif not util.safehasattr(thing, '__iter__'):
385 386 if thing is not None:
386 387 yield str(thing)
387 388 else:
388 389 for i in thing:
389 390 if isinstance(i, str):
390 391 yield i
391 392 elif not util.safehasattr(i, '__iter__'):
392 393 if i is not None:
393 394 yield str(i)
394 395 elif i is not None:
395 396 for j in _flatten(i):
396 397 yield j
397 398
398 399 def parsestring(s, quoted=True):
399 400 '''parse a string using simple c-like syntax.
400 401 string must be in quotes if quoted is True.'''
401 402 if quoted:
402 403 if len(s) < 2 or s[0] != s[-1]:
403 404 raise SyntaxError(_('unmatched quotes'))
404 405 return s[1:-1].decode('string_escape')
405 406
406 407 return s.decode('string_escape')
407 408
408 409 class engine(object):
409 410 '''template expansion engine.
410 411
411 412 template expansion works like this. a map file contains key=value
412 413 pairs. if value is quoted, it is treated as string. otherwise, it
413 414 is treated as name of template file.
414 415
415 416 templater is asked to expand a key in map. it looks up key, and
416 417 looks for strings like this: {foo}. it expands {foo} by looking up
417 418 foo in map, and substituting it. expansion is recursive: it stops
418 419 when there is no more {foo} to replace.
419 420
420 421 expansion also allows formatting and filtering.
421 422
422 423 format uses key to expand each item in list. syntax is
423 424 {key%format}.
424 425
425 426 filter uses function to transform value. syntax is
426 427 {key|filter1|filter2|...}.'''
427 428
428 429 def __init__(self, loader, filters={}, defaults={}):
429 430 self._loader = loader
430 431 self._filters = filters
431 432 self._defaults = defaults
432 433 self._cache = {}
433 434
434 435 def _load(self, t):
435 436 '''load, parse, and cache a template'''
436 437 if t not in self._cache:
437 438 self._cache[t] = compiletemplate(self._loader(t), self)
438 439 return self._cache[t]
439 440
440 441 def process(self, t, mapping):
441 442 '''Perform expansion. t is name of map element to expand.
442 443 mapping contains added elements for use during expansion. Is a
443 444 generator.'''
444 445 return _flatten(runtemplate(self, mapping, self._load(t)))
445 446
446 447 engines = {'default': engine}
447 448
448 449 def stylelist():
449 450 paths = templatepath()
450 451 if not paths:
451 452 return _('no templates found, try `hg debuginstall` for more info')
452 453 dirlist = os.listdir(paths[0])
453 454 stylelist = []
454 455 for file in dirlist:
455 456 split = file.split(".")
456 457 if split[0] == "map-cmdline":
457 458 stylelist.append(split[1])
458 459 return ", ".join(sorted(stylelist))
459 460
460 461 class TemplateNotFound(util.Abort):
461 462 pass
462 463
463 464 class templater(object):
464 465
465 466 def __init__(self, mapfile, filters={}, defaults={}, cache={},
466 467 minchunk=1024, maxchunk=65536):
467 468 '''set up template engine.
468 469 mapfile is name of file to read map definitions from.
469 470 filters is dict of functions. each transforms a value into another.
470 471 defaults is dict of default map definitions.'''
471 472 self.mapfile = mapfile or 'template'
472 473 self.cache = cache.copy()
473 474 self.map = {}
474 475 self.base = (mapfile and os.path.dirname(mapfile)) or ''
475 476 self.filters = templatefilters.filters.copy()
476 477 self.filters.update(filters)
477 478 self.defaults = defaults
478 479 self.minchunk, self.maxchunk = minchunk, maxchunk
479 480 self.ecache = {}
480 481
481 482 if not mapfile:
482 483 return
483 484 if not os.path.exists(mapfile):
484 485 raise util.Abort(_("style '%s' not found") % mapfile,
485 486 hint=_("available styles: %s") % stylelist())
486 487
487 488 conf = config.config()
488 489 conf.read(mapfile)
489 490
490 491 for key, val in conf[''].items():
491 492 if not val:
492 493 raise SyntaxError(_('%s: missing value') % conf.source('', key))
493 494 if val[0] in "'\"":
494 495 try:
495 496 self.cache[key] = parsestring(val)
496 497 except SyntaxError, inst:
497 498 raise SyntaxError('%s: %s' %
498 499 (conf.source('', key), inst.args[0]))
499 500 else:
500 501 val = 'default', val
501 502 if ':' in val[1]:
502 503 val = val[1].split(':', 1)
503 504 self.map[key] = val[0], os.path.join(self.base, val[1])
504 505
505 506 def __contains__(self, key):
506 507 return key in self.cache or key in self.map
507 508
508 509 def load(self, t):
509 510 '''Get the template for the given template name. Use a local cache.'''
510 511 if t not in self.cache:
511 512 try:
512 513 self.cache[t] = util.readfile(self.map[t][1])
513 514 except KeyError, inst:
514 515 raise TemplateNotFound(_('"%s" not in template map') %
515 516 inst.args[0])
516 517 except IOError, inst:
517 518 raise IOError(inst.args[0], _('template file %s: %s') %
518 519 (self.map[t][1], inst.args[1]))
519 520 return self.cache[t]
520 521
521 522 def __call__(self, t, **mapping):
522 523 ttype = t in self.map and self.map[t][0] or 'default'
523 524 if ttype not in self.ecache:
524 525 self.ecache[ttype] = engines[ttype](self.load,
525 526 self.filters, self.defaults)
526 527 proc = self.ecache[ttype]
527 528
528 529 stream = proc.process(t, mapping)
529 530 if self.minchunk:
530 531 stream = util.increasingchunks(stream, min=self.minchunk,
531 532 max=self.maxchunk)
532 533 return stream
533 534
534 535 def templatepath(name=None):
535 536 '''return location of template file or directory (if no name).
536 537 returns None if not found.'''
537 538 normpaths = []
538 539
539 540 # executable version (py2exe) doesn't support __file__
540 541 if util.mainfrozen():
541 542 module = sys.executable
542 543 else:
543 544 module = __file__
544 545 for f in path:
545 546 if f.startswith('/'):
546 547 p = f
547 548 else:
548 549 fl = f.split('/')
549 550 p = os.path.join(os.path.dirname(module), *fl)
550 551 if name:
551 552 p = os.path.join(p, name)
552 553 if name and os.path.exists(p):
553 554 return os.path.normpath(p)
554 555 elif os.path.isdir(p):
555 556 normpaths.append(os.path.normpath(p))
556 557
557 558 return normpaths
558 559
559 560 def stylemap(styles, paths=None):
560 561 """Return path to mapfile for a given style.
561 562
562 563 Searches mapfile in the following locations:
563 564 1. templatepath/style/map
564 565 2. templatepath/map-style
565 566 3. templatepath/map
566 567 """
567 568
568 569 if paths is None:
569 570 paths = templatepath()
570 571 elif isinstance(paths, str):
571 572 paths = [paths]
572 573
573 574 if isinstance(styles, str):
574 575 styles = [styles]
575 576
576 577 for style in styles:
577 578 if not style:
578 579 continue
579 580 locations = [os.path.join(style, 'map'), 'map-' + style]
580 581 locations.append('map')
581 582
582 583 for path in paths:
583 584 for location in locations:
584 585 mapfile = os.path.join(path, location)
585 586 if os.path.isfile(mapfile):
586 587 return style, mapfile
587 588
588 589 raise RuntimeError("No hgweb templates found in %r" % paths)
@@ -1,1756 +1,1762 b''
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 --template '{file_copies % "{source} -> {name}\n"}' -r .
49 49 second -> fourth
50 50
51 51 Quoting for ui.logtemplate
52 52
53 53 $ hg tip --config "ui.logtemplate={rev}\n"
54 54 8
55 55 $ hg tip --config "ui.logtemplate='{rev}\n'"
56 56 8
57 57 $ hg tip --config 'ui.logtemplate="{rev}\n"'
58 58 8
59 59
60 60 Make sure user/global hgrc does not affect tests
61 61
62 62 $ echo '[ui]' > .hg/hgrc
63 63 $ echo 'logtemplate =' >> .hg/hgrc
64 64 $ echo 'style =' >> .hg/hgrc
65 65
66 66 Default style is like normal output:
67 67
68 68 $ hg log > log.out
69 69 $ hg log --style default > style.out
70 70 $ cmp log.out style.out || diff -u log.out style.out
71 71
72 72 $ hg log -v > log.out
73 73 $ hg log -v --style default > style.out
74 74 $ cmp log.out style.out || diff -u log.out style.out
75 75
76 76 $ hg log --debug > log.out
77 77 $ hg log --debug --style default > style.out
78 78 $ cmp log.out style.out || diff -u log.out style.out
79 79
80 80 Revision with no copies (used to print a traceback):
81 81
82 82 $ hg tip -v --template '\n'
83 83
84 84
85 85 Compact style works:
86 86
87 87 $ hg log --style compact
88 88 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
89 89 third
90 90
91 91 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user
92 92 second
93 93
94 94 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
95 95 merge
96 96
97 97 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
98 98 new head
99 99
100 100 4 bbe44766e73d 1970-01-17 04:53 +0000 person
101 101 new branch
102 102
103 103 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
104 104 no user, no domain
105 105
106 106 2 97054abb4ab8 1970-01-14 21:20 +0000 other
107 107 no person
108 108
109 109 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other
110 110 other 1
111 111
112 112 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user
113 113 line 1
114 114
115 115
116 116 $ hg log -v --style compact
117 117 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
118 118 third
119 119
120 120 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
121 121 second
122 122
123 123 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
124 124 merge
125 125
126 126 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
127 127 new head
128 128
129 129 4 bbe44766e73d 1970-01-17 04:53 +0000 person
130 130 new branch
131 131
132 132 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
133 133 no user, no domain
134 134
135 135 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place
136 136 no person
137 137
138 138 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
139 139 other 1
140 140 other 2
141 141
142 142 other 3
143 143
144 144 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
145 145 line 1
146 146 line 2
147 147
148 148
149 149 $ hg log --debug --style compact
150 150 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test
151 151 third
152 152
153 153 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
154 154 second
155 155
156 156 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
157 157 merge
158 158
159 159 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person
160 160 new head
161 161
162 162 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person
163 163 new branch
164 164
165 165 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person
166 166 no user, no domain
167 167
168 168 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place
169 169 no person
170 170
171 171 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
172 172 other 1
173 173 other 2
174 174
175 175 other 3
176 176
177 177 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
178 178 line 1
179 179 line 2
180 180
181 181
182 182 Test xml styles:
183 183
184 184 $ hg log --style xml
185 185 <?xml version="1.0"?>
186 186 <log>
187 187 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
188 188 <tag>tip</tag>
189 189 <author email="test">test</author>
190 190 <date>2020-01-01T10:01:00+00:00</date>
191 191 <msg xml:space="preserve">third</msg>
192 192 </logentry>
193 193 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
194 194 <parent revision="-1" node="0000000000000000000000000000000000000000" />
195 195 <author email="user@hostname">User Name</author>
196 196 <date>1970-01-12T13:46:40+00:00</date>
197 197 <msg xml:space="preserve">second</msg>
198 198 </logentry>
199 199 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
200 200 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
201 201 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
202 202 <author email="person">person</author>
203 203 <date>1970-01-18T08:40:01+00:00</date>
204 204 <msg xml:space="preserve">merge</msg>
205 205 </logentry>
206 206 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
207 207 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
208 208 <author email="person">person</author>
209 209 <date>1970-01-18T08:40:00+00:00</date>
210 210 <msg xml:space="preserve">new head</msg>
211 211 </logentry>
212 212 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
213 213 <branch>foo</branch>
214 214 <author email="person">person</author>
215 215 <date>1970-01-17T04:53:20+00:00</date>
216 216 <msg xml:space="preserve">new branch</msg>
217 217 </logentry>
218 218 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
219 219 <author email="person">person</author>
220 220 <date>1970-01-16T01:06:40+00:00</date>
221 221 <msg xml:space="preserve">no user, no domain</msg>
222 222 </logentry>
223 223 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
224 224 <author email="other@place">other</author>
225 225 <date>1970-01-14T21:20:00+00:00</date>
226 226 <msg xml:space="preserve">no person</msg>
227 227 </logentry>
228 228 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
229 229 <author email="other@place">A. N. Other</author>
230 230 <date>1970-01-13T17:33:20+00:00</date>
231 231 <msg xml:space="preserve">other 1
232 232 other 2
233 233
234 234 other 3</msg>
235 235 </logentry>
236 236 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
237 237 <author email="user@hostname">User Name</author>
238 238 <date>1970-01-12T13:46:40+00:00</date>
239 239 <msg xml:space="preserve">line 1
240 240 line 2</msg>
241 241 </logentry>
242 242 </log>
243 243
244 244 $ hg log -v --style xml
245 245 <?xml version="1.0"?>
246 246 <log>
247 247 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
248 248 <tag>tip</tag>
249 249 <author email="test">test</author>
250 250 <date>2020-01-01T10:01:00+00:00</date>
251 251 <msg xml:space="preserve">third</msg>
252 252 <paths>
253 253 <path action="A">fourth</path>
254 254 <path action="A">third</path>
255 255 <path action="R">second</path>
256 256 </paths>
257 257 <copies>
258 258 <copy source="second">fourth</copy>
259 259 </copies>
260 260 </logentry>
261 261 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
262 262 <parent revision="-1" node="0000000000000000000000000000000000000000" />
263 263 <author email="user@hostname">User Name</author>
264 264 <date>1970-01-12T13:46:40+00:00</date>
265 265 <msg xml:space="preserve">second</msg>
266 266 <paths>
267 267 <path action="A">second</path>
268 268 </paths>
269 269 </logentry>
270 270 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
271 271 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
272 272 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
273 273 <author email="person">person</author>
274 274 <date>1970-01-18T08:40:01+00:00</date>
275 275 <msg xml:space="preserve">merge</msg>
276 276 <paths>
277 277 </paths>
278 278 </logentry>
279 279 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
280 280 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
281 281 <author email="person">person</author>
282 282 <date>1970-01-18T08:40:00+00:00</date>
283 283 <msg xml:space="preserve">new head</msg>
284 284 <paths>
285 285 <path action="A">d</path>
286 286 </paths>
287 287 </logentry>
288 288 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
289 289 <branch>foo</branch>
290 290 <author email="person">person</author>
291 291 <date>1970-01-17T04:53:20+00:00</date>
292 292 <msg xml:space="preserve">new branch</msg>
293 293 <paths>
294 294 </paths>
295 295 </logentry>
296 296 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
297 297 <author email="person">person</author>
298 298 <date>1970-01-16T01:06:40+00:00</date>
299 299 <msg xml:space="preserve">no user, no domain</msg>
300 300 <paths>
301 301 <path action="M">c</path>
302 302 </paths>
303 303 </logentry>
304 304 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
305 305 <author email="other@place">other</author>
306 306 <date>1970-01-14T21:20:00+00:00</date>
307 307 <msg xml:space="preserve">no person</msg>
308 308 <paths>
309 309 <path action="A">c</path>
310 310 </paths>
311 311 </logentry>
312 312 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
313 313 <author email="other@place">A. N. Other</author>
314 314 <date>1970-01-13T17:33:20+00:00</date>
315 315 <msg xml:space="preserve">other 1
316 316 other 2
317 317
318 318 other 3</msg>
319 319 <paths>
320 320 <path action="A">b</path>
321 321 </paths>
322 322 </logentry>
323 323 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
324 324 <author email="user@hostname">User Name</author>
325 325 <date>1970-01-12T13:46:40+00:00</date>
326 326 <msg xml:space="preserve">line 1
327 327 line 2</msg>
328 328 <paths>
329 329 <path action="A">a</path>
330 330 </paths>
331 331 </logentry>
332 332 </log>
333 333
334 334 $ hg log --debug --style xml
335 335 <?xml version="1.0"?>
336 336 <log>
337 337 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
338 338 <tag>tip</tag>
339 339 <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" />
340 340 <parent revision="-1" node="0000000000000000000000000000000000000000" />
341 341 <author email="test">test</author>
342 342 <date>2020-01-01T10:01:00+00:00</date>
343 343 <msg xml:space="preserve">third</msg>
344 344 <paths>
345 345 <path action="A">fourth</path>
346 346 <path action="A">third</path>
347 347 <path action="R">second</path>
348 348 </paths>
349 349 <copies>
350 350 <copy source="second">fourth</copy>
351 351 </copies>
352 352 <extra key="branch">default</extra>
353 353 </logentry>
354 354 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
355 355 <parent revision="-1" node="0000000000000000000000000000000000000000" />
356 356 <parent revision="-1" node="0000000000000000000000000000000000000000" />
357 357 <author email="user@hostname">User Name</author>
358 358 <date>1970-01-12T13:46:40+00:00</date>
359 359 <msg xml:space="preserve">second</msg>
360 360 <paths>
361 361 <path action="A">second</path>
362 362 </paths>
363 363 <extra key="branch">default</extra>
364 364 </logentry>
365 365 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
366 366 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
367 367 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
368 368 <author email="person">person</author>
369 369 <date>1970-01-18T08:40:01+00:00</date>
370 370 <msg xml:space="preserve">merge</msg>
371 371 <paths>
372 372 </paths>
373 373 <extra key="branch">default</extra>
374 374 </logentry>
375 375 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
376 376 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
377 377 <parent revision="-1" node="0000000000000000000000000000000000000000" />
378 378 <author email="person">person</author>
379 379 <date>1970-01-18T08:40:00+00:00</date>
380 380 <msg xml:space="preserve">new head</msg>
381 381 <paths>
382 382 <path action="A">d</path>
383 383 </paths>
384 384 <extra key="branch">default</extra>
385 385 </logentry>
386 386 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
387 387 <branch>foo</branch>
388 388 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
389 389 <parent revision="-1" node="0000000000000000000000000000000000000000" />
390 390 <author email="person">person</author>
391 391 <date>1970-01-17T04:53:20+00:00</date>
392 392 <msg xml:space="preserve">new branch</msg>
393 393 <paths>
394 394 </paths>
395 395 <extra key="branch">foo</extra>
396 396 </logentry>
397 397 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
398 398 <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" />
399 399 <parent revision="-1" node="0000000000000000000000000000000000000000" />
400 400 <author email="person">person</author>
401 401 <date>1970-01-16T01:06:40+00:00</date>
402 402 <msg xml:space="preserve">no user, no domain</msg>
403 403 <paths>
404 404 <path action="M">c</path>
405 405 </paths>
406 406 <extra key="branch">default</extra>
407 407 </logentry>
408 408 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
409 409 <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" />
410 410 <parent revision="-1" node="0000000000000000000000000000000000000000" />
411 411 <author email="other@place">other</author>
412 412 <date>1970-01-14T21:20:00+00:00</date>
413 413 <msg xml:space="preserve">no person</msg>
414 414 <paths>
415 415 <path action="A">c</path>
416 416 </paths>
417 417 <extra key="branch">default</extra>
418 418 </logentry>
419 419 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
420 420 <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" />
421 421 <parent revision="-1" node="0000000000000000000000000000000000000000" />
422 422 <author email="other@place">A. N. Other</author>
423 423 <date>1970-01-13T17:33:20+00:00</date>
424 424 <msg xml:space="preserve">other 1
425 425 other 2
426 426
427 427 other 3</msg>
428 428 <paths>
429 429 <path action="A">b</path>
430 430 </paths>
431 431 <extra key="branch">default</extra>
432 432 </logentry>
433 433 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
434 434 <parent revision="-1" node="0000000000000000000000000000000000000000" />
435 435 <parent revision="-1" node="0000000000000000000000000000000000000000" />
436 436 <author email="user@hostname">User Name</author>
437 437 <date>1970-01-12T13:46:40+00:00</date>
438 438 <msg xml:space="preserve">line 1
439 439 line 2</msg>
440 440 <paths>
441 441 <path action="A">a</path>
442 442 </paths>
443 443 <extra key="branch">default</extra>
444 444 </logentry>
445 445 </log>
446 446
447 447
448 448 Error if style not readable:
449 449
450 450 #if unix-permissions no-root
451 451 $ touch q
452 452 $ chmod 0 q
453 453 $ hg log --style ./q
454 454 abort: Permission denied: ./q
455 455 [255]
456 456 #endif
457 457
458 458 Error if no style:
459 459
460 460 $ hg log --style notexist
461 461 abort: style 'notexist' not found
462 462 (available styles: bisect, changelog, compact, default, phases, xml)
463 463 [255]
464 464
465 465 Error if style missing key:
466 466
467 467 $ echo 'q = q' > t
468 468 $ hg log --style ./t
469 469 abort: "changeset" not in template map
470 470 [255]
471 471
472 472 Error if style missing value:
473 473
474 474 $ echo 'changeset =' > t
475 475 $ hg log --style t
476 476 abort: t:1: missing value
477 477 [255]
478 478
479 479 Error if include fails:
480 480
481 481 $ echo 'changeset = q' >> t
482 482 #if unix-permissions no-root
483 483 $ hg log --style ./t
484 484 abort: template file ./q: Permission denied
485 485 [255]
486 486 $ rm q
487 487 #endif
488 488
489 489 Include works:
490 490
491 491 $ echo '{rev}' > q
492 492 $ hg log --style ./t
493 493 8
494 494 7
495 495 6
496 496 5
497 497 4
498 498 3
499 499 2
500 500 1
501 501 0
502 502
503 503 Missing non-standard names give no error (backward compatibility):
504 504
505 505 $ echo "changeset = '{c}'" > t
506 506 $ hg log --style ./t
507 507
508 508 Defining non-standard name works:
509 509
510 510 $ cat <<EOF > t
511 511 > changeset = '{c}'
512 512 > c = q
513 513 > EOF
514 514 $ hg log --style ./t
515 515 8
516 516 7
517 517 6
518 518 5
519 519 4
520 520 3
521 521 2
522 522 1
523 523 0
524 524
525 525 ui.style works:
526 526
527 527 $ echo '[ui]' > .hg/hgrc
528 528 $ echo 'style = t' >> .hg/hgrc
529 529 $ hg log
530 530 8
531 531 7
532 532 6
533 533 5
534 534 4
535 535 3
536 536 2
537 537 1
538 538 0
539 539
540 540
541 541 Issue338:
542 542
543 543 $ hg log --style=changelog > changelog
544 544
545 545 $ cat changelog
546 546 2020-01-01 test <test>
547 547
548 548 * fourth, second, third:
549 549 third
550 550 [95c24699272e] [tip]
551 551
552 552 1970-01-12 User Name <user@hostname>
553 553
554 554 * second:
555 555 second
556 556 [29114dbae42b]
557 557
558 558 1970-01-18 person <person>
559 559
560 560 * merge
561 561 [d41e714fe50d]
562 562
563 563 * d:
564 564 new head
565 565 [13207e5a10d9]
566 566
567 567 1970-01-17 person <person>
568 568
569 569 * new branch
570 570 [bbe44766e73d] <foo>
571 571
572 572 1970-01-16 person <person>
573 573
574 574 * c:
575 575 no user, no domain
576 576 [10e46f2dcbf4]
577 577
578 578 1970-01-14 other <other@place>
579 579
580 580 * c:
581 581 no person
582 582 [97054abb4ab8]
583 583
584 584 1970-01-13 A. N. Other <other@place>
585 585
586 586 * b:
587 587 other 1 other 2
588 588
589 589 other 3
590 590 [b608e9d1a3f0]
591 591
592 592 1970-01-12 User Name <user@hostname>
593 593
594 594 * a:
595 595 line 1 line 2
596 596 [1e4e1b8f71e0]
597 597
598 598
599 599 Issue2130: xml output for 'hg heads' is malformed
600 600
601 601 $ hg heads --style changelog
602 602 2020-01-01 test <test>
603 603
604 604 * fourth, second, third:
605 605 third
606 606 [95c24699272e] [tip]
607 607
608 608 1970-01-18 person <person>
609 609
610 610 * merge
611 611 [d41e714fe50d]
612 612
613 613 1970-01-17 person <person>
614 614
615 615 * new branch
616 616 [bbe44766e73d] <foo>
617 617
618 618
619 619 Keys work:
620 620
621 621 $ for key in author branch branches date desc file_adds file_dels file_mods \
622 622 > file_copies file_copies_switch files \
623 623 > manifest node parents rev tags diffstat extras \
624 624 > p1rev p2rev p1node p2node; do
625 625 > for mode in '' --verbose --debug; do
626 626 > hg log $mode --template "$key$mode: {$key}\n"
627 627 > done
628 628 > done
629 629 author: test
630 630 author: User Name <user@hostname>
631 631 author: person
632 632 author: person
633 633 author: person
634 634 author: person
635 635 author: other@place
636 636 author: A. N. Other <other@place>
637 637 author: User Name <user@hostname>
638 638 author--verbose: test
639 639 author--verbose: User Name <user@hostname>
640 640 author--verbose: person
641 641 author--verbose: person
642 642 author--verbose: person
643 643 author--verbose: person
644 644 author--verbose: other@place
645 645 author--verbose: A. N. Other <other@place>
646 646 author--verbose: User Name <user@hostname>
647 647 author--debug: test
648 648 author--debug: User Name <user@hostname>
649 649 author--debug: person
650 650 author--debug: person
651 651 author--debug: person
652 652 author--debug: person
653 653 author--debug: other@place
654 654 author--debug: A. N. Other <other@place>
655 655 author--debug: User Name <user@hostname>
656 656 branch: default
657 657 branch: default
658 658 branch: default
659 659 branch: default
660 660 branch: foo
661 661 branch: default
662 662 branch: default
663 663 branch: default
664 664 branch: default
665 665 branch--verbose: default
666 666 branch--verbose: default
667 667 branch--verbose: default
668 668 branch--verbose: default
669 669 branch--verbose: foo
670 670 branch--verbose: default
671 671 branch--verbose: default
672 672 branch--verbose: default
673 673 branch--verbose: default
674 674 branch--debug: default
675 675 branch--debug: default
676 676 branch--debug: default
677 677 branch--debug: default
678 678 branch--debug: foo
679 679 branch--debug: default
680 680 branch--debug: default
681 681 branch--debug: default
682 682 branch--debug: default
683 683 branches:
684 684 branches:
685 685 branches:
686 686 branches:
687 687 branches: foo
688 688 branches:
689 689 branches:
690 690 branches:
691 691 branches:
692 692 branches--verbose:
693 693 branches--verbose:
694 694 branches--verbose:
695 695 branches--verbose:
696 696 branches--verbose: foo
697 697 branches--verbose:
698 698 branches--verbose:
699 699 branches--verbose:
700 700 branches--verbose:
701 701 branches--debug:
702 702 branches--debug:
703 703 branches--debug:
704 704 branches--debug:
705 705 branches--debug: foo
706 706 branches--debug:
707 707 branches--debug:
708 708 branches--debug:
709 709 branches--debug:
710 710 date: 1577872860.00
711 711 date: 1000000.00
712 712 date: 1500001.00
713 713 date: 1500000.00
714 714 date: 1400000.00
715 715 date: 1300000.00
716 716 date: 1200000.00
717 717 date: 1100000.00
718 718 date: 1000000.00
719 719 date--verbose: 1577872860.00
720 720 date--verbose: 1000000.00
721 721 date--verbose: 1500001.00
722 722 date--verbose: 1500000.00
723 723 date--verbose: 1400000.00
724 724 date--verbose: 1300000.00
725 725 date--verbose: 1200000.00
726 726 date--verbose: 1100000.00
727 727 date--verbose: 1000000.00
728 728 date--debug: 1577872860.00
729 729 date--debug: 1000000.00
730 730 date--debug: 1500001.00
731 731 date--debug: 1500000.00
732 732 date--debug: 1400000.00
733 733 date--debug: 1300000.00
734 734 date--debug: 1200000.00
735 735 date--debug: 1100000.00
736 736 date--debug: 1000000.00
737 737 desc: third
738 738 desc: second
739 739 desc: merge
740 740 desc: new head
741 741 desc: new branch
742 742 desc: no user, no domain
743 743 desc: no person
744 744 desc: other 1
745 745 other 2
746 746
747 747 other 3
748 748 desc: line 1
749 749 line 2
750 750 desc--verbose: third
751 751 desc--verbose: second
752 752 desc--verbose: merge
753 753 desc--verbose: new head
754 754 desc--verbose: new branch
755 755 desc--verbose: no user, no domain
756 756 desc--verbose: no person
757 757 desc--verbose: other 1
758 758 other 2
759 759
760 760 other 3
761 761 desc--verbose: line 1
762 762 line 2
763 763 desc--debug: third
764 764 desc--debug: second
765 765 desc--debug: merge
766 766 desc--debug: new head
767 767 desc--debug: new branch
768 768 desc--debug: no user, no domain
769 769 desc--debug: no person
770 770 desc--debug: other 1
771 771 other 2
772 772
773 773 other 3
774 774 desc--debug: line 1
775 775 line 2
776 776 file_adds: fourth third
777 777 file_adds: second
778 778 file_adds:
779 779 file_adds: d
780 780 file_adds:
781 781 file_adds:
782 782 file_adds: c
783 783 file_adds: b
784 784 file_adds: a
785 785 file_adds--verbose: fourth third
786 786 file_adds--verbose: second
787 787 file_adds--verbose:
788 788 file_adds--verbose: d
789 789 file_adds--verbose:
790 790 file_adds--verbose:
791 791 file_adds--verbose: c
792 792 file_adds--verbose: b
793 793 file_adds--verbose: a
794 794 file_adds--debug: fourth third
795 795 file_adds--debug: second
796 796 file_adds--debug:
797 797 file_adds--debug: d
798 798 file_adds--debug:
799 799 file_adds--debug:
800 800 file_adds--debug: c
801 801 file_adds--debug: b
802 802 file_adds--debug: a
803 803 file_dels: second
804 804 file_dels:
805 805 file_dels:
806 806 file_dels:
807 807 file_dels:
808 808 file_dels:
809 809 file_dels:
810 810 file_dels:
811 811 file_dels:
812 812 file_dels--verbose: second
813 813 file_dels--verbose:
814 814 file_dels--verbose:
815 815 file_dels--verbose:
816 816 file_dels--verbose:
817 817 file_dels--verbose:
818 818 file_dels--verbose:
819 819 file_dels--verbose:
820 820 file_dels--verbose:
821 821 file_dels--debug: second
822 822 file_dels--debug:
823 823 file_dels--debug:
824 824 file_dels--debug:
825 825 file_dels--debug:
826 826 file_dels--debug:
827 827 file_dels--debug:
828 828 file_dels--debug:
829 829 file_dels--debug:
830 830 file_mods:
831 831 file_mods:
832 832 file_mods:
833 833 file_mods:
834 834 file_mods:
835 835 file_mods: c
836 836 file_mods:
837 837 file_mods:
838 838 file_mods:
839 839 file_mods--verbose:
840 840 file_mods--verbose:
841 841 file_mods--verbose:
842 842 file_mods--verbose:
843 843 file_mods--verbose:
844 844 file_mods--verbose: c
845 845 file_mods--verbose:
846 846 file_mods--verbose:
847 847 file_mods--verbose:
848 848 file_mods--debug:
849 849 file_mods--debug:
850 850 file_mods--debug:
851 851 file_mods--debug:
852 852 file_mods--debug:
853 853 file_mods--debug: c
854 854 file_mods--debug:
855 855 file_mods--debug:
856 856 file_mods--debug:
857 857 file_copies: fourth (second)
858 858 file_copies:
859 859 file_copies:
860 860 file_copies:
861 861 file_copies:
862 862 file_copies:
863 863 file_copies:
864 864 file_copies:
865 865 file_copies:
866 866 file_copies--verbose: fourth (second)
867 867 file_copies--verbose:
868 868 file_copies--verbose:
869 869 file_copies--verbose:
870 870 file_copies--verbose:
871 871 file_copies--verbose:
872 872 file_copies--verbose:
873 873 file_copies--verbose:
874 874 file_copies--verbose:
875 875 file_copies--debug: fourth (second)
876 876 file_copies--debug:
877 877 file_copies--debug:
878 878 file_copies--debug:
879 879 file_copies--debug:
880 880 file_copies--debug:
881 881 file_copies--debug:
882 882 file_copies--debug:
883 883 file_copies--debug:
884 884 file_copies_switch:
885 885 file_copies_switch:
886 886 file_copies_switch:
887 887 file_copies_switch:
888 888 file_copies_switch:
889 889 file_copies_switch:
890 890 file_copies_switch:
891 891 file_copies_switch:
892 892 file_copies_switch:
893 893 file_copies_switch--verbose:
894 894 file_copies_switch--verbose:
895 895 file_copies_switch--verbose:
896 896 file_copies_switch--verbose:
897 897 file_copies_switch--verbose:
898 898 file_copies_switch--verbose:
899 899 file_copies_switch--verbose:
900 900 file_copies_switch--verbose:
901 901 file_copies_switch--verbose:
902 902 file_copies_switch--debug:
903 903 file_copies_switch--debug:
904 904 file_copies_switch--debug:
905 905 file_copies_switch--debug:
906 906 file_copies_switch--debug:
907 907 file_copies_switch--debug:
908 908 file_copies_switch--debug:
909 909 file_copies_switch--debug:
910 910 file_copies_switch--debug:
911 911 files: fourth second third
912 912 files: second
913 913 files:
914 914 files: d
915 915 files:
916 916 files: c
917 917 files: c
918 918 files: b
919 919 files: a
920 920 files--verbose: fourth second third
921 921 files--verbose: second
922 922 files--verbose:
923 923 files--verbose: d
924 924 files--verbose:
925 925 files--verbose: c
926 926 files--verbose: c
927 927 files--verbose: b
928 928 files--verbose: a
929 929 files--debug: fourth second third
930 930 files--debug: second
931 931 files--debug:
932 932 files--debug: d
933 933 files--debug:
934 934 files--debug: c
935 935 files--debug: c
936 936 files--debug: b
937 937 files--debug: a
938 938 manifest: 6:94961b75a2da
939 939 manifest: 5:f2dbc354b94e
940 940 manifest: 4:4dc3def4f9b4
941 941 manifest: 4:4dc3def4f9b4
942 942 manifest: 3:cb5a1327723b
943 943 manifest: 3:cb5a1327723b
944 944 manifest: 2:6e0e82995c35
945 945 manifest: 1:4e8d705b1e53
946 946 manifest: 0:a0c8bcbbb45c
947 947 manifest--verbose: 6:94961b75a2da
948 948 manifest--verbose: 5:f2dbc354b94e
949 949 manifest--verbose: 4:4dc3def4f9b4
950 950 manifest--verbose: 4:4dc3def4f9b4
951 951 manifest--verbose: 3:cb5a1327723b
952 952 manifest--verbose: 3:cb5a1327723b
953 953 manifest--verbose: 2:6e0e82995c35
954 954 manifest--verbose: 1:4e8d705b1e53
955 955 manifest--verbose: 0:a0c8bcbbb45c
956 956 manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64
957 957 manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf
958 958 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
959 959 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
960 960 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
961 961 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
962 962 manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
963 963 manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
964 964 manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
965 965 node: 95c24699272ef57d062b8bccc32c878bf841784a
966 966 node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
967 967 node: d41e714fe50d9e4a5f11b4d595d543481b5f980b
968 968 node: 13207e5a10d9fd28ec424934298e176197f2c67f
969 969 node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
970 970 node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
971 971 node: 97054abb4ab824450e9164180baf491ae0078465
972 972 node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
973 973 node: 1e4e1b8f71e05681d422154f5421e385fec3454f
974 974 node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a
975 975 node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
976 976 node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b
977 977 node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
978 978 node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
979 979 node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
980 980 node--verbose: 97054abb4ab824450e9164180baf491ae0078465
981 981 node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
982 982 node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
983 983 node--debug: 95c24699272ef57d062b8bccc32c878bf841784a
984 984 node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
985 985 node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b
986 986 node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
987 987 node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
988 988 node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
989 989 node--debug: 97054abb4ab824450e9164180baf491ae0078465
990 990 node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
991 991 node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
992 992 parents:
993 993 parents: -1:000000000000
994 994 parents: 5:13207e5a10d9 4:bbe44766e73d
995 995 parents: 3:10e46f2dcbf4
996 996 parents:
997 997 parents:
998 998 parents:
999 999 parents:
1000 1000 parents:
1001 1001 parents--verbose:
1002 1002 parents--verbose: -1:000000000000
1003 1003 parents--verbose: 5:13207e5a10d9 4:bbe44766e73d
1004 1004 parents--verbose: 3:10e46f2dcbf4
1005 1005 parents--verbose:
1006 1006 parents--verbose:
1007 1007 parents--verbose:
1008 1008 parents--verbose:
1009 1009 parents--verbose:
1010 1010 parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000
1011 1011 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1012 1012 parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1013 1013 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1014 1014 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1015 1015 parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000
1016 1016 parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000
1017 1017 parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000
1018 1018 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1019 1019 rev: 8
1020 1020 rev: 7
1021 1021 rev: 6
1022 1022 rev: 5
1023 1023 rev: 4
1024 1024 rev: 3
1025 1025 rev: 2
1026 1026 rev: 1
1027 1027 rev: 0
1028 1028 rev--verbose: 8
1029 1029 rev--verbose: 7
1030 1030 rev--verbose: 6
1031 1031 rev--verbose: 5
1032 1032 rev--verbose: 4
1033 1033 rev--verbose: 3
1034 1034 rev--verbose: 2
1035 1035 rev--verbose: 1
1036 1036 rev--verbose: 0
1037 1037 rev--debug: 8
1038 1038 rev--debug: 7
1039 1039 rev--debug: 6
1040 1040 rev--debug: 5
1041 1041 rev--debug: 4
1042 1042 rev--debug: 3
1043 1043 rev--debug: 2
1044 1044 rev--debug: 1
1045 1045 rev--debug: 0
1046 1046 tags: tip
1047 1047 tags:
1048 1048 tags:
1049 1049 tags:
1050 1050 tags:
1051 1051 tags:
1052 1052 tags:
1053 1053 tags:
1054 1054 tags:
1055 1055 tags--verbose: tip
1056 1056 tags--verbose:
1057 1057 tags--verbose:
1058 1058 tags--verbose:
1059 1059 tags--verbose:
1060 1060 tags--verbose:
1061 1061 tags--verbose:
1062 1062 tags--verbose:
1063 1063 tags--verbose:
1064 1064 tags--debug: tip
1065 1065 tags--debug:
1066 1066 tags--debug:
1067 1067 tags--debug:
1068 1068 tags--debug:
1069 1069 tags--debug:
1070 1070 tags--debug:
1071 1071 tags--debug:
1072 1072 tags--debug:
1073 1073 diffstat: 3: +2/-1
1074 1074 diffstat: 1: +1/-0
1075 1075 diffstat: 0: +0/-0
1076 1076 diffstat: 1: +1/-0
1077 1077 diffstat: 0: +0/-0
1078 1078 diffstat: 1: +1/-0
1079 1079 diffstat: 1: +4/-0
1080 1080 diffstat: 1: +2/-0
1081 1081 diffstat: 1: +1/-0
1082 1082 diffstat--verbose: 3: +2/-1
1083 1083 diffstat--verbose: 1: +1/-0
1084 1084 diffstat--verbose: 0: +0/-0
1085 1085 diffstat--verbose: 1: +1/-0
1086 1086 diffstat--verbose: 0: +0/-0
1087 1087 diffstat--verbose: 1: +1/-0
1088 1088 diffstat--verbose: 1: +4/-0
1089 1089 diffstat--verbose: 1: +2/-0
1090 1090 diffstat--verbose: 1: +1/-0
1091 1091 diffstat--debug: 3: +2/-1
1092 1092 diffstat--debug: 1: +1/-0
1093 1093 diffstat--debug: 0: +0/-0
1094 1094 diffstat--debug: 1: +1/-0
1095 1095 diffstat--debug: 0: +0/-0
1096 1096 diffstat--debug: 1: +1/-0
1097 1097 diffstat--debug: 1: +4/-0
1098 1098 diffstat--debug: 1: +2/-0
1099 1099 diffstat--debug: 1: +1/-0
1100 1100 extras: branch=default
1101 1101 extras: branch=default
1102 1102 extras: branch=default
1103 1103 extras: branch=default
1104 1104 extras: branch=foo
1105 1105 extras: branch=default
1106 1106 extras: branch=default
1107 1107 extras: branch=default
1108 1108 extras: branch=default
1109 1109 extras--verbose: branch=default
1110 1110 extras--verbose: branch=default
1111 1111 extras--verbose: branch=default
1112 1112 extras--verbose: branch=default
1113 1113 extras--verbose: branch=foo
1114 1114 extras--verbose: branch=default
1115 1115 extras--verbose: branch=default
1116 1116 extras--verbose: branch=default
1117 1117 extras--verbose: branch=default
1118 1118 extras--debug: branch=default
1119 1119 extras--debug: branch=default
1120 1120 extras--debug: branch=default
1121 1121 extras--debug: branch=default
1122 1122 extras--debug: branch=foo
1123 1123 extras--debug: branch=default
1124 1124 extras--debug: branch=default
1125 1125 extras--debug: branch=default
1126 1126 extras--debug: branch=default
1127 1127 p1rev: 7
1128 1128 p1rev: -1
1129 1129 p1rev: 5
1130 1130 p1rev: 3
1131 1131 p1rev: 3
1132 1132 p1rev: 2
1133 1133 p1rev: 1
1134 1134 p1rev: 0
1135 1135 p1rev: -1
1136 1136 p1rev--verbose: 7
1137 1137 p1rev--verbose: -1
1138 1138 p1rev--verbose: 5
1139 1139 p1rev--verbose: 3
1140 1140 p1rev--verbose: 3
1141 1141 p1rev--verbose: 2
1142 1142 p1rev--verbose: 1
1143 1143 p1rev--verbose: 0
1144 1144 p1rev--verbose: -1
1145 1145 p1rev--debug: 7
1146 1146 p1rev--debug: -1
1147 1147 p1rev--debug: 5
1148 1148 p1rev--debug: 3
1149 1149 p1rev--debug: 3
1150 1150 p1rev--debug: 2
1151 1151 p1rev--debug: 1
1152 1152 p1rev--debug: 0
1153 1153 p1rev--debug: -1
1154 1154 p2rev: -1
1155 1155 p2rev: -1
1156 1156 p2rev: 4
1157 1157 p2rev: -1
1158 1158 p2rev: -1
1159 1159 p2rev: -1
1160 1160 p2rev: -1
1161 1161 p2rev: -1
1162 1162 p2rev: -1
1163 1163 p2rev--verbose: -1
1164 1164 p2rev--verbose: -1
1165 1165 p2rev--verbose: 4
1166 1166 p2rev--verbose: -1
1167 1167 p2rev--verbose: -1
1168 1168 p2rev--verbose: -1
1169 1169 p2rev--verbose: -1
1170 1170 p2rev--verbose: -1
1171 1171 p2rev--verbose: -1
1172 1172 p2rev--debug: -1
1173 1173 p2rev--debug: -1
1174 1174 p2rev--debug: 4
1175 1175 p2rev--debug: -1
1176 1176 p2rev--debug: -1
1177 1177 p2rev--debug: -1
1178 1178 p2rev--debug: -1
1179 1179 p2rev--debug: -1
1180 1180 p2rev--debug: -1
1181 1181 p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1182 1182 p1node: 0000000000000000000000000000000000000000
1183 1183 p1node: 13207e5a10d9fd28ec424934298e176197f2c67f
1184 1184 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1185 1185 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1186 1186 p1node: 97054abb4ab824450e9164180baf491ae0078465
1187 1187 p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1188 1188 p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1189 1189 p1node: 0000000000000000000000000000000000000000
1190 1190 p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1191 1191 p1node--verbose: 0000000000000000000000000000000000000000
1192 1192 p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1193 1193 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1194 1194 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1195 1195 p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1196 1196 p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1197 1197 p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
1198 1198 p1node--verbose: 0000000000000000000000000000000000000000
1199 1199 p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1200 1200 p1node--debug: 0000000000000000000000000000000000000000
1201 1201 p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
1202 1202 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1203 1203 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1204 1204 p1node--debug: 97054abb4ab824450e9164180baf491ae0078465
1205 1205 p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1206 1206 p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
1207 1207 p1node--debug: 0000000000000000000000000000000000000000
1208 1208 p2node: 0000000000000000000000000000000000000000
1209 1209 p2node: 0000000000000000000000000000000000000000
1210 1210 p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1211 1211 p2node: 0000000000000000000000000000000000000000
1212 1212 p2node: 0000000000000000000000000000000000000000
1213 1213 p2node: 0000000000000000000000000000000000000000
1214 1214 p2node: 0000000000000000000000000000000000000000
1215 1215 p2node: 0000000000000000000000000000000000000000
1216 1216 p2node: 0000000000000000000000000000000000000000
1217 1217 p2node--verbose: 0000000000000000000000000000000000000000
1218 1218 p2node--verbose: 0000000000000000000000000000000000000000
1219 1219 p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1220 1220 p2node--verbose: 0000000000000000000000000000000000000000
1221 1221 p2node--verbose: 0000000000000000000000000000000000000000
1222 1222 p2node--verbose: 0000000000000000000000000000000000000000
1223 1223 p2node--verbose: 0000000000000000000000000000000000000000
1224 1224 p2node--verbose: 0000000000000000000000000000000000000000
1225 1225 p2node--verbose: 0000000000000000000000000000000000000000
1226 1226 p2node--debug: 0000000000000000000000000000000000000000
1227 1227 p2node--debug: 0000000000000000000000000000000000000000
1228 1228 p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1229 1229 p2node--debug: 0000000000000000000000000000000000000000
1230 1230 p2node--debug: 0000000000000000000000000000000000000000
1231 1231 p2node--debug: 0000000000000000000000000000000000000000
1232 1232 p2node--debug: 0000000000000000000000000000000000000000
1233 1233 p2node--debug: 0000000000000000000000000000000000000000
1234 1234 p2node--debug: 0000000000000000000000000000000000000000
1235 1235
1236 1236 Filters work:
1237 1237
1238 1238 $ hg log --template '{author|domain}\n'
1239 1239
1240 1240 hostname
1241 1241
1242 1242
1243 1243
1244 1244
1245 1245 place
1246 1246 place
1247 1247 hostname
1248 1248
1249 1249 $ hg log --template '{author|person}\n'
1250 1250 test
1251 1251 User Name
1252 1252 person
1253 1253 person
1254 1254 person
1255 1255 person
1256 1256 other
1257 1257 A. N. Other
1258 1258 User Name
1259 1259
1260 1260 $ hg log --template '{author|user}\n'
1261 1261 test
1262 1262 user
1263 1263 person
1264 1264 person
1265 1265 person
1266 1266 person
1267 1267 other
1268 1268 other
1269 1269 user
1270 1270
1271 1271 $ hg log --template '{date|date}\n'
1272 1272 Wed Jan 01 10:01:00 2020 +0000
1273 1273 Mon Jan 12 13:46:40 1970 +0000
1274 1274 Sun Jan 18 08:40:01 1970 +0000
1275 1275 Sun Jan 18 08:40:00 1970 +0000
1276 1276 Sat Jan 17 04:53:20 1970 +0000
1277 1277 Fri Jan 16 01:06:40 1970 +0000
1278 1278 Wed Jan 14 21:20:00 1970 +0000
1279 1279 Tue Jan 13 17:33:20 1970 +0000
1280 1280 Mon Jan 12 13:46:40 1970 +0000
1281 1281
1282 1282 $ hg log --template '{date|isodate}\n'
1283 1283 2020-01-01 10:01 +0000
1284 1284 1970-01-12 13:46 +0000
1285 1285 1970-01-18 08:40 +0000
1286 1286 1970-01-18 08:40 +0000
1287 1287 1970-01-17 04:53 +0000
1288 1288 1970-01-16 01:06 +0000
1289 1289 1970-01-14 21:20 +0000
1290 1290 1970-01-13 17:33 +0000
1291 1291 1970-01-12 13:46 +0000
1292 1292
1293 1293 $ hg log --template '{date|isodatesec}\n'
1294 1294 2020-01-01 10:01:00 +0000
1295 1295 1970-01-12 13:46:40 +0000
1296 1296 1970-01-18 08:40:01 +0000
1297 1297 1970-01-18 08:40:00 +0000
1298 1298 1970-01-17 04:53:20 +0000
1299 1299 1970-01-16 01:06:40 +0000
1300 1300 1970-01-14 21:20:00 +0000
1301 1301 1970-01-13 17:33:20 +0000
1302 1302 1970-01-12 13:46:40 +0000
1303 1303
1304 1304 $ hg log --template '{date|rfc822date}\n'
1305 1305 Wed, 01 Jan 2020 10:01:00 +0000
1306 1306 Mon, 12 Jan 1970 13:46:40 +0000
1307 1307 Sun, 18 Jan 1970 08:40:01 +0000
1308 1308 Sun, 18 Jan 1970 08:40:00 +0000
1309 1309 Sat, 17 Jan 1970 04:53:20 +0000
1310 1310 Fri, 16 Jan 1970 01:06:40 +0000
1311 1311 Wed, 14 Jan 1970 21:20:00 +0000
1312 1312 Tue, 13 Jan 1970 17:33:20 +0000
1313 1313 Mon, 12 Jan 1970 13:46:40 +0000
1314 1314
1315 1315 $ hg log --template '{desc|firstline}\n'
1316 1316 third
1317 1317 second
1318 1318 merge
1319 1319 new head
1320 1320 new branch
1321 1321 no user, no domain
1322 1322 no person
1323 1323 other 1
1324 1324 line 1
1325 1325
1326 1326 $ hg log --template '{node|short}\n'
1327 1327 95c24699272e
1328 1328 29114dbae42b
1329 1329 d41e714fe50d
1330 1330 13207e5a10d9
1331 1331 bbe44766e73d
1332 1332 10e46f2dcbf4
1333 1333 97054abb4ab8
1334 1334 b608e9d1a3f0
1335 1335 1e4e1b8f71e0
1336 1336
1337 1337 $ hg log --template '<changeset author="{author|xmlescape}"/>\n'
1338 1338 <changeset author="test"/>
1339 1339 <changeset author="User Name &lt;user@hostname&gt;"/>
1340 1340 <changeset author="person"/>
1341 1341 <changeset author="person"/>
1342 1342 <changeset author="person"/>
1343 1343 <changeset author="person"/>
1344 1344 <changeset author="other@place"/>
1345 1345 <changeset author="A. N. Other &lt;other@place&gt;"/>
1346 1346 <changeset author="User Name &lt;user@hostname&gt;"/>
1347 1347
1348 1348 $ hg log --template '{rev}: {children}\n'
1349 1349 8:
1350 1350 7: 8:95c24699272e
1351 1351 6:
1352 1352 5: 6:d41e714fe50d
1353 1353 4: 6:d41e714fe50d
1354 1354 3: 4:bbe44766e73d 5:13207e5a10d9
1355 1355 2: 3:10e46f2dcbf4
1356 1356 1: 2:97054abb4ab8
1357 1357 0: 1:b608e9d1a3f0
1358 1358
1359 1359 Formatnode filter works:
1360 1360
1361 1361 $ hg -q log -r 0 --template '{node|formatnode}\n'
1362 1362 1e4e1b8f71e0
1363 1363
1364 1364 $ hg log -r 0 --template '{node|formatnode}\n'
1365 1365 1e4e1b8f71e0
1366 1366
1367 1367 $ hg -v log -r 0 --template '{node|formatnode}\n'
1368 1368 1e4e1b8f71e0
1369 1369
1370 1370 $ hg --debug log -r 0 --template '{node|formatnode}\n'
1371 1371 1e4e1b8f71e05681d422154f5421e385fec3454f
1372 1372
1373 1373 Age filter:
1374 1374
1375 1375 $ hg log --template '{date|age}\n' > /dev/null || exit 1
1376 1376
1377 1377 >>> from datetime import datetime, timedelta
1378 1378 >>> fp = open('a', 'w')
1379 1379 >>> n = datetime.now() + timedelta(366 * 7)
1380 1380 >>> fp.write('%d-%d-%d 00:00' % (n.year, n.month, n.day))
1381 1381 >>> fp.close()
1382 1382 $ hg add a
1383 1383 $ hg commit -m future -d "`cat a`"
1384 1384
1385 1385 $ hg log -l1 --template '{date|age}\n'
1386 1386 7 years from now
1387 1387
1388 1388 Error on syntax:
1389 1389
1390 1390 $ echo 'x = "f' >> t
1391 1391 $ hg log
1392 1392 abort: t:3: unmatched quotes
1393 1393 [255]
1394 1394
1395 1395 Behind the scenes, this will throw TypeError
1396 1396
1397 1397 $ hg log -l 3 --template '{date|obfuscate}\n'
1398 1398 abort: template filter 'obfuscate' is not compatible with keyword 'date'
1399 1399 [255]
1400 1400
1401 1401 Behind the scenes, this will throw a ValueError
1402 1402
1403 1403 $ hg log -l 3 --template 'line: {desc|shortdate}\n'
1404 1404 abort: template filter 'shortdate' is not compatible with keyword 'desc'
1405 1405 [255]
1406 1406
1407 1407 Behind the scenes, this will throw AttributeError
1408 1408
1409 1409 $ hg log -l 3 --template 'line: {date|escape}\n'
1410 1410 abort: template filter 'escape' is not compatible with keyword 'date'
1411 1411 [255]
1412 1412
1413 1413 Behind the scenes, this will throw ValueError
1414 1414
1415 1415 $ hg tip --template '{author|email|date}\n'
1416 1416 abort: template filter 'datefilter' is not compatible with keyword 'author'
1417 1417 [255]
1418 1418
1419 Thrown an error if a template function doesn't exist
1420
1421 $ hg tip --template '{foo()}\n'
1422 hg: parse error: unknown function 'foo'
1423 [255]
1424
1419 1425 $ cd ..
1420 1426
1421 1427
1422 1428 latesttag:
1423 1429
1424 1430 $ hg init latesttag
1425 1431 $ cd latesttag
1426 1432
1427 1433 $ echo a > file
1428 1434 $ hg ci -Am a -d '0 0'
1429 1435 adding file
1430 1436
1431 1437 $ echo b >> file
1432 1438 $ hg ci -m b -d '1 0'
1433 1439
1434 1440 $ echo c >> head1
1435 1441 $ hg ci -Am h1c -d '2 0'
1436 1442 adding head1
1437 1443
1438 1444 $ hg update -q 1
1439 1445 $ echo d >> head2
1440 1446 $ hg ci -Am h2d -d '3 0'
1441 1447 adding head2
1442 1448 created new head
1443 1449
1444 1450 $ echo e >> head2
1445 1451 $ hg ci -m h2e -d '4 0'
1446 1452
1447 1453 $ hg merge -q
1448 1454 $ hg ci -m merge -d '5 -3600'
1449 1455
1450 1456 No tag set:
1451 1457
1452 1458 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
1453 1459 5: null+5
1454 1460 4: null+4
1455 1461 3: null+3
1456 1462 2: null+3
1457 1463 1: null+2
1458 1464 0: null+1
1459 1465
1460 1466 One common tag: longuest path wins:
1461 1467
1462 1468 $ hg tag -r 1 -m t1 -d '6 0' t1
1463 1469 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
1464 1470 6: t1+4
1465 1471 5: t1+3
1466 1472 4: t1+2
1467 1473 3: t1+1
1468 1474 2: t1+1
1469 1475 1: t1+0
1470 1476 0: null+1
1471 1477
1472 1478 One ancestor tag: more recent wins:
1473 1479
1474 1480 $ hg tag -r 2 -m t2 -d '7 0' t2
1475 1481 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
1476 1482 7: t2+3
1477 1483 6: t2+2
1478 1484 5: t2+1
1479 1485 4: t1+2
1480 1486 3: t1+1
1481 1487 2: t2+0
1482 1488 1: t1+0
1483 1489 0: null+1
1484 1490
1485 1491 Two branch tags: more recent wins:
1486 1492
1487 1493 $ hg tag -r 3 -m t3 -d '8 0' t3
1488 1494 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
1489 1495 8: t3+5
1490 1496 7: t3+4
1491 1497 6: t3+3
1492 1498 5: t3+2
1493 1499 4: t3+1
1494 1500 3: t3+0
1495 1501 2: t2+0
1496 1502 1: t1+0
1497 1503 0: null+1
1498 1504
1499 1505 Merged tag overrides:
1500 1506
1501 1507 $ hg tag -r 5 -m t5 -d '9 0' t5
1502 1508 $ hg tag -r 3 -m at3 -d '10 0' at3
1503 1509 $ hg log --template '{rev}: {latesttag}+{latesttagdistance}\n'
1504 1510 10: t5+5
1505 1511 9: t5+4
1506 1512 8: t5+3
1507 1513 7: t5+2
1508 1514 6: t5+1
1509 1515 5: t5+0
1510 1516 4: at3:t3+1
1511 1517 3: at3:t3+0
1512 1518 2: t2+0
1513 1519 1: t1+0
1514 1520 0: null+1
1515 1521
1516 1522 $ cd ..
1517 1523
1518 1524
1519 1525 Style path expansion: issue1948 - ui.style option doesn't work on OSX
1520 1526 if it is a relative path
1521 1527
1522 1528 $ mkdir -p home/styles
1523 1529
1524 1530 $ cat > home/styles/teststyle <<EOF
1525 1531 > changeset = 'test {rev}:{node|short}\n'
1526 1532 > EOF
1527 1533
1528 1534 $ HOME=`pwd`/home; export HOME
1529 1535
1530 1536 $ cat > latesttag/.hg/hgrc <<EOF
1531 1537 > [ui]
1532 1538 > style = ~/styles/teststyle
1533 1539 > EOF
1534 1540
1535 1541 $ hg -R latesttag tip
1536 1542 test 10:9b4a630e5f5f
1537 1543
1538 1544 Test recursive showlist template (issue1989):
1539 1545
1540 1546 $ cat > style1989 <<EOF
1541 1547 > changeset = '{file_mods}{manifest}{extras}'
1542 1548 > file_mod = 'M|{author|person}\n'
1543 1549 > manifest = '{rev},{author}\n'
1544 1550 > extra = '{key}: {author}\n'
1545 1551 > EOF
1546 1552
1547 1553 $ hg -R latesttag log -r tip --style=style1989
1548 1554 M|test
1549 1555 10,test
1550 1556 branch: test
1551 1557
1552 1558 Test new-style inline templating:
1553 1559
1554 1560 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
1555 1561 modified files: .hgtags
1556 1562
1557 1563 Test the sub function of templating for expansion:
1558 1564
1559 1565 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
1560 1566 xx
1561 1567
1562 1568 Test the strip function with chars specified:
1563 1569
1564 1570 $ hg log -R latesttag --template '{desc}\n'
1565 1571 at3
1566 1572 t5
1567 1573 t3
1568 1574 t2
1569 1575 t1
1570 1576 merge
1571 1577 h2e
1572 1578 h2d
1573 1579 h1c
1574 1580 b
1575 1581 a
1576 1582
1577 1583 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
1578 1584 at3
1579 1585 5
1580 1586 3
1581 1587 2
1582 1588 1
1583 1589 merg
1584 1590 h2
1585 1591 h2d
1586 1592 h1c
1587 1593 b
1588 1594 a
1589 1595
1590 1596 Test date format:
1591 1597
1592 1598 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
1593 1599 date: 70 01 01 10 +0000
1594 1600 date: 70 01 01 09 +0000
1595 1601 date: 70 01 01 08 +0000
1596 1602 date: 70 01 01 07 +0000
1597 1603 date: 70 01 01 06 +0000
1598 1604 date: 70 01 01 05 +0100
1599 1605 date: 70 01 01 04 +0000
1600 1606 date: 70 01 01 03 +0000
1601 1607 date: 70 01 01 02 +0000
1602 1608 date: 70 01 01 01 +0000
1603 1609 date: 70 01 01 00 +0000
1604 1610
1605 1611 Test string escaping:
1606 1612
1607 1613 $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
1608 1614 >
1609 1615 <>\n<[>
1610 1616 <>\n<]>
1611 1617 <>\n<
1612 1618
1613 1619 "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
1614 1620
1615 1621 $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
1616 1622 \x6e
1617 1623 $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
1618 1624 \x5c\x786e
1619 1625 $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
1620 1626 \x6e
1621 1627 $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
1622 1628 \x5c\x786e
1623 1629
1624 1630 $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
1625 1631 \x6e
1626 1632 $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
1627 1633 \x5c\x786e
1628 1634 $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
1629 1635 \x6e
1630 1636 $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
1631 1637 \x5c\x786e
1632 1638
1633 1639 $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
1634 1640 fourth
1635 1641 second
1636 1642 third
1637 1643 $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
1638 1644 fourth\nsecond\nthird
1639 1645
1640 1646 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
1641 1647 <p>
1642 1648 1st
1643 1649 </p>
1644 1650 <p>
1645 1651 2nd
1646 1652 </p>
1647 1653 $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
1648 1654 <p>
1649 1655 1st\n\n2nd
1650 1656 </p>
1651 1657 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
1652 1658 1st
1653 1659
1654 1660 2nd
1655 1661
1656 1662 $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
1657 1663 o perso
1658 1664 $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
1659 1665 no person
1660 1666 $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
1661 1667 o perso
1662 1668 $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
1663 1669 no perso
1664 1670
1665 1671 $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
1666 1672 -o perso-
1667 1673 $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
1668 1674 no person
1669 1675 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
1670 1676 \x2do perso\x2d
1671 1677 $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
1672 1678 -o perso-
1673 1679 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
1674 1680 \x2do perso\x6e
1675 1681
1676 1682 $ hg log -R a -r 8 --template '{files % "{file}\n"}'
1677 1683 fourth
1678 1684 second
1679 1685 third
1680 1686 $ hg log -R a -r 8 --template '{files % r"{file}\n"}\n'
1681 1687 fourth\nsecond\nthird\n
1682 1688
1683 1689 Test string escapeing in nested expression:
1684 1690
1685 1691 $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
1686 1692 fourth\x6esecond\x6ethird
1687 1693 $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
1688 1694 fourth\x6esecond\x6ethird
1689 1695
1690 1696 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
1691 1697 fourth\x6esecond\x6ethird
1692 1698 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
1693 1699 fourth\x5c\x786esecond\x5c\x786ethird
1694 1700
1695 1701 $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
1696 1702 3:\x6eo user, \x6eo domai\x6e
1697 1703 4:\x5c\x786eew bra\x5c\x786ech
1698 1704
1699 1705 Test recursive evaluation:
1700 1706
1701 1707 $ hg init r
1702 1708 $ cd r
1703 1709 $ echo a > a
1704 1710 $ hg ci -Am '{rev}'
1705 1711 adding a
1706 1712 $ hg log -r 0 --template '{if(rev, desc)}\n'
1707 1713 {rev}
1708 1714 $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n'
1709 1715 test 0
1710 1716
1711 1717 $ hg branch -q 'text.{rev}'
1712 1718 $ echo aa >> aa
1713 1719 $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
1714 1720
1715 1721 $ hg log -r 1 --template '{fill(desc, "20", author, branch)}'
1716 1722 {node|short}desc to
1717 1723 text.{rev}be wrapped
1718 1724 text.{rev}desc to be
1719 1725 text.{rev}wrapped (no-eol)
1720 1726 $ hg log -r 1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}'
1721 1727 bcc7ff960b8e:desc to
1722 1728 text.1:be wrapped
1723 1729 text.1:desc to be
1724 1730 text.1:wrapped (no-eol)
1725 1731
1726 1732 $ hg log -r 1 --template '{sub(r"[0-9]", "-", author)}'
1727 1733 {node|short} (no-eol)
1728 1734 $ hg log -r 1 --template '{sub(r"[0-9]", "-", "{node|short}")}'
1729 1735 bcc-ff---b-e (no-eol)
1730 1736
1731 1737 $ cat >> .hg/hgrc <<EOF
1732 1738 > [extensions]
1733 1739 > color=
1734 1740 > [color]
1735 1741 > mode=ansi
1736 1742 > text.{rev} = red
1737 1743 > text.1 = green
1738 1744 > EOF
1739 1745 $ hg log --color=always -r 1 --template '{label(branch, "text\n")}'
1740 1746 \x1b[0;31mtext\x1b[0m (esc)
1741 1747 $ hg log --color=always -r 1 --template '{label("text.{rev}", "text\n")}'
1742 1748 \x1b[0;32mtext\x1b[0m (esc)
1743 1749
1744 1750 Test branches inside if statement:
1745 1751
1746 1752 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
1747 1753 no
1748 1754
1749 1755 $ cd ..
1750 1756
1751 1757 Test stringify on sub expressions
1752 1758
1753 1759 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
1754 1760 fourth, second, third
1755 1761 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
1756 1762 abc
General Comments 0
You need to be logged in to leave comments. Login now