##// END OF EJS Templates
test-template: fix stdio mode on Windows...
Yuya Nishihara -
r42167:a6696540 default
parent child Browse files
Show More
@@ -1,1605 +1,1609
1 1 Test template filters and functions
2 2 ===================================
3 3
4 4 $ hg init a
5 5 $ cd a
6 6 $ echo a > a
7 7 $ hg add a
8 8 $ echo line 1 > b
9 9 $ echo line 2 >> b
10 10 $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>'
11 11
12 12 $ hg add b
13 13 $ echo other 1 > c
14 14 $ echo other 2 >> c
15 15 $ echo >> c
16 16 $ echo other 3 >> c
17 17 $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>'
18 18
19 19 $ hg add c
20 20 $ hg commit -m 'no person' -d '1200000 0' -u 'other@place'
21 21 $ echo c >> c
22 22 $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person'
23 23
24 24 $ echo foo > .hg/branch
25 25 $ hg commit -m 'new branch' -d '1400000 0' -u 'person'
26 26
27 27 $ hg co -q 3
28 28 $ echo other 4 >> d
29 29 $ hg add d
30 30 $ hg commit -m 'new head' -d '1500000 0' -u 'person'
31 31
32 32 $ hg merge -q foo
33 33 $ hg commit -m 'merge' -d '1500001 0' -u 'person'
34 34
35 35 Second branch starting at nullrev:
36 36
37 37 $ hg update null
38 38 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
39 39 $ echo second > second
40 40 $ hg add second
41 41 $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
42 42 created new head
43 43
44 44 $ echo third > third
45 45 $ hg add third
46 46 $ hg mv second fourth
47 47 $ hg commit -m third -d "2020-01-01 10:01"
48 48
49 49 $ hg phase -r 5 --public
50 50 $ hg phase -r 7 --secret --force
51 51
52 52 Filters work:
53 53
54 54 $ hg log --template '{author|domain}\n'
55 55
56 56 hostname
57 57
58 58
59 59
60 60
61 61 place
62 62 place
63 63 hostname
64 64
65 65 $ hg log --template '{author|person}\n'
66 66 test
67 67 User Name
68 68 person
69 69 person
70 70 person
71 71 person
72 72 other
73 73 A. N. Other
74 74 User Name
75 75
76 76 $ hg log --template '{author|user}\n'
77 77 test
78 78 user
79 79 person
80 80 person
81 81 person
82 82 person
83 83 other
84 84 other
85 85 user
86 86
87 87 $ hg log --template '{date|date}\n'
88 88 Wed Jan 01 10:01:00 2020 +0000
89 89 Mon Jan 12 13:46:40 1970 +0000
90 90 Sun Jan 18 08:40:01 1970 +0000
91 91 Sun Jan 18 08:40:00 1970 +0000
92 92 Sat Jan 17 04:53:20 1970 +0000
93 93 Fri Jan 16 01:06:40 1970 +0000
94 94 Wed Jan 14 21:20:00 1970 +0000
95 95 Tue Jan 13 17:33:20 1970 +0000
96 96 Mon Jan 12 13:46:40 1970 +0000
97 97
98 98 $ hg log --template '{date|isodate}\n'
99 99 2020-01-01 10:01 +0000
100 100 1970-01-12 13:46 +0000
101 101 1970-01-18 08:40 +0000
102 102 1970-01-18 08:40 +0000
103 103 1970-01-17 04:53 +0000
104 104 1970-01-16 01:06 +0000
105 105 1970-01-14 21:20 +0000
106 106 1970-01-13 17:33 +0000
107 107 1970-01-12 13:46 +0000
108 108
109 109 $ hg log --template '{date|isodatesec}\n'
110 110 2020-01-01 10:01:00 +0000
111 111 1970-01-12 13:46:40 +0000
112 112 1970-01-18 08:40:01 +0000
113 113 1970-01-18 08:40:00 +0000
114 114 1970-01-17 04:53:20 +0000
115 115 1970-01-16 01:06:40 +0000
116 116 1970-01-14 21:20:00 +0000
117 117 1970-01-13 17:33:20 +0000
118 118 1970-01-12 13:46:40 +0000
119 119
120 120 $ hg log --template '{date|rfc822date}\n'
121 121 Wed, 01 Jan 2020 10:01:00 +0000
122 122 Mon, 12 Jan 1970 13:46:40 +0000
123 123 Sun, 18 Jan 1970 08:40:01 +0000
124 124 Sun, 18 Jan 1970 08:40:00 +0000
125 125 Sat, 17 Jan 1970 04:53:20 +0000
126 126 Fri, 16 Jan 1970 01:06:40 +0000
127 127 Wed, 14 Jan 1970 21:20:00 +0000
128 128 Tue, 13 Jan 1970 17:33:20 +0000
129 129 Mon, 12 Jan 1970 13:46:40 +0000
130 130
131 131 $ hg log --template '{desc|firstline}\n'
132 132 third
133 133 second
134 134 merge
135 135 new head
136 136 new branch
137 137 no user, no domain
138 138 no person
139 139 other 1
140 140 line 1
141 141
142 142 $ hg log --template '{node|short}\n'
143 143 95c24699272e
144 144 29114dbae42b
145 145 d41e714fe50d
146 146 13207e5a10d9
147 147 bbe44766e73d
148 148 10e46f2dcbf4
149 149 97054abb4ab8
150 150 b608e9d1a3f0
151 151 1e4e1b8f71e0
152 152
153 153 $ hg log --template '<changeset author="{author|xmlescape}"/>\n'
154 154 <changeset author="test"/>
155 155 <changeset author="User Name &lt;user@hostname&gt;"/>
156 156 <changeset author="person"/>
157 157 <changeset author="person"/>
158 158 <changeset author="person"/>
159 159 <changeset author="person"/>
160 160 <changeset author="other@place"/>
161 161 <changeset author="A. N. Other &lt;other@place&gt;"/>
162 162 <changeset author="User Name &lt;user@hostname&gt;"/>
163 163
164 164 $ hg log --template '{rev}: {children}\n'
165 165 8:
166 166 7: 8:95c24699272e
167 167 6:
168 168 5: 6:d41e714fe50d
169 169 4: 6:d41e714fe50d
170 170 3: 4:bbe44766e73d 5:13207e5a10d9
171 171 2: 3:10e46f2dcbf4
172 172 1: 2:97054abb4ab8
173 173 0: 1:b608e9d1a3f0
174 174
175 175 Formatnode filter works:
176 176
177 177 $ hg -q log -r 0 --template '{node|formatnode}\n'
178 178 1e4e1b8f71e0
179 179
180 180 $ hg log -r 0 --template '{node|formatnode}\n'
181 181 1e4e1b8f71e0
182 182
183 183 $ hg -v log -r 0 --template '{node|formatnode}\n'
184 184 1e4e1b8f71e0
185 185
186 186 $ hg --debug log -r 0 --template '{node|formatnode}\n'
187 187 1e4e1b8f71e05681d422154f5421e385fec3454f
188 188
189 189 Age filter:
190 190
191 191 $ hg init unstable-hash
192 192 $ cd unstable-hash
193 193 $ hg log --template '{date|age}\n' > /dev/null || exit 1
194 194
195 195 >>> from __future__ import absolute_import
196 196 >>> import datetime
197 197 >>> fp = open('a', 'wb')
198 198 >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
199 199 >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day)) and None
200 200 >>> fp.close()
201 201 $ hg add a
202 202 $ hg commit -m future -d "`cat a`"
203 203
204 204 $ hg log -l1 --template '{date|age}\n'
205 205 7 years from now
206 206
207 207 $ cd ..
208 208 $ rm -rf unstable-hash
209 209
210 210 Filename filters:
211 211
212 212 $ hg debugtemplate '{"foo/bar"|basename}|{"foo/"|basename}|{"foo"|basename}|\n'
213 213 bar||foo|
214 214 $ hg debugtemplate '{"foo/bar"|dirname}|{"foo/"|dirname}|{"foo"|dirname}|\n'
215 215 foo|foo||
216 216 $ hg debugtemplate '{"foo/bar"|stripdir}|{"foo/"|stripdir}|{"foo"|stripdir}|\n'
217 217 foo|foo|foo|
218 218
219 219 commondir() filter:
220 220
221 221 $ hg debugtemplate '{""|splitlines|commondir}\n'
222 222
223 223 $ hg debugtemplate '{"foo/bar\nfoo/baz\nfoo/foobar\n"|splitlines|commondir}\n'
224 224 foo
225 225 $ hg debugtemplate '{"foo/bar\nfoo/bar\n"|splitlines|commondir}\n'
226 226 foo
227 227 $ hg debugtemplate '{"/foo/bar\n/foo/bar\n"|splitlines|commondir}\n'
228 228 foo
229 229 $ hg debugtemplate '{"/foo\n/foo\n"|splitlines|commondir}\n'
230 230
231 231 $ hg debugtemplate '{"foo/bar\nbar/baz"|splitlines|commondir}\n'
232 232
233 233 $ hg debugtemplate '{"foo/bar\nbar/baz\nbar/foo\n"|splitlines|commondir}\n'
234 234
235 235 $ hg debugtemplate '{"foo/../bar\nfoo/bar"|splitlines|commondir}\n'
236 236 foo
237 237 $ hg debugtemplate '{"foo\n/foo"|splitlines|commondir}\n'
238 238
239 239
240 240 $ hg log -r null -T '{rev|commondir}'
241 241 hg: parse error: argument is not a list of text
242 242 (template filter 'commondir' is not compatible with keyword 'rev')
243 243 [255]
244 244
245 245 Add a dummy commit to make up for the instability of the above:
246 246
247 247 $ echo a > a
248 248 $ hg add a
249 249 $ hg ci -m future
250 250
251 251 Count filter:
252 252
253 253 $ hg log -l1 --template '{node|count} {node|short|count}\n'
254 254 40 12
255 255
256 256 $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n'
257 257 0 1 4
258 258
259 259 $ hg log -G --template '{rev}: children: {children|count}, \
260 260 > tags: {tags|count}, file_adds: {file_adds|count}, \
261 261 > ancestors: {revset("ancestors(%s)", rev)|count}'
262 262 @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3
263 263 |
264 264 o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2
265 265 |
266 266 o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1
267 267
268 268 o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7
269 269 |\
270 270 | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5
271 271 | |
272 272 o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5
273 273 |/
274 274 o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4
275 275 |
276 276 o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3
277 277 |
278 278 o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2
279 279 |
280 280 o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1
281 281
282 282
283 283 $ hg log -l1 -T '{termwidth|count}\n'
284 284 hg: parse error: not countable
285 285 (template filter 'count' is not compatible with keyword 'termwidth')
286 286 [255]
287 287
288 288 Upper/lower filters:
289 289
290 290 $ hg log -r0 --template '{branch|upper}\n'
291 291 DEFAULT
292 292 $ hg log -r0 --template '{author|lower}\n'
293 293 user name <user@hostname>
294 294 $ hg log -r0 --template '{date|upper}\n'
295 295 1000000.00
296 296
297 297 Add a commit that does all possible modifications at once
298 298
299 299 $ echo modify >> third
300 300 $ touch b
301 301 $ hg add b
302 302 $ hg mv fourth fifth
303 303 $ hg rm a
304 304 $ hg ci -m "Modify, add, remove, rename"
305 305
306 306 Pass generator object created by template function to filter
307 307
308 308 $ hg log -l 1 --template '{if(author, author)|user}\n'
309 309 test
310 310
311 311 Test diff function:
312 312
313 313 $ hg diff -c 8
314 314 diff -r 29114dbae42b -r 95c24699272e fourth
315 315 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
316 316 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
317 317 @@ -0,0 +1,1 @@
318 318 +second
319 319 diff -r 29114dbae42b -r 95c24699272e second
320 320 --- a/second Mon Jan 12 13:46:40 1970 +0000
321 321 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
322 322 @@ -1,1 +0,0 @@
323 323 -second
324 324 diff -r 29114dbae42b -r 95c24699272e third
325 325 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
326 326 +++ b/third Wed Jan 01 10:01:00 2020 +0000
327 327 @@ -0,0 +1,1 @@
328 328 +third
329 329
330 330 $ hg log -r 8 -T "{diff()}"
331 331 diff -r 29114dbae42b -r 95c24699272e fourth
332 332 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
333 333 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
334 334 @@ -0,0 +1,1 @@
335 335 +second
336 336 diff -r 29114dbae42b -r 95c24699272e second
337 337 --- a/second Mon Jan 12 13:46:40 1970 +0000
338 338 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
339 339 @@ -1,1 +0,0 @@
340 340 -second
341 341 diff -r 29114dbae42b -r 95c24699272e third
342 342 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
343 343 +++ b/third Wed Jan 01 10:01:00 2020 +0000
344 344 @@ -0,0 +1,1 @@
345 345 +third
346 346
347 347 $ hg log -r 8 -T "{diff('glob:f*')}"
348 348 diff -r 29114dbae42b -r 95c24699272e fourth
349 349 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
350 350 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
351 351 @@ -0,0 +1,1 @@
352 352 +second
353 353
354 354 $ hg log -r 8 -T "{diff('', 'glob:f*')}"
355 355 diff -r 29114dbae42b -r 95c24699272e second
356 356 --- a/second Mon Jan 12 13:46:40 1970 +0000
357 357 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
358 358 @@ -1,1 +0,0 @@
359 359 -second
360 360 diff -r 29114dbae42b -r 95c24699272e third
361 361 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
362 362 +++ b/third Wed Jan 01 10:01:00 2020 +0000
363 363 @@ -0,0 +1,1 @@
364 364 +third
365 365
366 366 $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
367 367 diff -r 29114dbae42b -r 95c24699272e fourth
368 368 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
369 369 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
370 370 @@ -0,0 +1,1 @@
371 371 +second
372 372
373 373 $ cd ..
374 374
375 375 latesttag() function:
376 376
377 377 $ hg init latesttag
378 378 $ cd latesttag
379 379
380 380 $ echo a > file
381 381 $ hg ci -Am a -d '0 0'
382 382 adding file
383 383
384 384 $ echo b >> file
385 385 $ hg ci -m b -d '1 0'
386 386
387 387 $ echo c >> head1
388 388 $ hg ci -Am h1c -d '2 0'
389 389 adding head1
390 390
391 391 $ hg update -q 1
392 392 $ echo d >> head2
393 393 $ hg ci -Am h2d -d '3 0'
394 394 adding head2
395 395 created new head
396 396
397 397 $ echo e >> head2
398 398 $ hg ci -m h2e -d '4 0'
399 399
400 400 $ hg merge -q
401 401 $ hg ci -m merge -d '5 -3600'
402 402
403 403 $ hg tag -r 1 -m t1 -d '6 0' t1
404 404 $ hg tag -r 2 -m t2 -d '7 0' t2
405 405 $ hg tag -r 3 -m t3 -d '8 0' t3
406 406 $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
407 407 $ hg tag -r 5 -m t5 -d '9 0' t5
408 408 $ hg tag -r 3 -m at3 -d '10 0' at3
409 409
410 410 $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n"
411 411 @ 11: t3, C: 9, D: 8
412 412 |
413 413 o 10: t3, C: 8, D: 7
414 414 |
415 415 o 9: t3, C: 7, D: 6
416 416 |
417 417 o 8: t3, C: 6, D: 5
418 418 |
419 419 o 7: t3, C: 5, D: 4
420 420 |
421 421 o 6: t3, C: 4, D: 3
422 422 |
423 423 o 5: t3, C: 3, D: 2
424 424 |\
425 425 | o 4: t3, C: 1, D: 1
426 426 | |
427 427 | o 3: t3, C: 0, D: 0
428 428 | |
429 429 o | 2: t1, C: 1, D: 1
430 430 |/
431 431 o 1: t1, C: 0, D: 0
432 432 |
433 433 o 0: null, C: 1, D: 1
434 434
435 435
436 436 $ cd ..
437 437
438 438 Test filter() empty values:
439 439
440 440 $ hg log -R a -r 1 -T '{filter(desc|splitlines) % "{line}\n"}'
441 441 other 1
442 442 other 2
443 443 other 3
444 444 $ hg log -R a -r 0 -T '{filter(dict(a=0, b=1) % "{ifeq(key, "a", "{value}\n")}")}'
445 445 0
446 446
447 447 0 should not be falsy
448 448
449 449 $ hg log -R a -r 0 -T '{filter(revset("0:2"))}\n'
450 450 0 1 2
451 451
452 452 Test filter() by expression:
453 453
454 454 $ hg log -R a -r 1 -T '{filter(desc|splitlines, ifcontains("1", line, "t"))}\n'
455 455 other 1
456 456 $ hg log -R a -r 0 -T '{filter(dict(a=0, b=1), ifeq(key, "b", "t"))}\n'
457 457 b=1
458 458
459 459 Test filter() shouldn't crash:
460 460
461 461 $ hg log -R a -r 0 -T '{filter(extras)}\n'
462 462 branch=default
463 463 $ hg log -R a -r 0 -T '{filter(files)}\n'
464 464 a
465 465
466 466 Test filter() unsupported arguments:
467 467
468 468 $ hg log -R a -r 0 -T '{filter()}\n'
469 469 hg: parse error: filter expects one or two arguments
470 470 [255]
471 471 $ hg log -R a -r 0 -T '{filter(date)}\n'
472 472 hg: parse error: date is not iterable
473 473 [255]
474 474 $ hg log -R a -r 0 -T '{filter(rev)}\n'
475 475 hg: parse error: 0 is not iterable
476 476 [255]
477 477 $ hg log -R a -r 0 -T '{filter(desc|firstline)}\n'
478 478 hg: parse error: 'line 1' is not filterable
479 479 [255]
480 480 $ hg log -R a -r 0 -T '{filter(manifest)}\n'
481 481 hg: parse error: '0:a0c8bcbbb45c' is not filterable
482 482 [255]
483 483 $ hg log -R a -r 0 -T '{filter(succsandmarkers)}\n'
484 484 hg: parse error: not filterable without template
485 485 [255]
486 486 $ hg log -R a -r 0 -T '{filter(desc|splitlines % "{line}", "")}\n'
487 487 hg: parse error: not filterable by expression
488 488 [255]
489 489
490 490 Test manifest/get() can be join()-ed as string, though it's silly:
491 491
492 492 $ hg log -R latesttag -r tip -T '{join(manifest, ".")}\n'
493 493 1.1.:.2.b.c.6.e.9.0.0.6.c.e.2
494 494 $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), ".")}\n'
495 495 d.e.f.a.u.l.t
496 496
497 497 Test join() over string
498 498
499 499 $ hg log -R latesttag -r tip -T '{join(rev|stringify, ".")}\n'
500 500 1.1
501 501
502 502 Test join() over uniterable
503 503
504 504 $ hg log -R latesttag -r tip -T '{join(rev, "")}\n'
505 505 hg: parse error: 11 is not iterable
506 506 [255]
507 507
508 508 Test min/max of integers
509 509
510 510 $ hg log -R latesttag -l1 -T '{min(revset("9:10"))}\n'
511 511 9
512 512 $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n'
513 513 10
514 514
515 515 Test min/max over map operation:
516 516
517 517 $ hg log -R latesttag -r3 -T '{min(tags % "{tag}")}\n'
518 518 at3
519 519 $ hg log -R latesttag -r3 -T '{max(tags % "{tag}")}\n'
520 520 t3
521 521
522 522 Test min/max of strings:
523 523
524 524 $ hg log -R latesttag -l1 -T '{min(desc)}\n'
525 525 3
526 526 $ hg log -R latesttag -l1 -T '{max(desc)}\n'
527 527 t
528 528
529 529 Test min/max of non-iterable:
530 530
531 531 $ hg debugtemplate '{min(1)}'
532 532 hg: parse error: 1 is not iterable
533 533 (min first argument should be an iterable)
534 534 [255]
535 535 $ hg debugtemplate '{max(2)}'
536 536 hg: parse error: 2 is not iterable
537 537 (max first argument should be an iterable)
538 538 [255]
539 539
540 540 $ hg log -R latesttag -l1 -T '{min(date)}'
541 541 hg: parse error: date is not iterable
542 542 (min first argument should be an iterable)
543 543 [255]
544 544 $ hg log -R latesttag -l1 -T '{max(date)}'
545 545 hg: parse error: date is not iterable
546 546 (max first argument should be an iterable)
547 547 [255]
548 548
549 549 Test min/max of empty sequence:
550 550
551 551 $ hg debugtemplate '{min("")}'
552 552 hg: parse error: empty string
553 553 (min first argument should be an iterable)
554 554 [255]
555 555 $ hg debugtemplate '{max("")}'
556 556 hg: parse error: empty string
557 557 (max first argument should be an iterable)
558 558 [255]
559 559 $ hg debugtemplate '{min(dict())}'
560 560 hg: parse error: empty sequence
561 561 (min first argument should be an iterable)
562 562 [255]
563 563 $ hg debugtemplate '{max(dict())}'
564 564 hg: parse error: empty sequence
565 565 (max first argument should be an iterable)
566 566 [255]
567 567 $ hg debugtemplate '{min(dict() % "")}'
568 568 hg: parse error: empty sequence
569 569 (min first argument should be an iterable)
570 570 [255]
571 571 $ hg debugtemplate '{max(dict() % "")}'
572 572 hg: parse error: empty sequence
573 573 (max first argument should be an iterable)
574 574 [255]
575 575
576 576 Test min/max of if() result
577 577
578 578 $ cd latesttag
579 579 $ hg log -l1 -T '{min(if(true, revset("9:10"), ""))}\n'
580 580 9
581 581 $ hg log -l1 -T '{max(if(false, "", revset("9:10")))}\n'
582 582 10
583 583 $ hg log -l1 -T '{min(ifcontains("a", "aa", revset("9:10"), ""))}\n'
584 584 9
585 585 $ hg log -l1 -T '{max(ifcontains("a", "bb", "", revset("9:10")))}\n'
586 586 10
587 587 $ hg log -l1 -T '{min(ifeq(0, 0, revset("9:10"), ""))}\n'
588 588 9
589 589 $ hg log -l1 -T '{max(ifeq(0, 1, "", revset("9:10")))}\n'
590 590 10
591 591 $ cd ..
592 592
593 593 Test laziness of if() then/else clause
594 594
595 595 $ hg debugtemplate '{count(0)}'
596 596 hg: parse error: not countable
597 597 (incompatible use of template filter 'count')
598 598 [255]
599 599 $ hg debugtemplate '{if(true, "", count(0))}'
600 600 $ hg debugtemplate '{if(false, count(0), "")}'
601 601 $ hg debugtemplate '{ifcontains("a", "aa", "", count(0))}'
602 602 $ hg debugtemplate '{ifcontains("a", "bb", count(0), "")}'
603 603 $ hg debugtemplate '{ifeq(0, 0, "", count(0))}'
604 604 $ hg debugtemplate '{ifeq(0, 1, count(0), "")}'
605 605
606 606 Test search() function:
607 607
608 608 $ hg log -R a -r2 -T '{desc}\n'
609 609 no person
610 610
611 611 $ hg log -R a -r2 -T '{search(r"p.*", desc)}\n'
612 612 person
613 613
614 614 as bool
615 615
616 616 $ hg log -R a -r2 -T '{if(search(r"p.*", desc), "", "not ")}found\n'
617 617 found
618 618 $ hg log -R a -r2 -T '{if(search(r"q", desc), "", "not ")}found\n'
619 619 not found
620 620
621 621 match as json
622 622
623 623 $ hg log -R a -r2 -T '{search(r"(no) p.*", desc)|json}\n'
624 624 {"0": "no person", "1": "no"}
625 625 $ hg log -R a -r2 -T '{search(r"q", desc)|json}\n'
626 626 null
627 627
628 628 group reference
629 629
630 630 $ hg log -R a -r2 -T '{search(r"(no) (p.*)", desc) % "{1|upper} {2|hex}"}\n'
631 631 NO 706572736f6e
632 632 $ hg log -R a -r2 -T '{search(r"(?P<foo>[a-z]*)", desc) % "{foo}"}\n'
633 633 no
634 634 $ hg log -R a -r2 -T '{search(r"(?P<foo>[a-z]*)", desc).foo}\n'
635 635 no
636 636
637 637 group reference with no match
638 638
639 639 $ hg log -R a -r2 -T '{search(r"q", desc) % "match: {0}"}\n'
640 640
641 641
642 642 bad group names
643 643
644 644 $ hg log -R a -r2 -T '{search(r"(?P<0>.)", desc) % "{0}"}\n'
645 645 hg: parse error: search got an invalid pattern: (?P<0>.)
646 646 [255]
647 647 $ hg log -R a -r2 -T '{search(r"(?P<repo>.)", desc) % "{repo}"}\n'
648 648 hg: parse error: invalid group 'repo' in search pattern: (?P<repo>.)
649 649 [255]
650 650
651 651 Test the sub function of templating for expansion:
652 652
653 653 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
654 654 xx
655 655
656 656 $ hg log -R latesttag -r 10 -T '{sub("[", "x", rev)}\n'
657 657 hg: parse error: sub got an invalid pattern: [
658 658 [255]
659 659 $ hg log -R latesttag -r 10 -T '{sub("[0-9]", r"\1", rev)}\n'
660 660 hg: parse error: sub got an invalid replacement: \1
661 661 [255]
662 662
663 663 Test the strip function with chars specified:
664 664
665 665 $ hg log -R latesttag --template '{desc}\n'
666 666 at3
667 667 t5
668 668 t4
669 669 t3
670 670 t2
671 671 t1
672 672 merge
673 673 h2e
674 674 h2d
675 675 h1c
676 676 b
677 677 a
678 678
679 679 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
680 680 at3
681 681 5
682 682 4
683 683 3
684 684 2
685 685 1
686 686 merg
687 687 h2
688 688 h2d
689 689 h1c
690 690 b
691 691 a
692 692
693 693 Test date format:
694 694
695 695 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
696 696 date: 70 01 01 10 +0000
697 697 date: 70 01 01 09 +0000
698 698 date: 70 01 01 04 +0000
699 699 date: 70 01 01 08 +0000
700 700 date: 70 01 01 07 +0000
701 701 date: 70 01 01 06 +0000
702 702 date: 70 01 01 05 +0100
703 703 date: 70 01 01 04 +0000
704 704 date: 70 01 01 03 +0000
705 705 date: 70 01 01 02 +0000
706 706 date: 70 01 01 01 +0000
707 707 date: 70 01 01 00 +0000
708 708
709 709 Test invalid date:
710 710
711 711 $ hg log -R latesttag -T '{date(rev)}\n'
712 712 hg: parse error: date expects a date information
713 713 [255]
714 714
715 715 Set up repository containing template fragments in commit metadata:
716 716
717 717 $ hg init r
718 718 $ cd r
719 719 $ echo a > a
720 720 $ hg ci -Am '{rev}'
721 721 adding a
722 722
723 723 $ hg branch -q 'text.{rev}'
724 724 $ echo aa >> aa
725 725 $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
726 726
727 727 color effect can be specified without quoting:
728 728
729 729 $ hg log --color=always -l 1 --template '{label(red, "text\n")}'
730 730 \x1b[0;31mtext\x1b[0m (esc)
731 731
732 732 color effects can be nested (issue5413)
733 733
734 734 $ hg debugtemplate --color=always \
735 735 > '{label(red, "red{label(magenta, "ma{label(cyan, "cyan")}{label(yellow, "yellow")}genta")}")}\n'
736 736 \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)
737 737
738 738 pad() should interact well with color codes (issue5416)
739 739
740 740 $ hg debugtemplate --color=always \
741 741 > '{pad(label(red, "red"), 5, label(cyan, "-"))}\n'
742 742 \x1b[0;31mred\x1b[0m\x1b[0;36m-\x1b[0m\x1b[0;36m-\x1b[0m (esc)
743 743
744 744 pad() with truncate has to strip color codes, though
745 745
746 746 $ hg debugtemplate --color=always \
747 747 > '{pad(label(red, "scarlet"), 5, truncate=true)}\n'
748 748 scarl
749 749
750 750 label should be no-op if color is disabled:
751 751
752 752 $ hg log --color=never -l 1 --template '{label(red, "text\n")}'
753 753 text
754 754 $ hg log --config extensions.color=! -l 1 --template '{label(red, "text\n")}'
755 755 text
756 756
757 757 Test branches inside if statement:
758 758
759 759 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
760 760 no
761 761
762 762 Test dict constructor:
763 763
764 764 $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n'
765 765 y=f7769ec2ab97 x=0
766 766 $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}'
767 767 x=0
768 768 y=f7769ec2ab97
769 769 $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n'
770 770 {"x": 0, "y": "f7769ec2ab97"}
771 771 $ hg log -r 0 -T '{dict()|json}\n'
772 772 {}
773 773
774 774 $ hg log -r 0 -T '{dict(rev, node=node|short)}\n'
775 775 rev=0 node=f7769ec2ab97
776 776 $ hg log -r 0 -T '{dict(rev, node|short)}\n'
777 777 rev=0 node=f7769ec2ab97
778 778
779 779 $ hg log -r 0 -T '{dict(rev, rev=rev)}\n'
780 780 hg: parse error: duplicated dict key 'rev' inferred
781 781 [255]
782 782 $ hg log -r 0 -T '{dict(node, node|short)}\n'
783 783 hg: parse error: duplicated dict key 'node' inferred
784 784 [255]
785 785 $ hg log -r 0 -T '{dict(1 + 2)}'
786 786 hg: parse error: dict key cannot be inferred
787 787 [255]
788 788
789 789 $ hg log -r 0 -T '{dict(x=rev, x=node)}'
790 790 hg: parse error: dict got multiple values for keyword argument 'x'
791 791 [255]
792 792
793 793 Test get function:
794 794
795 795 $ hg log -r 0 --template '{get(extras, "branch")}\n'
796 796 default
797 797 $ hg log -r 0 --template '{get(extras, "br{"anch"}")}\n'
798 798 default
799 799 $ hg log -r 0 --template '{get(files, "should_fail")}\n'
800 800 hg: parse error: not a dictionary
801 801 (get() expects a dict as first argument)
802 802 [255]
803 803
804 804 Test json filter applied to wrapped object:
805 805
806 806 $ hg log -r0 -T '{files|json}\n'
807 807 ["a"]
808 808 $ hg log -r0 -T '{extras|json}\n'
809 809 {"branch": "default"}
810 810 $ hg log -r0 -T '{date|json}\n'
811 811 [0, 0]
812 812
813 813 Test json filter applied to map result:
814 814
815 815 $ hg log -r0 -T '{json(extras % "{key}")}\n'
816 816 ["branch"]
817 817
818 818 Test localdate(date, tz) function:
819 819
820 820 $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n'
821 821 1970-01-01 09:00 +0900
822 822 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n'
823 823 1970-01-01 00:00 +0000
824 824 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "blahUTC")|isodate}\n'
825 825 hg: parse error: localdate expects a timezone
826 826 [255]
827 827 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n'
828 828 1970-01-01 02:00 +0200
829 829 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n'
830 830 1970-01-01 00:00 +0000
831 831 $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n'
832 832 1970-01-01 00:00 +0000
833 833 $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n'
834 834 hg: parse error: localdate expects a timezone
835 835 [255]
836 836 $ hg log -r0 -T '{localdate(date, date)|isodate}\n'
837 837 hg: parse error: localdate expects a timezone
838 838 [255]
839 839
840 840 Test shortest(node) function:
841 841
842 842 $ echo b > b
843 843 $ hg ci -qAm b
844 844 $ hg log --template '{shortest(node)}\n'
845 845 e777
846 846 bcc7
847 847 f776
848 848 $ hg log --template '{shortest(node, 10)}\n'
849 849 e777603221
850 850 bcc7ff960b
851 851 f7769ec2ab
852 852 $ hg log --template '{shortest(node, 1)}\n' -r null
853 853 00
854 854 $ hg log --template '{node|shortest}\n' -l1
855 855 e777
856 856
857 857 $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n'
858 858 f7769ec2ab
859 859 $ hg log -r 0 -T '{shortest(node, "not an int")}\n'
860 860 hg: parse error: shortest() expects an integer minlength
861 861 [255]
862 862
863 863 $ hg log -r 'wdir()' -T '{node|shortest}\n'
864 864 ffff
865 865
866 866 $ hg log --template '{shortest("f")}\n' -l1
867 867 f
868 868
869 869 $ hg log --template '{shortest("0123456789012345678901234567890123456789")}\n' -l1
870 870 0123456789012345678901234567890123456789
871 871
872 872 $ hg log --template '{shortest("01234567890123456789012345678901234567890123456789")}\n' -l1
873 873 01234567890123456789012345678901234567890123456789
874 874
875 875 $ hg log --template '{shortest("not a hex string")}\n' -l1
876 876 not a hex string
877 877
878 878 $ hg log --template '{shortest("not a hex string, but it'\''s 40 bytes long")}\n' -l1
879 879 not a hex string, but it's 40 bytes long
880 880
881 881 $ hg log --template '{shortest("ffffffffffffffffffffffffffffffffffffffff")}\n' -l1
882 882 ffff
883 883
884 884 $ hg log --template '{shortest("fffffff")}\n' -l1
885 885 ffff
886 886
887 887 $ hg log --template '{shortest("ff")}\n' -l1
888 888 ffff
889 889
890 890 $ cd ..
891 891
892 892 Test shortest(node) with the repo having short hash collision:
893 893
894 894 $ hg init hashcollision
895 895 $ cd hashcollision
896 896 $ cat <<EOF >> .hg/hgrc
897 897 > [experimental]
898 898 > evolution.createmarkers=True
899 899 > EOF
900 900 $ echo 0 > a
901 901 $ hg ci -qAm 0
902 902 $ for i in 17 129 248 242 480 580 617 1057 2857 4025; do
903 903 > hg up -q 0
904 904 > echo $i > a
905 905 > hg ci -qm $i
906 906 > done
907 907 $ hg up -q null
908 908 $ hg log -r0: -T '{rev}:{node}\n'
909 909 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
910 910 1:11424df6dc1dd4ea255eae2b58eaca7831973bbc
911 911 2:11407b3f1b9c3e76a79c1ec5373924df096f0499
912 912 3:11dd92fe0f39dfdaacdaa5f3997edc533875cfc4
913 913 4:10776689e627b465361ad5c296a20a487e153ca4
914 914 5:a00be79088084cb3aff086ab799f8790e01a976b
915 915 6:a0b0acd79b4498d0052993d35a6a748dd51d13e6
916 916 7:a0457b3450b8e1b778f1163b31a435802987fe5d
917 917 8:c56256a09cd28e5764f32e8e2810d0f01e2e357a
918 918 9:c5623987d205cd6d9d8389bfc40fff9dbb670b48
919 919 10:c562ddd9c94164376c20b86b0b4991636a3bf84f
920 920 $ hg debugobsolete a00be79088084cb3aff086ab799f8790e01a976b
921 921 obsoleted 1 changesets
922 922 $ hg debugobsolete c5623987d205cd6d9d8389bfc40fff9dbb670b48
923 923 obsoleted 1 changesets
924 924 $ hg debugobsolete c562ddd9c94164376c20b86b0b4991636a3bf84f
925 925 obsoleted 1 changesets
926 926
927 927 nodes starting with '11' (we don't have the revision number '11' though)
928 928
929 929 $ hg log -r 1:3 -T '{rev}:{shortest(node, 0)}\n'
930 930 1:1142
931 931 2:1140
932 932 3:11d
933 933
934 934 '5:a00' is hidden, but still we have two nodes starting with 'a0'
935 935
936 936 $ hg log -r 6:7 -T '{rev}:{shortest(node, 0)}\n'
937 937 6:a0b
938 938 7:a04
939 939
940 940 node '10' conflicts with the revision number '10' even if it is hidden
941 941 (we could exclude hidden revision numbers, but currently we don't)
942 942
943 943 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n'
944 944 4:107
945 945 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden
946 946 4:107
947 947
948 948 $ hg --config experimental.revisions.prefixhexnode=yes log -r 4 -T '{rev}:{shortest(node, 0)}\n'
949 949 4:x10
950 950 $ hg --config experimental.revisions.prefixhexnode=yes log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden
951 951 4:x10
952 952
953 953 node 'c562' should be unique if the other 'c562' nodes are hidden
954 954 (but we don't try the slow path to filter out hidden nodes for now)
955 955
956 956 $ hg log -r 8 -T '{rev}:{node|shortest}\n'
957 957 8:c5625
958 958 $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden
959 959 8:c5625
960 960 9:c5623
961 961 10:c562d
962 962
963 963 $ cd ..
964 964
965 965 Test prefixhexnode when the first character of the hash is 0.
966 966 $ hg init hashcollision2
967 967 $ cd hashcollision2
968 968 $ cat <<EOF >> .hg/hgrc
969 969 > [experimental]
970 970 > evolution.createmarkers=True
971 971 > EOF
972 972 $ echo 0 > a
973 973 $ hg ci -qAm 0
974 974 $ echo 21 > a
975 975 $ hg ci -qm 21
976 976 $ hg up -q null
977 977 $ hg log -r0: -T '{rev}:{node}\n'
978 978 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
979 979 1:0cf177ba2b1dc3862a00fb81715fec90950201be
980 980
981 981 we need the 'x' prefix to ensure we aren't colliding with rev0. We identify
982 982 the collision with nullid if we aren't using disambiguatewithin, so we need to set
983 983 that as well.
984 984 $ hg --config experimental.revisions.disambiguatewithin='descendants(0)' \
985 985 > --config experimental.revisions.prefixhexnode=yes \
986 986 > log -r 1 -T '{rev}:{shortest(node, 0)}\n'
987 987 1:x0
988 988
989 989 $ hg debugobsolete 0cf177ba2b1dc3862a00fb81715fec90950201be
990 990 obsoleted 1 changesets
991 991 $ hg up -q 0
992 992 $ echo 61 > a
993 993 $ hg ci -m 61
994 994 $ hg log -r0: -T '{rev}:{node}\n'
995 995 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
996 996 2:01384dde84b3a511ae0835f35ac40bd806c99bb8
997 997
998 998 we still have the 'x' prefix because '0' is still the shortest prefix, since
999 999 rev1's '0c' is hidden.
1000 1000 $ hg --config experimental.revisions.disambiguatewithin=0:-1-0 \
1001 1001 > --config experimental.revisions.prefixhexnode=yes \
1002 1002 > log -r 0:-1-0 -T '{rev}:{shortest(node, 0)}\n'
1003 1003 2:x0
1004 1004
1005 1005 we don't have the 'x' prefix on 2 because '01' is not a synonym for rev1.
1006 1006 $ hg --config experimental.revisions.disambiguatewithin=0:-1-0 \
1007 1007 > --config experimental.revisions.prefixhexnode=yes \
1008 1008 > log -r 0:-1-0 -T '{rev}:{shortest(node, 0)}\n' --hidden
1009 1009 1:0c
1010 1010 2:01
1011 1011
1012 1012 $ cd ..
1013 1013
1014 1014 Test pad function
1015 1015
1016 1016 $ cd r
1017 1017
1018 1018 $ hg log --template '{pad(rev, 20)} {author|user}\n'
1019 1019 2 test
1020 1020 1 {node|short}
1021 1021 0 test
1022 1022
1023 1023 $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n'
1024 1024 2 test
1025 1025 1 {node|short}
1026 1026 0 test
1027 1027
1028 1028 $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n'
1029 1029 2------------------- test
1030 1030 1------------------- {node|short}
1031 1031 0------------------- test
1032 1032
1033 1033 $ hg log --template '{pad(author, 5, "-", False, True)}\n'
1034 1034 test-
1035 1035 {node
1036 1036 test-
1037 1037 $ hg log --template '{pad(author, 5, "-", True, True)}\n'
1038 1038 -test
1039 1039 hort}
1040 1040 -test
1041 1041
1042 1042 Test template string in pad function
1043 1043
1044 1044 $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n'
1045 1045 {0} test
1046 1046
1047 1047 $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n'
1048 1048 \{rev} test
1049 1049
1050 1050 Test width argument passed to pad function
1051 1051
1052 1052 $ hg log -r 0 -T '{pad(rev, "1{"0"}")} {author|user}\n'
1053 1053 0 test
1054 1054 $ hg log -r 0 -T '{pad(rev, "not an int")}\n'
1055 1055 hg: parse error: pad() expects an integer width
1056 1056 [255]
1057 1057
1058 1058 Test invalid fillchar passed to pad function
1059 1059
1060 1060 $ hg log -r 0 -T '{pad(rev, 10, "")}\n'
1061 1061 hg: parse error: pad() expects a single fill character
1062 1062 [255]
1063 1063 $ hg log -r 0 -T '{pad(rev, 10, "--")}\n'
1064 1064 hg: parse error: pad() expects a single fill character
1065 1065 [255]
1066 1066
1067 1067 Test boolean argument passed to pad function
1068 1068
1069 1069 no crash
1070 1070
1071 1071 $ hg log -r 0 -T '{pad(rev, 10, "-", "f{"oo"}")}\n'
1072 1072 ---------0
1073 1073
1074 1074 string/literal
1075 1075
1076 1076 $ hg log -r 0 -T '{pad(rev, 10, "-", "false")}\n'
1077 1077 ---------0
1078 1078 $ hg log -r 0 -T '{pad(rev, 10, "-", false)}\n'
1079 1079 0---------
1080 1080 $ hg log -r 0 -T '{pad(rev, 10, "-", "")}\n'
1081 1081 0---------
1082 1082
1083 1083 unknown keyword is evaluated to ''
1084 1084
1085 1085 $ hg log -r 0 -T '{pad(rev, 10, "-", unknownkeyword)}\n'
1086 1086 0---------
1087 1087
1088 1088 Test separate function
1089 1089
1090 1090 $ hg log -r 0 -T '{separate("-", "", "a", "b", "", "", "c", "")}\n'
1091 1091 a-b-c
1092 1092 $ hg log -r 0 -T '{separate(" ", "{rev}:{node|short}", author|user, branch)}\n'
1093 1093 0:f7769ec2ab97 test default
1094 1094 $ hg log -r 0 --color=always -T '{separate(" ", "a", label(red, "b"), "c", label(red, ""), "d")}\n'
1095 1095 a \x1b[0;31mb\x1b[0m c d (esc)
1096 1096
1097 1097 Test boolean expression/literal passed to if function
1098 1098
1099 1099 $ hg log -r 0 -T '{if(rev, "rev 0 is True")}\n'
1100 1100 rev 0 is True
1101 1101 $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n'
1102 1102 literal 0 is True as well
1103 1103 $ hg log -r 0 -T '{if(min(revset(r"0")), "0 of hybriditem is also True")}\n'
1104 1104 0 of hybriditem is also True
1105 1105 $ hg log -r 0 -T '{if("", "", "empty string is False")}\n'
1106 1106 empty string is False
1107 1107 $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n'
1108 1108 empty list is False
1109 1109 $ hg log -r 0 -T '{if(revset(r"0"), "non-empty list is True")}\n'
1110 1110 non-empty list is True
1111 1111 $ hg log -r 0 -T '{if(revset(r"0") % "", "list of empty strings is True")}\n'
1112 1112 list of empty strings is True
1113 1113 $ hg log -r 0 -T '{if(true, "true is True")}\n'
1114 1114 true is True
1115 1115 $ hg log -r 0 -T '{if(false, "", "false is False")}\n'
1116 1116 false is False
1117 1117 $ hg log -r 0 -T '{if("false", "non-empty string is True")}\n'
1118 1118 non-empty string is True
1119 1119
1120 1120 Test ifcontains function
1121 1121
1122 1122 $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n'
1123 1123 2 is in the string
1124 1124 1 is not
1125 1125 0 is in the string
1126 1126
1127 1127 $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n'
1128 1128 2 is in the string
1129 1129 1 is not
1130 1130 0 is in the string
1131 1131
1132 1132 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
1133 1133 2 did not add a
1134 1134 1 did not add a
1135 1135 0 added a
1136 1136
1137 1137 $ hg log --debug -T '{rev}{ifcontains(1, parents, " is parent of 1")}\n'
1138 1138 2 is parent of 1
1139 1139 1
1140 1140 0
1141 1141
1142 1142 $ hg log -l1 -T '{ifcontains("branch", extras, "t", "f")}\n'
1143 1143 t
1144 1144 $ hg log -l1 -T '{ifcontains("branch", extras % "{key}", "t", "f")}\n'
1145 1145 t
1146 1146 $ hg log -l1 -T '{ifcontains("branc", extras % "{key}", "t", "f")}\n'
1147 1147 f
1148 1148 $ hg log -l1 -T '{ifcontains("branc", stringify(extras % "{key}"), "t", "f")}\n'
1149 1149 t
1150 1150
1151 1151 Test revset function
1152 1152
1153 1153 $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n'
1154 1154 2 current rev
1155 1155 1 not current rev
1156 1156 0 not current rev
1157 1157
1158 1158 $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n'
1159 1159 2 match rev
1160 1160 1 match rev
1161 1161 0 not match rev
1162 1162
1163 1163 $ hg log -T '{ifcontains(desc, revset(":"), "", "type not match")}\n' -l1
1164 1164 type not match
1165 1165
1166 1166 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n'
1167 1167 2 Parents: 1
1168 1168 1 Parents: 0
1169 1169 0 Parents:
1170 1170
1171 1171 $ cat >> .hg/hgrc <<EOF
1172 1172 > [revsetalias]
1173 1173 > myparents(\$1) = parents(\$1)
1174 1174 > EOF
1175 1175 $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n'
1176 1176 2 Parents: 1
1177 1177 1 Parents: 0
1178 1178 0 Parents:
1179 1179
1180 1180 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
1181 1181 Rev: 2
1182 1182 Ancestor: 0
1183 1183 Ancestor: 1
1184 1184 Ancestor: 2
1185 1185
1186 1186 Rev: 1
1187 1187 Ancestor: 0
1188 1188 Ancestor: 1
1189 1189
1190 1190 Rev: 0
1191 1191 Ancestor: 0
1192 1192
1193 1193 $ hg log --template '{revset("TIP"|lower)}\n' -l1
1194 1194 2
1195 1195
1196 1196 $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1
1197 1197 2
1198 1198
1199 1199 a list template is evaluated for each item of revset/parents
1200 1200
1201 1201 $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n'
1202 1202 2 p: 1:bcc7ff960b8e
1203 1203 1 p: 0:f7769ec2ab97
1204 1204 0 p:
1205 1205
1206 1206 $ hg log --debug -T '{rev} p:{parents % " {rev}:{node|short}"}\n'
1207 1207 2 p: 1:bcc7ff960b8e -1:000000000000
1208 1208 1 p: 0:f7769ec2ab97 -1:000000000000
1209 1209 0 p: -1:000000000000 -1:000000000000
1210 1210
1211 1211 therefore, 'revcache' should be recreated for each rev
1212 1212
1213 1213 $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n'
1214 1214 2 aa b
1215 1215 p
1216 1216 1
1217 1217 p a
1218 1218 0 a
1219 1219 p
1220 1220
1221 1221 $ hg log --debug -T '{rev} {file_adds}\np {parents % "{file_adds}"}\n'
1222 1222 2 aa b
1223 1223 p
1224 1224 1
1225 1225 p a
1226 1226 0 a
1227 1227 p
1228 1228
1229 1229 a revset item must be evaluated as an integer revision, not an offset from tip
1230 1230
1231 1231 $ hg log -l 1 -T '{revset("null") % "{rev}:{node|short}"}\n'
1232 1232 -1:000000000000
1233 1233 $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n'
1234 1234 -1:000000000000
1235 1235
1236 1236 join() should pick '{rev}' from revset items:
1237 1237
1238 1238 $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6
1239 1239 4, 5
1240 1240
1241 1241 on the other hand, parents are formatted as '{rev}:{node|formatnode}' by
1242 1242 default. join() should agree with the default formatting:
1243 1243
1244 1244 $ hg log -R ../a -T '{join(parents, ", ")}\n' -r6
1245 1245 5:13207e5a10d9, 4:bbe44766e73d
1246 1246
1247 1247 $ hg log -R ../a -T '{join(parents, ",\n")}\n' -r6 --debug
1248 1248 5:13207e5a10d9fd28ec424934298e176197f2c67f,
1249 1249 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1250 1250
1251 1251 Invalid arguments passed to revset()
1252 1252
1253 1253 $ hg log -T '{revset("%whatever", 0)}\n'
1254 1254 hg: parse error: unexpected revspec format character w
1255 1255 [255]
1256 1256 $ hg log -T '{revset("%lwhatever", files)}\n'
1257 1257 hg: parse error: unexpected revspec format character w
1258 1258 [255]
1259 1259 $ hg log -T '{revset("%s %s", 0)}\n'
1260 1260 hg: parse error: missing argument for revspec
1261 1261 [255]
1262 1262 $ hg log -T '{revset("", 0)}\n'
1263 1263 hg: parse error: too many revspec arguments specified
1264 1264 [255]
1265 1265 $ hg log -T '{revset("%s", 0, 1)}\n'
1266 1266 hg: parse error: too many revspec arguments specified
1267 1267 [255]
1268 1268 $ hg log -T '{revset("%", 0)}\n'
1269 1269 hg: parse error: incomplete revspec format character
1270 1270 [255]
1271 1271 $ hg log -T '{revset("%l", 0)}\n'
1272 1272 hg: parse error: incomplete revspec format character
1273 1273 [255]
1274 1274 $ hg log -T '{revset("%d", 'foo')}\n'
1275 1275 hg: parse error: invalid argument for revspec
1276 1276 [255]
1277 1277 $ hg log -T '{revset("%ld", files)}\n'
1278 1278 hg: parse error: invalid argument for revspec
1279 1279 [255]
1280 1280 $ hg log -T '{revset("%ls", 0)}\n'
1281 1281 hg: parse error: invalid argument for revspec
1282 1282 [255]
1283 1283 $ hg log -T '{revset("%b", 'foo')}\n'
1284 1284 hg: parse error: invalid argument for revspec
1285 1285 [255]
1286 1286 $ hg log -T '{revset("%lb", files)}\n'
1287 1287 hg: parse error: invalid argument for revspec
1288 1288 [255]
1289 1289 $ hg log -T '{revset("%r", 0)}\n'
1290 1290 hg: parse error: invalid argument for revspec
1291 1291 [255]
1292 1292
1293 1293 Test files function
1294 1294
1295 1295 $ hg log -T "{rev}\n{join(files('*'), '\n')}\n"
1296 1296 2
1297 1297 a
1298 1298 aa
1299 1299 b
1300 1300 1
1301 1301 a
1302 1302 0
1303 1303 a
1304 1304
1305 1305 $ hg log -T "{rev}\n{join(files('aa'), '\n')}\n"
1306 1306 2
1307 1307 aa
1308 1308 1
1309 1309
1310 1310 0
1311 1311
1312 1312
1313 1313 $ hg log -l1 -T "{files('aa') % '{file}\n'}"
1314 1314 aa
1315 1315 $ hg log -l1 -T "{files('aa') % '{path}\n'}"
1316 1316 aa
1317 1317
1318 1318 $ hg rm a
1319 1319 $ hg log -r "wdir()" -T "{rev}\n{join(files('*'), '\n')}\n"
1320 1320 2147483647
1321 1321 aa
1322 1322 b
1323 1323 $ hg revert a
1324 1324
1325 1325 Test relpath function
1326 1326
1327 1327 $ hg log -r0 -T '{files % "{file|relpath}\n"}'
1328 1328 a
1329 1329 $ cd ..
1330 1330 $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}'
1331 1331 r/a
1332 1332
1333 1333 Test stringify on sub expressions
1334 1334
1335 1335 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
1336 1336 fourth, second, third
1337 1337 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
1338 1338 abc
1339 1339
1340 1340 Test splitlines
1341 1341
1342 1342 $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}"
1343 1343 @ foo Modify, add, remove, rename
1344 1344 |
1345 1345 o foo future
1346 1346 |
1347 1347 o foo third
1348 1348 |
1349 1349 o foo second
1350 1350
1351 1351 o foo merge
1352 1352 |\
1353 1353 | o foo new head
1354 1354 | |
1355 1355 o | foo new branch
1356 1356 |/
1357 1357 o foo no user, no domain
1358 1358 |
1359 1359 o foo no person
1360 1360 |
1361 1361 o foo other 1
1362 1362 | foo other 2
1363 1363 | foo
1364 1364 | foo other 3
1365 1365 o foo line 1
1366 1366 foo line 2
1367 1367
1368 1368 $ hg log -R a -r0 -T '{desc|splitlines}\n'
1369 1369 line 1 line 2
1370 1370 $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n'
1371 1371 line 1|line 2
1372 1372
1373 1373 Test startswith
1374 1374 $ hg log -Gv -R a --template "{startswith(desc)}"
1375 1375 hg: parse error: startswith expects two arguments
1376 1376 [255]
1377 1377
1378 1378 $ hg log -Gv -R a --template "{startswith('line', desc)}"
1379 1379 @
1380 1380 |
1381 1381 o
1382 1382 |
1383 1383 o
1384 1384 |
1385 1385 o
1386 1386
1387 1387 o
1388 1388 |\
1389 1389 | o
1390 1390 | |
1391 1391 o |
1392 1392 |/
1393 1393 o
1394 1394 |
1395 1395 o
1396 1396 |
1397 1397 o
1398 1398 |
1399 1399 o line 1
1400 1400 line 2
1401 1401
1402 1402 Test word function (including index out of bounds graceful failure)
1403 1403
1404 1404 $ hg log -Gv -R a --template "{word('1', desc)}"
1405 1405 @ add,
1406 1406 |
1407 1407 o
1408 1408 |
1409 1409 o
1410 1410 |
1411 1411 o
1412 1412
1413 1413 o
1414 1414 |\
1415 1415 | o head
1416 1416 | |
1417 1417 o | branch
1418 1418 |/
1419 1419 o user,
1420 1420 |
1421 1421 o person
1422 1422 |
1423 1423 o 1
1424 1424 |
1425 1425 o 1
1426 1426
1427 1427
1428 1428 Test word third parameter used as splitter
1429 1429
1430 1430 $ hg log -Gv -R a --template "{word('0', desc, 'o')}"
1431 1431 @ M
1432 1432 |
1433 1433 o future
1434 1434 |
1435 1435 o third
1436 1436 |
1437 1437 o sec
1438 1438
1439 1439 o merge
1440 1440 |\
1441 1441 | o new head
1442 1442 | |
1443 1443 o | new branch
1444 1444 |/
1445 1445 o n
1446 1446 |
1447 1447 o n
1448 1448 |
1449 1449 o
1450 1450 |
1451 1451 o line 1
1452 1452 line 2
1453 1453
1454 1454 Test word error messages for not enough and too many arguments
1455 1455
1456 1456 $ hg log -Gv -R a --template "{word('0')}"
1457 1457 hg: parse error: word expects two or three arguments, got 1
1458 1458 [255]
1459 1459
1460 1460 $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}"
1461 1461 hg: parse error: word expects two or three arguments, got 7
1462 1462 [255]
1463 1463
1464 1464 Test word for integer literal
1465 1465
1466 1466 $ hg log -R a --template "{word(2, desc)}\n" -r0
1467 1467 line
1468 1468
1469 1469 Test word for invalid numbers
1470 1470
1471 1471 $ hg log -Gv -R a --template "{word('a', desc)}"
1472 1472 hg: parse error: word expects an integer index
1473 1473 [255]
1474 1474
1475 1475 Test word for out of range
1476 1476
1477 1477 $ hg log -R a --template "{word(10000, desc)}"
1478 1478 $ hg log -R a --template "{word(-10000, desc)}"
1479 1479
1480 1480 Test indent and not adding to empty lines
1481 1481
1482 1482 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
1483 1483 -----
1484 1484 > line 1
1485 1485 >> line 2
1486 1486 -----
1487 1487 > other 1
1488 1488 >> other 2
1489 1489
1490 1490 >> other 3
1491 1491
1492 1492 Test with non-strings like dates
1493 1493
1494 1494 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a
1495 1495 1200000.00
1496 1496 1300000.00
1497 1497
1498 1498 Test cbor filter:
1499 1499
1500 1500 $ cat <<'EOF' > "$TESTTMP/decodecbor.py"
1501 1501 > from __future__ import absolute_import
1502 > from mercurial import pycompat
1502 > from mercurial import (
1503 > dispatch,
1504 > pycompat,
1505 > )
1503 1506 > from mercurial.utils import (
1504 1507 > cborutil,
1505 1508 > stringutil,
1506 1509 > )
1510 > dispatch.initstdio()
1507 1511 > items = cborutil.decodeall(pycompat.stdin.read())
1508 1512 > pycompat.stdout.write(stringutil.pprint(items, indent=1) + b'\n')
1509 1513 > EOF
1510 1514
1511 1515 $ hg log -T "{rev|cbor}" -R a -l2 | "$PYTHON" "$TESTTMP/decodecbor.py"
1512 1516 [
1513 1517 10,
1514 1518 9
1515 1519 ]
1516 1520
1517 1521 $ hg log -T "{extras|cbor}" -R a -l1 | "$PYTHON" "$TESTTMP/decodecbor.py"
1518 1522 [
1519 1523 {
1520 1524 'branch': 'default'
1521 1525 }
1522 1526 ]
1523 1527
1524 1528 json filter should escape HTML tags so that the output can be embedded in hgweb:
1525 1529
1526 1530 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
1527 1531 "\u003cfoo@example.org\u003e"
1528 1532
1529 1533 Set up repository for non-ascii encoding tests:
1530 1534
1531 1535 $ hg init nonascii
1532 1536 $ cd nonascii
1533 1537 $ "$PYTHON" <<EOF
1534 1538 > open('latin1', 'wb').write(b'\xe9')
1535 1539 > open('utf-8', 'wb').write(b'\xc3\xa9')
1536 1540 > EOF
1537 1541 $ HGENCODING=utf-8 hg branch -q `cat utf-8`
1538 1542 $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8
1539 1543
1540 1544 json filter should try round-trip conversion to utf-8:
1541 1545
1542 1546 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
1543 1547 "\u00e9"
1544 1548 $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0
1545 1549 "non-ascii branch: \u00e9"
1546 1550
1547 1551 json filter should take input as utf-8 if it was converted from utf-8:
1548 1552
1549 1553 $ HGENCODING=latin-1 hg log -T "{branch|json}\n" -r0
1550 1554 "\u00e9"
1551 1555 $ HGENCODING=latin-1 hg log -T "{desc|json}\n" -r0
1552 1556 "non-ascii branch: \u00e9"
1553 1557
1554 1558 json filter takes input as utf-8b:
1555 1559
1556 1560 $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1
1557 1561 "\u00e9"
1558 1562 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
1559 1563 "\udce9"
1560 1564
1561 1565 utf8 filter:
1562 1566
1563 1567 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
1564 1568 round-trip: c3a9
1565 1569 $ HGENCODING=latin1 hg log -T "decoded: {'`cat latin1`'|utf8|hex}\n" -l1
1566 1570 decoded: c3a9
1567 1571 $ HGENCODING=ascii hg log -T "replaced: {'`cat latin1`'|utf8|hex}\n" -l1
1568 1572 abort: decoding near * (glob)
1569 1573 [255]
1570 1574 $ hg log -T "coerced to string: {rev|utf8}\n" -r0
1571 1575 coerced to string: 0
1572 1576
1573 1577 pad width:
1574 1578
1575 1579 $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
1576 1580 \xc3\xa9- (esc)
1577 1581
1578 1582 read config options:
1579 1583
1580 1584 $ hg log -T "{config('templateconfig', 'knob', 'foo')}\n"
1581 1585 foo
1582 1586 $ hg log -T "{config('templateconfig', 'knob', 'foo')}\n" \
1583 1587 > --config templateconfig.knob=bar
1584 1588 bar
1585 1589 $ hg log -T "{configbool('templateconfig', 'knob', True)}\n"
1586 1590 True
1587 1591 $ hg log -T "{configbool('templateconfig', 'knob', True)}\n" \
1588 1592 > --config templateconfig.knob=0
1589 1593 False
1590 1594 $ hg log -T "{configint('templateconfig', 'knob', 123)}\n"
1591 1595 123
1592 1596 $ hg log -T "{configint('templateconfig', 'knob', 123)}\n" \
1593 1597 > --config templateconfig.knob=456
1594 1598 456
1595 1599 $ hg log -T "{config('templateconfig', 'knob')}\n"
1596 1600 devel-warn: config item requires an explicit default value: 'templateconfig.knob' at: * (glob)
1597 1601
1598 1602 $ hg log -T "{configbool('ui', 'interactive')}\n"
1599 1603 False
1600 1604 $ hg log -T "{configbool('ui', 'interactive')}\n" --config ui.interactive=1
1601 1605 True
1602 1606 $ hg log -T "{config('templateconfig', 'knob', if(true, 'foo', 'bar'))}\n"
1603 1607 foo
1604 1608
1605 1609 $ cd ..
@@ -1,1824 +1,1828
1 1 Test template map files and styles
2 2 ==================================
3 3
4 4 $ hg init a
5 5 $ cd a
6 6 $ echo a > a
7 7 $ hg add a
8 8 $ echo line 1 > b
9 9 $ echo line 2 >> b
10 10 $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>'
11 11
12 12 $ hg add b
13 13 $ echo other 1 > c
14 14 $ echo other 2 >> c
15 15 $ echo >> c
16 16 $ echo other 3 >> c
17 17 $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>'
18 18
19 19 $ hg add c
20 20 $ hg commit -m 'no person' -d '1200000 0' -u 'other@place'
21 21 $ echo c >> c
22 22 $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person'
23 23
24 24 $ echo foo > .hg/branch
25 25 $ hg commit -m 'new branch' -d '1400000 0' -u 'person'
26 26
27 27 $ hg co -q 3
28 28 $ echo other 4 >> d
29 29 $ hg add d
30 30 $ hg commit -m 'new head' -d '1500000 0' -u 'person'
31 31
32 32 $ hg merge -q foo
33 33 $ hg commit -m 'merge' -d '1500001 0' -u 'person'
34 34
35 35 Second branch starting at nullrev:
36 36
37 37 $ hg update null
38 38 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
39 39 $ echo second > second
40 40 $ hg add second
41 41 $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
42 42 created new head
43 43
44 44 $ echo third > third
45 45 $ hg add third
46 46 $ hg mv second fourth
47 47 $ hg commit -m third -d "2020-01-01 10:01"
48 48
49 49 Make sure user/global hgrc does not affect tests
50 50
51 51 $ echo '[ui]' > .hg/hgrc
52 52 $ echo 'logtemplate =' >> .hg/hgrc
53 53 $ echo 'style =' >> .hg/hgrc
54 54
55 55 Add some simple styles to settings
56 56
57 57 $ cat <<'EOF' >> .hg/hgrc
58 58 > [templates]
59 59 > simple = "{rev}\n"
60 60 > simple2 = {rev}\n
61 61 > rev = "should not precede {rev} keyword\n"
62 62 > EOF
63 63
64 64 $ hg log -l1 -Tsimple
65 65 8
66 66 $ hg log -l1 -Tsimple2
67 67 8
68 68 $ hg log -l1 -Trev
69 69 should not precede 8 keyword
70 70 $ hg log -l1 -T '{simple}'
71 71 8
72 72
73 73 Map file shouldn't see user templates:
74 74
75 75 $ cat <<EOF > tmpl
76 76 > changeset = 'nothing expanded:{simple}\n'
77 77 > EOF
78 78 $ hg log -l1 --style ./tmpl
79 79 nothing expanded:
80 80
81 81 Test templates and style maps in files:
82 82
83 83 $ echo "{rev}" > tmpl
84 84 $ hg log -l1 -T./tmpl
85 85 8
86 86 $ hg log -l1 -Tblah/blah
87 87 blah/blah (no-eol)
88 88
89 89 $ printf 'changeset = "{rev}\\n"\n' > map-simple
90 90 $ hg log -l1 -T./map-simple
91 91 8
92 92
93 93 a map file may have [templates] and [templatealias] sections:
94 94
95 95 $ cat <<'EOF' > map-simple
96 96 > [templates]
97 97 > changeset = "{a}\n"
98 98 > [templatealias]
99 99 > a = rev
100 100 > EOF
101 101 $ hg log -l1 -T./map-simple
102 102 8
103 103
104 104 so it can be included in hgrc
105 105
106 106 $ cat <<EOF > myhgrc
107 107 > %include $HGRCPATH
108 108 > %include map-simple
109 109 > [templates]
110 110 > foo = "{changeset}"
111 111 > EOF
112 112 $ HGRCPATH=./myhgrc hg log -l1 -Tfoo
113 113 8
114 114 $ HGRCPATH=./myhgrc hg log -l1 -T'{a}\n'
115 115 8
116 116
117 117 Test template map inheritance
118 118
119 119 $ echo "__base__ = map-cmdline.default" > map-simple
120 120 $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple
121 121 $ hg log -l1 -T./map-simple
122 122 changeset: ***8***
123 123 tag: tip
124 124 user: test
125 125 date: Wed Jan 01 10:01:00 2020 +0000
126 126 summary: third
127 127
128 128
129 129 Test docheader, docfooter and separator in template map
130 130
131 131 $ cat <<'EOF' > map-myjson
132 132 > docheader = '\{\n'
133 133 > docfooter = '\n}\n'
134 134 > separator = ',\n'
135 135 > changeset = ' {dict(rev, node|short)|json}'
136 136 > EOF
137 137 $ hg log -l2 -T./map-myjson
138 138 {
139 139 {"node": "95c24699272e", "rev": 8},
140 140 {"node": "29114dbae42b", "rev": 7}
141 141 }
142 142
143 143 Test docheader, docfooter and separator in [templates] section
144 144
145 145 $ cat <<'EOF' >> .hg/hgrc
146 146 > [templates]
147 147 > myjson = ' {dict(rev, node|short)|json}'
148 148 > myjson:docheader = '\{\n'
149 149 > myjson:docfooter = '\n}\n'
150 150 > myjson:separator = ',\n'
151 151 > :docheader = 'should not be selected as a docheader for literal templates\n'
152 152 > EOF
153 153 $ hg log -l2 -Tmyjson
154 154 {
155 155 {"node": "95c24699272e", "rev": 8},
156 156 {"node": "29114dbae42b", "rev": 7}
157 157 }
158 158 $ hg log -l1 -T'{rev}\n'
159 159 8
160 160
161 161 Template should precede style option
162 162
163 163 $ hg log -l1 --style default -T '{rev}\n'
164 164 8
165 165
166 166 Add a commit with empty description, to ensure that the templates
167 167 below will omit the description line.
168 168
169 169 $ echo c >> c
170 170 $ hg add c
171 171 $ hg commit -qm ' '
172 172
173 173 Default style is like normal output. Phases style should be the same
174 174 as default style, except for extra phase lines.
175 175
176 176 $ hg log > log.out
177 177 $ hg log --style default > style.out
178 178 $ cmp log.out style.out || diff -u log.out style.out
179 179 $ hg log -T phases > phases.out
180 180 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
181 181 +phase: draft
182 182 +phase: draft
183 183 +phase: draft
184 184 +phase: draft
185 185 +phase: draft
186 186 +phase: draft
187 187 +phase: draft
188 188 +phase: draft
189 189 +phase: draft
190 190 +phase: draft
191 191
192 192 $ hg log -v > log.out
193 193 $ hg log -v --style default > style.out
194 194 $ cmp log.out style.out || diff -u log.out style.out
195 195 $ hg log -v -T phases > phases.out
196 196 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
197 197 +phase: draft
198 198 +phase: draft
199 199 +phase: draft
200 200 +phase: draft
201 201 +phase: draft
202 202 +phase: draft
203 203 +phase: draft
204 204 +phase: draft
205 205 +phase: draft
206 206 +phase: draft
207 207
208 208 $ hg log -q > log.out
209 209 $ hg log -q --style default > style.out
210 210 $ cmp log.out style.out || diff -u log.out style.out
211 211 $ hg log -q -T phases > phases.out
212 212 $ cmp log.out phases.out || diff -u log.out phases.out
213 213
214 214 $ hg log --debug > log.out
215 215 $ hg log --debug --style default > style.out
216 216 $ cmp log.out style.out || diff -u log.out style.out
217 217 $ hg log --debug -T phases > phases.out
218 218 $ cmp log.out phases.out || diff -u log.out phases.out
219 219
220 220 Default style of working-directory revision should also be the same (but
221 221 date may change while running tests):
222 222
223 223 $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out
224 224 $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out
225 225 $ cmp log.out style.out || diff -u log.out style.out
226 226
227 227 $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out
228 228 $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out
229 229 $ cmp log.out style.out || diff -u log.out style.out
230 230
231 231 $ hg log -r 'wdir()' -q > log.out
232 232 $ hg log -r 'wdir()' -q --style default > style.out
233 233 $ cmp log.out style.out || diff -u log.out style.out
234 234
235 235 $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out
236 236 $ hg log -r 'wdir()' --debug --style default \
237 237 > | sed 's|^date:.*|date:|' > style.out
238 238 $ cmp log.out style.out || diff -u log.out style.out
239 239
240 240 Default style should also preserve color information (issue2866):
241 241
242 242 $ cp $HGRCPATH $HGRCPATH-bak
243 243 $ cat <<EOF >> $HGRCPATH
244 244 > [extensions]
245 245 > color=
246 246 > EOF
247 247
248 248 $ hg --color=debug log > log.out
249 249 $ hg --color=debug log --style default > style.out
250 250 $ cmp log.out style.out || diff -u log.out style.out
251 251 $ hg --color=debug log -T phases > phases.out
252 252 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
253 253 +[log.phase|phase: draft]
254 254 +[log.phase|phase: draft]
255 255 +[log.phase|phase: draft]
256 256 +[log.phase|phase: draft]
257 257 +[log.phase|phase: draft]
258 258 +[log.phase|phase: draft]
259 259 +[log.phase|phase: draft]
260 260 +[log.phase|phase: draft]
261 261 +[log.phase|phase: draft]
262 262 +[log.phase|phase: draft]
263 263
264 264 $ hg --color=debug -v log > log.out
265 265 $ hg --color=debug -v log --style default > style.out
266 266 $ cmp log.out style.out || diff -u log.out style.out
267 267 $ hg --color=debug -v log -T phases > phases.out
268 268 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
269 269 +[log.phase|phase: draft]
270 270 +[log.phase|phase: draft]
271 271 +[log.phase|phase: draft]
272 272 +[log.phase|phase: draft]
273 273 +[log.phase|phase: draft]
274 274 +[log.phase|phase: draft]
275 275 +[log.phase|phase: draft]
276 276 +[log.phase|phase: draft]
277 277 +[log.phase|phase: draft]
278 278 +[log.phase|phase: draft]
279 279
280 280 $ hg --color=debug -q log > log.out
281 281 $ hg --color=debug -q log --style default > style.out
282 282 $ cmp log.out style.out || diff -u log.out style.out
283 283 $ hg --color=debug -q log -T phases > phases.out
284 284 $ cmp log.out phases.out || diff -u log.out phases.out
285 285
286 286 $ hg --color=debug --debug log > log.out
287 287 $ hg --color=debug --debug log --style default > style.out
288 288 $ cmp log.out style.out || diff -u log.out style.out
289 289 $ hg --color=debug --debug log -T phases > phases.out
290 290 $ cmp log.out phases.out || diff -u log.out phases.out
291 291
292 292 $ mv $HGRCPATH-bak $HGRCPATH
293 293
294 294 Remove commit with empty commit message, so as to not pollute further
295 295 tests.
296 296
297 297 $ hg --config extensions.strip= strip -q .
298 298
299 299 Revision with no copies (used to print a traceback):
300 300
301 301 $ hg tip -v --template '\n'
302 302
303 303
304 304 Compact style works:
305 305
306 306 $ hg log -Tcompact
307 307 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
308 308 third
309 309
310 310 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user
311 311 second
312 312
313 313 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
314 314 merge
315 315
316 316 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
317 317 new head
318 318
319 319 4 bbe44766e73d 1970-01-17 04:53 +0000 person
320 320 new branch
321 321
322 322 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
323 323 no user, no domain
324 324
325 325 2 97054abb4ab8 1970-01-14 21:20 +0000 other
326 326 no person
327 327
328 328 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other
329 329 other 1
330 330
331 331 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user
332 332 line 1
333 333
334 334
335 335 $ hg log -v --style compact
336 336 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
337 337 third
338 338
339 339 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
340 340 second
341 341
342 342 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
343 343 merge
344 344
345 345 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
346 346 new head
347 347
348 348 4 bbe44766e73d 1970-01-17 04:53 +0000 person
349 349 new branch
350 350
351 351 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
352 352 no user, no domain
353 353
354 354 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place
355 355 no person
356 356
357 357 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
358 358 other 1
359 359 other 2
360 360
361 361 other 3
362 362
363 363 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
364 364 line 1
365 365 line 2
366 366
367 367
368 368 $ hg log --debug --style compact
369 369 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test
370 370 third
371 371
372 372 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
373 373 second
374 374
375 375 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
376 376 merge
377 377
378 378 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person
379 379 new head
380 380
381 381 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person
382 382 new branch
383 383
384 384 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person
385 385 no user, no domain
386 386
387 387 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place
388 388 no person
389 389
390 390 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
391 391 other 1
392 392 other 2
393 393
394 394 other 3
395 395
396 396 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
397 397 line 1
398 398 line 2
399 399
400 400
401 401 Test xml styles:
402 402
403 403 $ hg log --style xml -r 'not all()'
404 404 <?xml version="1.0"?>
405 405 <log>
406 406 </log>
407 407
408 408 $ hg log --style xml
409 409 <?xml version="1.0"?>
410 410 <log>
411 411 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
412 412 <tag>tip</tag>
413 413 <author email="test">test</author>
414 414 <date>2020-01-01T10:01:00+00:00</date>
415 415 <msg xml:space="preserve">third</msg>
416 416 </logentry>
417 417 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
418 418 <parent revision="-1" node="0000000000000000000000000000000000000000" />
419 419 <author email="user@hostname">User Name</author>
420 420 <date>1970-01-12T13:46:40+00:00</date>
421 421 <msg xml:space="preserve">second</msg>
422 422 </logentry>
423 423 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
424 424 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
425 425 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
426 426 <author email="person">person</author>
427 427 <date>1970-01-18T08:40:01+00:00</date>
428 428 <msg xml:space="preserve">merge</msg>
429 429 </logentry>
430 430 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
431 431 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
432 432 <author email="person">person</author>
433 433 <date>1970-01-18T08:40:00+00:00</date>
434 434 <msg xml:space="preserve">new head</msg>
435 435 </logentry>
436 436 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
437 437 <branch>foo</branch>
438 438 <author email="person">person</author>
439 439 <date>1970-01-17T04:53:20+00:00</date>
440 440 <msg xml:space="preserve">new branch</msg>
441 441 </logentry>
442 442 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
443 443 <author email="person">person</author>
444 444 <date>1970-01-16T01:06:40+00:00</date>
445 445 <msg xml:space="preserve">no user, no domain</msg>
446 446 </logentry>
447 447 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
448 448 <author email="other@place">other</author>
449 449 <date>1970-01-14T21:20:00+00:00</date>
450 450 <msg xml:space="preserve">no person</msg>
451 451 </logentry>
452 452 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
453 453 <author email="other@place">A. N. Other</author>
454 454 <date>1970-01-13T17:33:20+00:00</date>
455 455 <msg xml:space="preserve">other 1
456 456 other 2
457 457
458 458 other 3</msg>
459 459 </logentry>
460 460 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
461 461 <author email="user@hostname">User Name</author>
462 462 <date>1970-01-12T13:46:40+00:00</date>
463 463 <msg xml:space="preserve">line 1
464 464 line 2</msg>
465 465 </logentry>
466 466 </log>
467 467
468 468 $ hg log -v --style xml
469 469 <?xml version="1.0"?>
470 470 <log>
471 471 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
472 472 <tag>tip</tag>
473 473 <author email="test">test</author>
474 474 <date>2020-01-01T10:01:00+00:00</date>
475 475 <msg xml:space="preserve">third</msg>
476 476 <paths>
477 477 <path action="A">fourth</path>
478 478 <path action="A">third</path>
479 479 <path action="R">second</path>
480 480 </paths>
481 481 <copies>
482 482 <copy source="second">fourth</copy>
483 483 </copies>
484 484 </logentry>
485 485 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
486 486 <parent revision="-1" node="0000000000000000000000000000000000000000" />
487 487 <author email="user@hostname">User Name</author>
488 488 <date>1970-01-12T13:46:40+00:00</date>
489 489 <msg xml:space="preserve">second</msg>
490 490 <paths>
491 491 <path action="A">second</path>
492 492 </paths>
493 493 </logentry>
494 494 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
495 495 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
496 496 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
497 497 <author email="person">person</author>
498 498 <date>1970-01-18T08:40:01+00:00</date>
499 499 <msg xml:space="preserve">merge</msg>
500 500 <paths>
501 501 </paths>
502 502 </logentry>
503 503 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
504 504 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
505 505 <author email="person">person</author>
506 506 <date>1970-01-18T08:40:00+00:00</date>
507 507 <msg xml:space="preserve">new head</msg>
508 508 <paths>
509 509 <path action="A">d</path>
510 510 </paths>
511 511 </logentry>
512 512 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
513 513 <branch>foo</branch>
514 514 <author email="person">person</author>
515 515 <date>1970-01-17T04:53:20+00:00</date>
516 516 <msg xml:space="preserve">new branch</msg>
517 517 <paths>
518 518 </paths>
519 519 </logentry>
520 520 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
521 521 <author email="person">person</author>
522 522 <date>1970-01-16T01:06:40+00:00</date>
523 523 <msg xml:space="preserve">no user, no domain</msg>
524 524 <paths>
525 525 <path action="M">c</path>
526 526 </paths>
527 527 </logentry>
528 528 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
529 529 <author email="other@place">other</author>
530 530 <date>1970-01-14T21:20:00+00:00</date>
531 531 <msg xml:space="preserve">no person</msg>
532 532 <paths>
533 533 <path action="A">c</path>
534 534 </paths>
535 535 </logentry>
536 536 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
537 537 <author email="other@place">A. N. Other</author>
538 538 <date>1970-01-13T17:33:20+00:00</date>
539 539 <msg xml:space="preserve">other 1
540 540 other 2
541 541
542 542 other 3</msg>
543 543 <paths>
544 544 <path action="A">b</path>
545 545 </paths>
546 546 </logentry>
547 547 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
548 548 <author email="user@hostname">User Name</author>
549 549 <date>1970-01-12T13:46:40+00:00</date>
550 550 <msg xml:space="preserve">line 1
551 551 line 2</msg>
552 552 <paths>
553 553 <path action="A">a</path>
554 554 </paths>
555 555 </logentry>
556 556 </log>
557 557
558 558 $ hg log --debug --style xml
559 559 <?xml version="1.0"?>
560 560 <log>
561 561 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
562 562 <tag>tip</tag>
563 563 <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" />
564 564 <parent revision="-1" node="0000000000000000000000000000000000000000" />
565 565 <author email="test">test</author>
566 566 <date>2020-01-01T10:01:00+00:00</date>
567 567 <msg xml:space="preserve">third</msg>
568 568 <paths>
569 569 <path action="A">fourth</path>
570 570 <path action="A">third</path>
571 571 <path action="R">second</path>
572 572 </paths>
573 573 <copies>
574 574 <copy source="second">fourth</copy>
575 575 </copies>
576 576 <extra key="branch">default</extra>
577 577 </logentry>
578 578 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
579 579 <parent revision="-1" node="0000000000000000000000000000000000000000" />
580 580 <parent revision="-1" node="0000000000000000000000000000000000000000" />
581 581 <author email="user@hostname">User Name</author>
582 582 <date>1970-01-12T13:46:40+00:00</date>
583 583 <msg xml:space="preserve">second</msg>
584 584 <paths>
585 585 <path action="A">second</path>
586 586 </paths>
587 587 <extra key="branch">default</extra>
588 588 </logentry>
589 589 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
590 590 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
591 591 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
592 592 <author email="person">person</author>
593 593 <date>1970-01-18T08:40:01+00:00</date>
594 594 <msg xml:space="preserve">merge</msg>
595 595 <paths>
596 596 </paths>
597 597 <extra key="branch">default</extra>
598 598 </logentry>
599 599 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
600 600 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
601 601 <parent revision="-1" node="0000000000000000000000000000000000000000" />
602 602 <author email="person">person</author>
603 603 <date>1970-01-18T08:40:00+00:00</date>
604 604 <msg xml:space="preserve">new head</msg>
605 605 <paths>
606 606 <path action="A">d</path>
607 607 </paths>
608 608 <extra key="branch">default</extra>
609 609 </logentry>
610 610 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
611 611 <branch>foo</branch>
612 612 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
613 613 <parent revision="-1" node="0000000000000000000000000000000000000000" />
614 614 <author email="person">person</author>
615 615 <date>1970-01-17T04:53:20+00:00</date>
616 616 <msg xml:space="preserve">new branch</msg>
617 617 <paths>
618 618 </paths>
619 619 <extra key="branch">foo</extra>
620 620 </logentry>
621 621 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
622 622 <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" />
623 623 <parent revision="-1" node="0000000000000000000000000000000000000000" />
624 624 <author email="person">person</author>
625 625 <date>1970-01-16T01:06:40+00:00</date>
626 626 <msg xml:space="preserve">no user, no domain</msg>
627 627 <paths>
628 628 <path action="M">c</path>
629 629 </paths>
630 630 <extra key="branch">default</extra>
631 631 </logentry>
632 632 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
633 633 <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" />
634 634 <parent revision="-1" node="0000000000000000000000000000000000000000" />
635 635 <author email="other@place">other</author>
636 636 <date>1970-01-14T21:20:00+00:00</date>
637 637 <msg xml:space="preserve">no person</msg>
638 638 <paths>
639 639 <path action="A">c</path>
640 640 </paths>
641 641 <extra key="branch">default</extra>
642 642 </logentry>
643 643 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
644 644 <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" />
645 645 <parent revision="-1" node="0000000000000000000000000000000000000000" />
646 646 <author email="other@place">A. N. Other</author>
647 647 <date>1970-01-13T17:33:20+00:00</date>
648 648 <msg xml:space="preserve">other 1
649 649 other 2
650 650
651 651 other 3</msg>
652 652 <paths>
653 653 <path action="A">b</path>
654 654 </paths>
655 655 <extra key="branch">default</extra>
656 656 </logentry>
657 657 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
658 658 <parent revision="-1" node="0000000000000000000000000000000000000000" />
659 659 <parent revision="-1" node="0000000000000000000000000000000000000000" />
660 660 <author email="user@hostname">User Name</author>
661 661 <date>1970-01-12T13:46:40+00:00</date>
662 662 <msg xml:space="preserve">line 1
663 663 line 2</msg>
664 664 <paths>
665 665 <path action="A">a</path>
666 666 </paths>
667 667 <extra key="branch">default</extra>
668 668 </logentry>
669 669 </log>
670 670
671 671
672 672 test CBOR style:
673 673
674 674 $ cat <<'EOF' > "$TESTTMP/decodecborarray.py"
675 675 > from __future__ import absolute_import
676 > from mercurial import pycompat
676 > from mercurial import (
677 > dispatch,
678 > pycompat,
679 > )
677 680 > from mercurial.utils import (
678 681 > cborutil,
679 682 > stringutil,
680 683 > )
684 > dispatch.initstdio()
681 685 > data = pycompat.stdin.read()
682 686 > # our CBOR decoder doesn't support parsing indefinite-length arrays,
683 687 > # but the log output is indefinite stream by nature.
684 688 > assert data[:1] == cborutil.BEGIN_INDEFINITE_ARRAY
685 689 > assert data[-1:] == cborutil.BREAK
686 690 > items = cborutil.decodeall(data[1:-1])
687 691 > pycompat.stdout.write(stringutil.pprint(items, indent=1) + b'\n')
688 692 > EOF
689 693
690 694 $ hg log -k nosuch -Tcbor | "$PYTHON" "$TESTTMP/decodecborarray.py"
691 695 []
692 696
693 697 $ hg log -qr0:1 -Tcbor | "$PYTHON" "$TESTTMP/decodecborarray.py"
694 698 [
695 699 {
696 700 'node': '1e4e1b8f71e05681d422154f5421e385fec3454f',
697 701 'rev': 0
698 702 },
699 703 {
700 704 'node': 'b608e9d1a3f0273ccf70fb85fd6866b3482bf965',
701 705 'rev': 1
702 706 }
703 707 ]
704 708
705 709 $ hg log -vpr . -Tcbor --stat | "$PYTHON" "$TESTTMP/decodecborarray.py"
706 710 [
707 711 {
708 712 'bookmarks': [],
709 713 'branch': 'default',
710 714 'date': [
711 715 1577872860,
712 716 0
713 717 ],
714 718 'desc': 'third',
715 719 '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',
716 720 'diffstat': ' fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n',
717 721 'files': [
718 722 'fourth',
719 723 'second',
720 724 'third'
721 725 ],
722 726 'node': '95c24699272ef57d062b8bccc32c878bf841784a',
723 727 'parents': [
724 728 '29114dbae42b9f078cf2714dbe3a86bba8ec7453'
725 729 ],
726 730 'phase': 'draft',
727 731 'rev': 8,
728 732 'tags': [
729 733 'tip'
730 734 ],
731 735 'user': 'test'
732 736 }
733 737 ]
734 738
735 739
736 740 Test JSON style:
737 741
738 742 $ hg log -k nosuch -Tjson
739 743 [
740 744 ]
741 745
742 746 $ hg log -qr . -Tjson
743 747 [
744 748 {
745 749 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
746 750 "rev": 8
747 751 }
748 752 ]
749 753
750 754 $ hg log -vpr . -Tjson --stat
751 755 [
752 756 {
753 757 "bookmarks": [],
754 758 "branch": "default",
755 759 "date": [1577872860, 0],
756 760 "desc": "third",
757 761 "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",
758 762 "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n",
759 763 "files": ["fourth", "second", "third"],
760 764 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
761 765 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
762 766 "phase": "draft",
763 767 "rev": 8,
764 768 "tags": ["tip"],
765 769 "user": "test"
766 770 }
767 771 ]
768 772
769 773 honor --git but not format-breaking diffopts
770 774 $ hg --config diff.noprefix=True log --git -vpr . -Tjson
771 775 [
772 776 {
773 777 "bookmarks": [],
774 778 "branch": "default",
775 779 "date": [1577872860, 0],
776 780 "desc": "third",
777 781 "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",
778 782 "files": ["fourth", "second", "third"],
779 783 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
780 784 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
781 785 "phase": "draft",
782 786 "rev": 8,
783 787 "tags": ["tip"],
784 788 "user": "test"
785 789 }
786 790 ]
787 791
788 792 $ hg log -T json
789 793 [
790 794 {
791 795 "bookmarks": [],
792 796 "branch": "default",
793 797 "date": [1577872860, 0],
794 798 "desc": "third",
795 799 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
796 800 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
797 801 "phase": "draft",
798 802 "rev": 8,
799 803 "tags": ["tip"],
800 804 "user": "test"
801 805 },
802 806 {
803 807 "bookmarks": [],
804 808 "branch": "default",
805 809 "date": [1000000, 0],
806 810 "desc": "second",
807 811 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
808 812 "parents": ["0000000000000000000000000000000000000000"],
809 813 "phase": "draft",
810 814 "rev": 7,
811 815 "tags": [],
812 816 "user": "User Name <user@hostname>"
813 817 },
814 818 {
815 819 "bookmarks": [],
816 820 "branch": "default",
817 821 "date": [1500001, 0],
818 822 "desc": "merge",
819 823 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
820 824 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
821 825 "phase": "draft",
822 826 "rev": 6,
823 827 "tags": [],
824 828 "user": "person"
825 829 },
826 830 {
827 831 "bookmarks": [],
828 832 "branch": "default",
829 833 "date": [1500000, 0],
830 834 "desc": "new head",
831 835 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
832 836 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
833 837 "phase": "draft",
834 838 "rev": 5,
835 839 "tags": [],
836 840 "user": "person"
837 841 },
838 842 {
839 843 "bookmarks": [],
840 844 "branch": "foo",
841 845 "date": [1400000, 0],
842 846 "desc": "new branch",
843 847 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
844 848 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
845 849 "phase": "draft",
846 850 "rev": 4,
847 851 "tags": [],
848 852 "user": "person"
849 853 },
850 854 {
851 855 "bookmarks": [],
852 856 "branch": "default",
853 857 "date": [1300000, 0],
854 858 "desc": "no user, no domain",
855 859 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
856 860 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
857 861 "phase": "draft",
858 862 "rev": 3,
859 863 "tags": [],
860 864 "user": "person"
861 865 },
862 866 {
863 867 "bookmarks": [],
864 868 "branch": "default",
865 869 "date": [1200000, 0],
866 870 "desc": "no person",
867 871 "node": "97054abb4ab824450e9164180baf491ae0078465",
868 872 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
869 873 "phase": "draft",
870 874 "rev": 2,
871 875 "tags": [],
872 876 "user": "other@place"
873 877 },
874 878 {
875 879 "bookmarks": [],
876 880 "branch": "default",
877 881 "date": [1100000, 0],
878 882 "desc": "other 1\nother 2\n\nother 3",
879 883 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
880 884 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
881 885 "phase": "draft",
882 886 "rev": 1,
883 887 "tags": [],
884 888 "user": "A. N. Other <other@place>"
885 889 },
886 890 {
887 891 "bookmarks": [],
888 892 "branch": "default",
889 893 "date": [1000000, 0],
890 894 "desc": "line 1\nline 2",
891 895 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
892 896 "parents": ["0000000000000000000000000000000000000000"],
893 897 "phase": "draft",
894 898 "rev": 0,
895 899 "tags": [],
896 900 "user": "User Name <user@hostname>"
897 901 }
898 902 ]
899 903
900 904 $ hg heads -v -Tjson
901 905 [
902 906 {
903 907 "bookmarks": [],
904 908 "branch": "default",
905 909 "date": [1577872860, 0],
906 910 "desc": "third",
907 911 "files": ["fourth", "second", "third"],
908 912 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
909 913 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
910 914 "phase": "draft",
911 915 "rev": 8,
912 916 "tags": ["tip"],
913 917 "user": "test"
914 918 },
915 919 {
916 920 "bookmarks": [],
917 921 "branch": "default",
918 922 "date": [1500001, 0],
919 923 "desc": "merge",
920 924 "files": [],
921 925 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
922 926 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
923 927 "phase": "draft",
924 928 "rev": 6,
925 929 "tags": [],
926 930 "user": "person"
927 931 },
928 932 {
929 933 "bookmarks": [],
930 934 "branch": "foo",
931 935 "date": [1400000, 0],
932 936 "desc": "new branch",
933 937 "files": [],
934 938 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
935 939 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
936 940 "phase": "draft",
937 941 "rev": 4,
938 942 "tags": [],
939 943 "user": "person"
940 944 }
941 945 ]
942 946
943 947 $ hg log --debug -Tjson
944 948 [
945 949 {
946 950 "added": ["fourth", "third"],
947 951 "bookmarks": [],
948 952 "branch": "default",
949 953 "date": [1577872860, 0],
950 954 "desc": "third",
951 955 "extra": {"branch": "default"},
952 956 "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64",
953 957 "modified": [],
954 958 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
955 959 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
956 960 "phase": "draft",
957 961 "removed": ["second"],
958 962 "rev": 8,
959 963 "tags": ["tip"],
960 964 "user": "test"
961 965 },
962 966 {
963 967 "added": ["second"],
964 968 "bookmarks": [],
965 969 "branch": "default",
966 970 "date": [1000000, 0],
967 971 "desc": "second",
968 972 "extra": {"branch": "default"},
969 973 "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf",
970 974 "modified": [],
971 975 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
972 976 "parents": ["0000000000000000000000000000000000000000"],
973 977 "phase": "draft",
974 978 "removed": [],
975 979 "rev": 7,
976 980 "tags": [],
977 981 "user": "User Name <user@hostname>"
978 982 },
979 983 {
980 984 "added": [],
981 985 "bookmarks": [],
982 986 "branch": "default",
983 987 "date": [1500001, 0],
984 988 "desc": "merge",
985 989 "extra": {"branch": "default"},
986 990 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
987 991 "modified": [],
988 992 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
989 993 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
990 994 "phase": "draft",
991 995 "removed": [],
992 996 "rev": 6,
993 997 "tags": [],
994 998 "user": "person"
995 999 },
996 1000 {
997 1001 "added": ["d"],
998 1002 "bookmarks": [],
999 1003 "branch": "default",
1000 1004 "date": [1500000, 0],
1001 1005 "desc": "new head",
1002 1006 "extra": {"branch": "default"},
1003 1007 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1004 1008 "modified": [],
1005 1009 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
1006 1010 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1007 1011 "phase": "draft",
1008 1012 "removed": [],
1009 1013 "rev": 5,
1010 1014 "tags": [],
1011 1015 "user": "person"
1012 1016 },
1013 1017 {
1014 1018 "added": [],
1015 1019 "bookmarks": [],
1016 1020 "branch": "foo",
1017 1021 "date": [1400000, 0],
1018 1022 "desc": "new branch",
1019 1023 "extra": {"branch": "foo"},
1020 1024 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1021 1025 "modified": [],
1022 1026 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1023 1027 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1024 1028 "phase": "draft",
1025 1029 "removed": [],
1026 1030 "rev": 4,
1027 1031 "tags": [],
1028 1032 "user": "person"
1029 1033 },
1030 1034 {
1031 1035 "added": [],
1032 1036 "bookmarks": [],
1033 1037 "branch": "default",
1034 1038 "date": [1300000, 0],
1035 1039 "desc": "no user, no domain",
1036 1040 "extra": {"branch": "default"},
1037 1041 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1038 1042 "modified": ["c"],
1039 1043 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
1040 1044 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
1041 1045 "phase": "draft",
1042 1046 "removed": [],
1043 1047 "rev": 3,
1044 1048 "tags": [],
1045 1049 "user": "person"
1046 1050 },
1047 1051 {
1048 1052 "added": ["c"],
1049 1053 "bookmarks": [],
1050 1054 "branch": "default",
1051 1055 "date": [1200000, 0],
1052 1056 "desc": "no person",
1053 1057 "extra": {"branch": "default"},
1054 1058 "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1",
1055 1059 "modified": [],
1056 1060 "node": "97054abb4ab824450e9164180baf491ae0078465",
1057 1061 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
1058 1062 "phase": "draft",
1059 1063 "removed": [],
1060 1064 "rev": 2,
1061 1065 "tags": [],
1062 1066 "user": "other@place"
1063 1067 },
1064 1068 {
1065 1069 "added": ["b"],
1066 1070 "bookmarks": [],
1067 1071 "branch": "default",
1068 1072 "date": [1100000, 0],
1069 1073 "desc": "other 1\nother 2\n\nother 3",
1070 1074 "extra": {"branch": "default"},
1071 1075 "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55",
1072 1076 "modified": [],
1073 1077 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
1074 1078 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
1075 1079 "phase": "draft",
1076 1080 "removed": [],
1077 1081 "rev": 1,
1078 1082 "tags": [],
1079 1083 "user": "A. N. Other <other@place>"
1080 1084 },
1081 1085 {
1082 1086 "added": ["a"],
1083 1087 "bookmarks": [],
1084 1088 "branch": "default",
1085 1089 "date": [1000000, 0],
1086 1090 "desc": "line 1\nline 2",
1087 1091 "extra": {"branch": "default"},
1088 1092 "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0",
1089 1093 "modified": [],
1090 1094 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1091 1095 "parents": ["0000000000000000000000000000000000000000"],
1092 1096 "phase": "draft",
1093 1097 "removed": [],
1094 1098 "rev": 0,
1095 1099 "tags": [],
1096 1100 "user": "User Name <user@hostname>"
1097 1101 }
1098 1102 ]
1099 1103
1100 1104 Error if style not readable:
1101 1105
1102 1106 #if unix-permissions no-root
1103 1107 $ touch q
1104 1108 $ chmod 0 q
1105 1109 $ hg log --style ./q
1106 1110 abort: Permission denied: './q'
1107 1111 [255]
1108 1112 #endif
1109 1113
1110 1114 Error if no style:
1111 1115
1112 1116 $ hg log --style notexist
1113 1117 abort: style 'notexist' not found
1114 1118 (available styles: bisect, changelog, compact, default, phases, show, status, xml)
1115 1119 [255]
1116 1120
1117 1121 $ hg log -T list
1118 1122 available styles: bisect, changelog, compact, default, phases, show, status, xml
1119 1123 abort: specify a template
1120 1124 [255]
1121 1125
1122 1126 Error if style missing key:
1123 1127
1124 1128 $ echo 'q = q' > t
1125 1129 $ hg log --style ./t
1126 1130 abort: "changeset" not in template map
1127 1131 [255]
1128 1132
1129 1133 Error if style missing value:
1130 1134
1131 1135 $ echo 'changeset =' > t
1132 1136 $ hg log --style t
1133 1137 hg: parse error at t:1: missing value
1134 1138 [255]
1135 1139
1136 1140 Error if include fails:
1137 1141
1138 1142 $ echo 'changeset = q' >> t
1139 1143 #if unix-permissions no-root
1140 1144 $ hg log --style ./t
1141 1145 abort: template file ./q: Permission denied
1142 1146 [255]
1143 1147 $ rm -f q
1144 1148 #endif
1145 1149
1146 1150 Include works:
1147 1151
1148 1152 $ echo '{rev}' > q
1149 1153 $ hg log --style ./t
1150 1154 8
1151 1155 7
1152 1156 6
1153 1157 5
1154 1158 4
1155 1159 3
1156 1160 2
1157 1161 1
1158 1162 0
1159 1163
1160 1164 $ hg phase -r 5 --public
1161 1165 $ hg phase -r 7 --secret --force
1162 1166
1163 1167 Missing non-standard names give no error (backward compatibility):
1164 1168
1165 1169 $ echo "changeset = '{c}'" > t
1166 1170 $ hg log --style ./t
1167 1171
1168 1172 Defining non-standard name works:
1169 1173
1170 1174 $ cat <<EOF > t
1171 1175 > changeset = '{c}'
1172 1176 > c = q
1173 1177 > EOF
1174 1178 $ hg log --style ./t
1175 1179 8
1176 1180 7
1177 1181 6
1178 1182 5
1179 1183 4
1180 1184 3
1181 1185 2
1182 1186 1
1183 1187 0
1184 1188
1185 1189 ui.style works:
1186 1190
1187 1191 $ echo '[ui]' > .hg/hgrc
1188 1192 $ echo 'style = t' >> .hg/hgrc
1189 1193 $ hg log
1190 1194 8
1191 1195 7
1192 1196 6
1193 1197 5
1194 1198 4
1195 1199 3
1196 1200 2
1197 1201 1
1198 1202 0
1199 1203
1200 1204 Issue338:
1201 1205
1202 1206 $ hg log --style=changelog > changelog
1203 1207
1204 1208 $ cat changelog
1205 1209 2020-01-01 test <test>
1206 1210
1207 1211 * fourth, second, third:
1208 1212 third
1209 1213 [95c24699272e] [tip]
1210 1214
1211 1215 1970-01-12 User Name <user@hostname>
1212 1216
1213 1217 * second:
1214 1218 second
1215 1219 [29114dbae42b]
1216 1220
1217 1221 1970-01-18 person <person>
1218 1222
1219 1223 * merge
1220 1224 [d41e714fe50d]
1221 1225
1222 1226 * d:
1223 1227 new head
1224 1228 [13207e5a10d9]
1225 1229
1226 1230 1970-01-17 person <person>
1227 1231
1228 1232 * new branch
1229 1233 [bbe44766e73d] <foo>
1230 1234
1231 1235 1970-01-16 person <person>
1232 1236
1233 1237 * c:
1234 1238 no user, no domain
1235 1239 [10e46f2dcbf4]
1236 1240
1237 1241 1970-01-14 other <other@place>
1238 1242
1239 1243 * c:
1240 1244 no person
1241 1245 [97054abb4ab8]
1242 1246
1243 1247 1970-01-13 A. N. Other <other@place>
1244 1248
1245 1249 * b:
1246 1250 other 1 other 2
1247 1251
1248 1252 other 3
1249 1253 [b608e9d1a3f0]
1250 1254
1251 1255 1970-01-12 User Name <user@hostname>
1252 1256
1253 1257 * a:
1254 1258 line 1 line 2
1255 1259 [1e4e1b8f71e0]
1256 1260
1257 1261
1258 1262 Issue2130: xml output for 'hg heads' is malformed
1259 1263
1260 1264 $ hg heads --style changelog
1261 1265 2020-01-01 test <test>
1262 1266
1263 1267 * fourth, second, third:
1264 1268 third
1265 1269 [95c24699272e] [tip]
1266 1270
1267 1271 1970-01-18 person <person>
1268 1272
1269 1273 * merge
1270 1274 [d41e714fe50d]
1271 1275
1272 1276 1970-01-17 person <person>
1273 1277
1274 1278 * new branch
1275 1279 [bbe44766e73d] <foo>
1276 1280
1277 1281
1278 1282 Add a dummy commit to make up for the instability of the above:
1279 1283
1280 1284 $ echo a > a
1281 1285 $ hg add a
1282 1286 $ hg ci -m future
1283 1287
1284 1288 Add a commit that does all possible modifications at once
1285 1289
1286 1290 $ echo modify >> third
1287 1291 $ touch b
1288 1292 $ hg add b
1289 1293 $ hg mv fourth fifth
1290 1294 $ hg rm a
1291 1295 $ hg ci -m "Modify, add, remove, rename"
1292 1296
1293 1297 Check the status template
1294 1298
1295 1299 $ cat <<EOF >> $HGRCPATH
1296 1300 > [extensions]
1297 1301 > color=
1298 1302 > EOF
1299 1303
1300 1304 $ hg log -T status -r 10
1301 1305 changeset: 10:0f9759ec227a
1302 1306 tag: tip
1303 1307 user: test
1304 1308 date: Thu Jan 01 00:00:00 1970 +0000
1305 1309 summary: Modify, add, remove, rename
1306 1310 files:
1307 1311 M third
1308 1312 A b
1309 1313 A fifth
1310 1314 R a
1311 1315 R fourth
1312 1316
1313 1317 $ hg log -T status -C -r 10
1314 1318 changeset: 10:0f9759ec227a
1315 1319 tag: tip
1316 1320 user: test
1317 1321 date: Thu Jan 01 00:00:00 1970 +0000
1318 1322 summary: Modify, add, remove, rename
1319 1323 files:
1320 1324 M third
1321 1325 A b
1322 1326 A fifth
1323 1327 fourth
1324 1328 R a
1325 1329 R fourth
1326 1330
1327 1331 $ hg log -T status -C -r 10 -v
1328 1332 changeset: 10:0f9759ec227a
1329 1333 tag: tip
1330 1334 user: test
1331 1335 date: Thu Jan 01 00:00:00 1970 +0000
1332 1336 description:
1333 1337 Modify, add, remove, rename
1334 1338
1335 1339 files:
1336 1340 M third
1337 1341 A b
1338 1342 A fifth
1339 1343 fourth
1340 1344 R a
1341 1345 R fourth
1342 1346
1343 1347 $ hg log -T status -C -r 10 --debug
1344 1348 changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c
1345 1349 tag: tip
1346 1350 phase: secret
1347 1351 parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066
1348 1352 parent: -1:0000000000000000000000000000000000000000
1349 1353 manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567
1350 1354 user: test
1351 1355 date: Thu Jan 01 00:00:00 1970 +0000
1352 1356 extra: branch=default
1353 1357 description:
1354 1358 Modify, add, remove, rename
1355 1359
1356 1360 files:
1357 1361 M third
1358 1362 A b
1359 1363 A fifth
1360 1364 fourth
1361 1365 R a
1362 1366 R fourth
1363 1367
1364 1368 $ hg log -T status -C -r 10 --quiet
1365 1369 10:0f9759ec227a
1366 1370 $ hg --color=debug log -T status -r 10
1367 1371 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
1368 1372 [log.tag|tag: tip]
1369 1373 [log.user|user: test]
1370 1374 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1371 1375 [log.summary|summary: Modify, add, remove, rename]
1372 1376 [ui.note log.files|files:]
1373 1377 [status.modified|M third]
1374 1378 [status.added|A b]
1375 1379 [status.added|A fifth]
1376 1380 [status.removed|R a]
1377 1381 [status.removed|R fourth]
1378 1382
1379 1383 $ hg --color=debug log -T status -C -r 10
1380 1384 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
1381 1385 [log.tag|tag: tip]
1382 1386 [log.user|user: test]
1383 1387 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1384 1388 [log.summary|summary: Modify, add, remove, rename]
1385 1389 [ui.note log.files|files:]
1386 1390 [status.modified|M third]
1387 1391 [status.added|A b]
1388 1392 [status.added|A fifth]
1389 1393 [status.copied| fourth]
1390 1394 [status.removed|R a]
1391 1395 [status.removed|R fourth]
1392 1396
1393 1397 $ hg --color=debug log -T status -C -r 10 -v
1394 1398 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
1395 1399 [log.tag|tag: tip]
1396 1400 [log.user|user: test]
1397 1401 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1398 1402 [ui.note log.description|description:]
1399 1403 [ui.note log.description|Modify, add, remove, rename]
1400 1404
1401 1405 [ui.note log.files|files:]
1402 1406 [status.modified|M third]
1403 1407 [status.added|A b]
1404 1408 [status.added|A fifth]
1405 1409 [status.copied| fourth]
1406 1410 [status.removed|R a]
1407 1411 [status.removed|R fourth]
1408 1412
1409 1413 $ hg --color=debug log -T status -C -r 10 --debug
1410 1414 [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c]
1411 1415 [log.tag|tag: tip]
1412 1416 [log.phase|phase: secret]
1413 1417 [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066]
1414 1418 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1415 1419 [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567]
1416 1420 [log.user|user: test]
1417 1421 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1418 1422 [ui.debug log.extra|extra: branch=default]
1419 1423 [ui.note log.description|description:]
1420 1424 [ui.note log.description|Modify, add, remove, rename]
1421 1425
1422 1426 [ui.note log.files|files:]
1423 1427 [status.modified|M third]
1424 1428 [status.added|A b]
1425 1429 [status.added|A fifth]
1426 1430 [status.copied| fourth]
1427 1431 [status.removed|R a]
1428 1432 [status.removed|R fourth]
1429 1433
1430 1434 $ hg --color=debug log -T status -C -r 10 --quiet
1431 1435 [log.node|10:0f9759ec227a]
1432 1436
1433 1437 Check the bisect template
1434 1438
1435 1439 $ hg bisect -g 1
1436 1440 $ hg bisect -b 3 --noupdate
1437 1441 Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests)
1438 1442 $ hg log -T bisect -r 0:4
1439 1443 changeset: 0:1e4e1b8f71e0
1440 1444 bisect: good (implicit)
1441 1445 user: User Name <user@hostname>
1442 1446 date: Mon Jan 12 13:46:40 1970 +0000
1443 1447 summary: line 1
1444 1448
1445 1449 changeset: 1:b608e9d1a3f0
1446 1450 bisect: good
1447 1451 user: A. N. Other <other@place>
1448 1452 date: Tue Jan 13 17:33:20 1970 +0000
1449 1453 summary: other 1
1450 1454
1451 1455 changeset: 2:97054abb4ab8
1452 1456 bisect: untested
1453 1457 user: other@place
1454 1458 date: Wed Jan 14 21:20:00 1970 +0000
1455 1459 summary: no person
1456 1460
1457 1461 changeset: 3:10e46f2dcbf4
1458 1462 bisect: bad
1459 1463 user: person
1460 1464 date: Fri Jan 16 01:06:40 1970 +0000
1461 1465 summary: no user, no domain
1462 1466
1463 1467 changeset: 4:bbe44766e73d
1464 1468 bisect: bad (implicit)
1465 1469 branch: foo
1466 1470 user: person
1467 1471 date: Sat Jan 17 04:53:20 1970 +0000
1468 1472 summary: new branch
1469 1473
1470 1474 $ hg log --debug -T bisect -r 0:4
1471 1475 changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
1472 1476 bisect: good (implicit)
1473 1477 phase: public
1474 1478 parent: -1:0000000000000000000000000000000000000000
1475 1479 parent: -1:0000000000000000000000000000000000000000
1476 1480 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
1477 1481 user: User Name <user@hostname>
1478 1482 date: Mon Jan 12 13:46:40 1970 +0000
1479 1483 files+: a
1480 1484 extra: branch=default
1481 1485 description:
1482 1486 line 1
1483 1487 line 2
1484 1488
1485 1489
1486 1490 changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1487 1491 bisect: good
1488 1492 phase: public
1489 1493 parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
1490 1494 parent: -1:0000000000000000000000000000000000000000
1491 1495 manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
1492 1496 user: A. N. Other <other@place>
1493 1497 date: Tue Jan 13 17:33:20 1970 +0000
1494 1498 files+: b
1495 1499 extra: branch=default
1496 1500 description:
1497 1501 other 1
1498 1502 other 2
1499 1503
1500 1504 other 3
1501 1505
1502 1506
1503 1507 changeset: 2:97054abb4ab824450e9164180baf491ae0078465
1504 1508 bisect: untested
1505 1509 phase: public
1506 1510 parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1507 1511 parent: -1:0000000000000000000000000000000000000000
1508 1512 manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
1509 1513 user: other@place
1510 1514 date: Wed Jan 14 21:20:00 1970 +0000
1511 1515 files+: c
1512 1516 extra: branch=default
1513 1517 description:
1514 1518 no person
1515 1519
1516 1520
1517 1521 changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
1518 1522 bisect: bad
1519 1523 phase: public
1520 1524 parent: 2:97054abb4ab824450e9164180baf491ae0078465
1521 1525 parent: -1:0000000000000000000000000000000000000000
1522 1526 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1523 1527 user: person
1524 1528 date: Fri Jan 16 01:06:40 1970 +0000
1525 1529 files: c
1526 1530 extra: branch=default
1527 1531 description:
1528 1532 no user, no domain
1529 1533
1530 1534
1531 1535 changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1532 1536 bisect: bad (implicit)
1533 1537 branch: foo
1534 1538 phase: draft
1535 1539 parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
1536 1540 parent: -1:0000000000000000000000000000000000000000
1537 1541 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1538 1542 user: person
1539 1543 date: Sat Jan 17 04:53:20 1970 +0000
1540 1544 extra: branch=foo
1541 1545 description:
1542 1546 new branch
1543 1547
1544 1548
1545 1549 $ hg log -v -T bisect -r 0:4
1546 1550 changeset: 0:1e4e1b8f71e0
1547 1551 bisect: good (implicit)
1548 1552 user: User Name <user@hostname>
1549 1553 date: Mon Jan 12 13:46:40 1970 +0000
1550 1554 files: a
1551 1555 description:
1552 1556 line 1
1553 1557 line 2
1554 1558
1555 1559
1556 1560 changeset: 1:b608e9d1a3f0
1557 1561 bisect: good
1558 1562 user: A. N. Other <other@place>
1559 1563 date: Tue Jan 13 17:33:20 1970 +0000
1560 1564 files: b
1561 1565 description:
1562 1566 other 1
1563 1567 other 2
1564 1568
1565 1569 other 3
1566 1570
1567 1571
1568 1572 changeset: 2:97054abb4ab8
1569 1573 bisect: untested
1570 1574 user: other@place
1571 1575 date: Wed Jan 14 21:20:00 1970 +0000
1572 1576 files: c
1573 1577 description:
1574 1578 no person
1575 1579
1576 1580
1577 1581 changeset: 3:10e46f2dcbf4
1578 1582 bisect: bad
1579 1583 user: person
1580 1584 date: Fri Jan 16 01:06:40 1970 +0000
1581 1585 files: c
1582 1586 description:
1583 1587 no user, no domain
1584 1588
1585 1589
1586 1590 changeset: 4:bbe44766e73d
1587 1591 bisect: bad (implicit)
1588 1592 branch: foo
1589 1593 user: person
1590 1594 date: Sat Jan 17 04:53:20 1970 +0000
1591 1595 description:
1592 1596 new branch
1593 1597
1594 1598
1595 1599 $ hg --color=debug log -T bisect -r 0:4
1596 1600 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
1597 1601 [log.bisect bisect.good|bisect: good (implicit)]
1598 1602 [log.user|user: User Name <user@hostname>]
1599 1603 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
1600 1604 [log.summary|summary: line 1]
1601 1605
1602 1606 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
1603 1607 [log.bisect bisect.good|bisect: good]
1604 1608 [log.user|user: A. N. Other <other@place>]
1605 1609 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
1606 1610 [log.summary|summary: other 1]
1607 1611
1608 1612 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
1609 1613 [log.bisect bisect.untested|bisect: untested]
1610 1614 [log.user|user: other@place]
1611 1615 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
1612 1616 [log.summary|summary: no person]
1613 1617
1614 1618 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
1615 1619 [log.bisect bisect.bad|bisect: bad]
1616 1620 [log.user|user: person]
1617 1621 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
1618 1622 [log.summary|summary: no user, no domain]
1619 1623
1620 1624 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
1621 1625 [log.bisect bisect.bad|bisect: bad (implicit)]
1622 1626 [log.branch|branch: foo]
1623 1627 [log.user|user: person]
1624 1628 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
1625 1629 [log.summary|summary: new branch]
1626 1630
1627 1631 $ hg --color=debug log --debug -T bisect -r 0:4
1628 1632 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
1629 1633 [log.bisect bisect.good|bisect: good (implicit)]
1630 1634 [log.phase|phase: public]
1631 1635 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1632 1636 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1633 1637 [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0]
1634 1638 [log.user|user: User Name <user@hostname>]
1635 1639 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
1636 1640 [ui.debug log.files|files+: a]
1637 1641 [ui.debug log.extra|extra: branch=default]
1638 1642 [ui.note log.description|description:]
1639 1643 [ui.note log.description|line 1
1640 1644 line 2]
1641 1645
1642 1646
1643 1647 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
1644 1648 [log.bisect bisect.good|bisect: good]
1645 1649 [log.phase|phase: public]
1646 1650 [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
1647 1651 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1648 1652 [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55]
1649 1653 [log.user|user: A. N. Other <other@place>]
1650 1654 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
1651 1655 [ui.debug log.files|files+: b]
1652 1656 [ui.debug log.extra|extra: branch=default]
1653 1657 [ui.note log.description|description:]
1654 1658 [ui.note log.description|other 1
1655 1659 other 2
1656 1660
1657 1661 other 3]
1658 1662
1659 1663
1660 1664 [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465]
1661 1665 [log.bisect bisect.untested|bisect: untested]
1662 1666 [log.phase|phase: public]
1663 1667 [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
1664 1668 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1665 1669 [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1]
1666 1670 [log.user|user: other@place]
1667 1671 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
1668 1672 [ui.debug log.files|files+: c]
1669 1673 [ui.debug log.extra|extra: branch=default]
1670 1674 [ui.note log.description|description:]
1671 1675 [ui.note log.description|no person]
1672 1676
1673 1677
1674 1678 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
1675 1679 [log.bisect bisect.bad|bisect: bad]
1676 1680 [log.phase|phase: public]
1677 1681 [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465]
1678 1682 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1679 1683 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
1680 1684 [log.user|user: person]
1681 1685 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
1682 1686 [ui.debug log.files|files: c]
1683 1687 [ui.debug log.extra|extra: branch=default]
1684 1688 [ui.note log.description|description:]
1685 1689 [ui.note log.description|no user, no domain]
1686 1690
1687 1691
1688 1692 [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74]
1689 1693 [log.bisect bisect.bad|bisect: bad (implicit)]
1690 1694 [log.branch|branch: foo]
1691 1695 [log.phase|phase: draft]
1692 1696 [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
1693 1697 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
1694 1698 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
1695 1699 [log.user|user: person]
1696 1700 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
1697 1701 [ui.debug log.extra|extra: branch=foo]
1698 1702 [ui.note log.description|description:]
1699 1703 [ui.note log.description|new branch]
1700 1704
1701 1705
1702 1706 $ hg --color=debug log -v -T bisect -r 0:4
1703 1707 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
1704 1708 [log.bisect bisect.good|bisect: good (implicit)]
1705 1709 [log.user|user: User Name <user@hostname>]
1706 1710 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
1707 1711 [ui.note log.files|files: a]
1708 1712 [ui.note log.description|description:]
1709 1713 [ui.note log.description|line 1
1710 1714 line 2]
1711 1715
1712 1716
1713 1717 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
1714 1718 [log.bisect bisect.good|bisect: good]
1715 1719 [log.user|user: A. N. Other <other@place>]
1716 1720 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
1717 1721 [ui.note log.files|files: b]
1718 1722 [ui.note log.description|description:]
1719 1723 [ui.note log.description|other 1
1720 1724 other 2
1721 1725
1722 1726 other 3]
1723 1727
1724 1728
1725 1729 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
1726 1730 [log.bisect bisect.untested|bisect: untested]
1727 1731 [log.user|user: other@place]
1728 1732 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
1729 1733 [ui.note log.files|files: c]
1730 1734 [ui.note log.description|description:]
1731 1735 [ui.note log.description|no person]
1732 1736
1733 1737
1734 1738 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
1735 1739 [log.bisect bisect.bad|bisect: bad]
1736 1740 [log.user|user: person]
1737 1741 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
1738 1742 [ui.note log.files|files: c]
1739 1743 [ui.note log.description|description:]
1740 1744 [ui.note log.description|no user, no domain]
1741 1745
1742 1746
1743 1747 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
1744 1748 [log.bisect bisect.bad|bisect: bad (implicit)]
1745 1749 [log.branch|branch: foo]
1746 1750 [log.user|user: person]
1747 1751 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
1748 1752 [ui.note log.description|description:]
1749 1753 [ui.note log.description|new branch]
1750 1754
1751 1755
1752 1756 $ hg bisect --reset
1753 1757
1754 1758 $ cd ..
1755 1759
1756 1760 Set up latesttag repository:
1757 1761
1758 1762 $ hg init latesttag
1759 1763 $ cd latesttag
1760 1764
1761 1765 $ echo a > file
1762 1766 $ hg ci -Am a -d '0 0'
1763 1767 adding file
1764 1768
1765 1769 $ echo b >> file
1766 1770 $ hg ci -m b -d '1 0'
1767 1771
1768 1772 $ echo c >> head1
1769 1773 $ hg ci -Am h1c -d '2 0'
1770 1774 adding head1
1771 1775
1772 1776 $ hg update -q 1
1773 1777 $ echo d >> head2
1774 1778 $ hg ci -Am h2d -d '3 0'
1775 1779 adding head2
1776 1780 created new head
1777 1781
1778 1782 $ echo e >> head2
1779 1783 $ hg ci -m h2e -d '4 0'
1780 1784
1781 1785 $ hg merge -q
1782 1786 $ hg ci -m merge -d '5 -3600'
1783 1787
1784 1788 $ hg tag -r 1 -m t1 -d '6 0' t1
1785 1789 $ hg tag -r 2 -m t2 -d '7 0' t2
1786 1790 $ hg tag -r 3 -m t3 -d '8 0' t3
1787 1791 $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
1788 1792 $ hg tag -r 5 -m t5 -d '9 0' t5
1789 1793 $ hg tag -r 3 -m at3 -d '10 0' at3
1790 1794
1791 1795 $ cd ..
1792 1796
1793 1797 Style path expansion: issue1948 - ui.style option doesn't work on OSX
1794 1798 if it is a relative path
1795 1799
1796 1800 $ mkdir -p home/styles
1797 1801
1798 1802 $ cat > home/styles/teststyle <<EOF
1799 1803 > changeset = 'test {rev}:{node|short}\n'
1800 1804 > EOF
1801 1805
1802 1806 $ HOME=`pwd`/home; export HOME
1803 1807
1804 1808 $ cat > latesttag/.hg/hgrc <<EOF
1805 1809 > [ui]
1806 1810 > style = ~/styles/teststyle
1807 1811 > EOF
1808 1812
1809 1813 $ hg -R latesttag tip
1810 1814 test 11:97e5943b523a
1811 1815
1812 1816 Test recursive showlist template (issue1989):
1813 1817
1814 1818 $ cat > style1989 <<EOF
1815 1819 > changeset = '{file_mods}{manifest}{extras}'
1816 1820 > file_mod = 'M|{author|person}\n'
1817 1821 > manifest = '{rev},{author}\n'
1818 1822 > extra = '{key}: {author}\n'
1819 1823 > EOF
1820 1824
1821 1825 $ hg -R latesttag log -r tip --style=style1989
1822 1826 M|test
1823 1827 11,
1824 1828 branch: test
General Comments 0
You need to be logged in to leave comments. Login now