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