tests/test-command-template.t
author Yuya Nishihara <yuya@tcha.org>
Sat, 16 Jun 2018 14:14:52 +0900
changeset 38436 da4508cdef37
parent 38434 70f551a3f52e
permissions -rw-r--r--
tests: extract test-template-keywords.t from test-command-template.t
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     1
  $ hg init a
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     2
  $ cd a
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     3
  $ echo a > a
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     4
  $ hg add a
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     5
  $ echo line 1 > b
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     6
  $ echo line 2 >> b
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     7
  $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     8
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
     9
  $ hg add b
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    10
  $ echo other 1 > c
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    11
  $ echo other 2 >> c
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    12
  $ echo >> c
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    13
  $ echo other 3 >> c
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    14
  $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    15
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    16
  $ hg add c
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    17
  $ hg commit -m 'no person' -d '1200000 0' -u 'other@place'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    18
  $ echo c >> c
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    19
  $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    20
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    21
  $ echo foo > .hg/branch
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    22
  $ hg commit -m 'new branch' -d '1400000 0' -u 'person'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    23
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    24
  $ hg co -q 3
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    25
  $ echo other 4 >> d
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    26
  $ hg add d
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    27
  $ hg commit -m 'new head' -d '1500000 0' -u 'person'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    28
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    29
  $ hg merge -q foo
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    30
  $ hg commit -m 'merge' -d '1500001 0' -u 'person'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
    31
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    32
Test arithmetic operators have the right precedence:
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    33
30237
94ef2f00b8a4 tests: use basic format code "%Y" instead of "%s" for test portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 30232
diff changeset
    34
  $ hg log -l 1 -T '{date(date, "%Y") + 5 * 10} {date(date, "%Y") - 2 * 3}\n'
94ef2f00b8a4 tests: use basic format code "%Y" instead of "%s" for test portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 30232
diff changeset
    35
  2020 1964
94ef2f00b8a4 tests: use basic format code "%Y" instead of "%s" for test portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 30232
diff changeset
    36
  $ hg log -l 1 -T '{date(date, "%Y") * 5 + 10} {date(date, "%Y") * 3 - 2}\n'
94ef2f00b8a4 tests: use basic format code "%Y" instead of "%s" for test portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 30232
diff changeset
    37
  9860 5908
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    38
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    39
Test division:
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    40
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    41
  $ hg debugtemplate -r0 -v '{5 / 2} {mod(5, 2)}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    42
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    43
    (/
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    44
      (integer '5')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    45
      (integer '2'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    46
    (string ' ')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    47
    (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    48
      (symbol 'mod')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    49
      (list
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    50
        (integer '5')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    51
        (integer '2')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    52
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
    53
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
    54
  * functions: mod
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    55
  2 1
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    56
  $ hg debugtemplate -r0 -v '{5 / -2} {mod(5, -2)}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    57
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    58
    (/
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    59
      (integer '5')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    60
      (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    61
        (integer '2')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    62
    (string ' ')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    63
    (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    64
      (symbol 'mod')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    65
      (list
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    66
        (integer '5')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    67
        (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    68
          (integer '2'))))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    69
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
    70
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
    71
  * functions: mod
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    72
  -3 -1
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    73
  $ hg debugtemplate -r0 -v '{-5 / 2} {mod(-5, 2)}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    74
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    75
    (/
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    76
      (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    77
        (integer '5'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    78
      (integer '2'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    79
    (string ' ')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    80
    (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    81
      (symbol 'mod')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    82
      (list
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    83
        (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    84
          (integer '5'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    85
        (integer '2')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    86
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
    87
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
    88
  * functions: mod
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    89
  -3 1
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    90
  $ hg debugtemplate -r0 -v '{-5 / -2} {mod(-5, -2)}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    91
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    92
    (/
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    93
      (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    94
        (integer '5'))
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    95
      (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    96
        (integer '2')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    97
    (string ' ')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
    98
    (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
    99
      (symbol 'mod')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   100
      (list
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   101
        (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   102
          (integer '5'))
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   103
        (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   104
          (integer '2'))))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   105
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   106
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   107
  * functions: mod
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   108
  2 -1
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   109
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   110
Filters bind closer than arithmetic:
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   111
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   112
  $ hg debugtemplate -r0 -v '{revset(".")|count - 1}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   113
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   114
    (-
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   115
      (|
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   116
        (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   117
          (symbol 'revset')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   118
          (string '.'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   119
        (symbol 'count'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   120
      (integer '1'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   121
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   122
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   123
  * functions: count, revset
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   124
  0
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   125
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   126
But negate binds closer still:
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   127
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   128
  $ hg debugtemplate -r0 -v '{1-3|stringify}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   129
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   130
    (-
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   131
      (integer '1')
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   132
      (|
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   133
        (integer '3')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   134
        (symbol 'stringify')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   135
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   136
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   137
  * functions: stringify
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   138
  hg: parse error: arithmetic only defined on integers
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   139
  [255]
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   140
  $ hg debugtemplate -r0 -v '{-3|stringify}\n'
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   141
  (template
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   142
    (|
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   143
      (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   144
        (integer '3'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   145
      (symbol 'stringify'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   146
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   147
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   148
  * functions: stringify
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   149
  -3
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   150
34329
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   151
Filters bind as close as map operator:
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   152
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   153
  $ hg debugtemplate -r0 -v '{desc|splitlines % "{line}\n"}'
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   154
  (template
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   155
    (%
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   156
      (|
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   157
        (symbol 'desc')
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   158
        (symbol 'splitlines'))
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   159
      (template
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   160
        (symbol 'line')
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   161
        (string '\n'))))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   162
  * keywords: desc, line
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   163
  * functions: splitlines
34329
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   164
  line 1
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   165
  line 2
6367318327f0 templater: adjust binding strength of '%' and '|' operators (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 34073
diff changeset
   166
31885
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   167
Keyword arguments:
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   168
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   169
  $ hg debugtemplate -r0 -v '{foo=bar|baz}'
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   170
  (template
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   171
    (keyvalue
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   172
      (symbol 'foo')
31885
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   173
      (|
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   174
        (symbol 'bar')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   175
        (symbol 'baz'))))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   176
  * keywords: bar, foo
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   177
  * functions: baz
31885
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   178
  hg: parse error: can't use a key-value pair in this context
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   179
  [255]
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   180
31887
f7b3677f66cd templater: port pad() to take keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31886
diff changeset
   181
  $ hg debugtemplate '{pad("foo", width=10, left=true)}\n'
f7b3677f66cd templater: port pad() to take keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31886
diff changeset
   182
         foo
f7b3677f66cd templater: port pad() to take keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31886
diff changeset
   183
31886
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   184
Call function which takes named arguments by filter syntax:
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   185
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   186
  $ hg debugtemplate '{" "|separate}'
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   187
  $ hg debugtemplate '{("not", "an", "argument", "list")|separate}'
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   188
  hg: parse error: unknown method 'list'
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   189
  [255]
bdda942f4b9c templater: add support for keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents: 31885
diff changeset
   190
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   191
Second branch starting at nullrev:
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   192
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   193
  $ hg update null
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   194
  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   195
  $ echo second > second
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   196
  $ hg add second
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   197
  $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   198
  created new head
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   199
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   200
  $ echo third > third
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   201
  $ hg add third
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   202
  $ hg mv second fourth
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   203
  $ hg commit -m third -d "2020-01-01 10:01"
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   204
18970
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18893
diff changeset
   205
  $ hg log --template '{join(file_copies, ",\n")}\n' -r .
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18893
diff changeset
   206
  fourth (second)
20665
945bc5497e6d commands: add -T alternative to --template
Matt Mackall <mpm@selenic.com>
parents: 20520
diff changeset
   207
  $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r .
18715
c4ff927b6f68 templater: properly handle file_copies with %
Matt Mackall <mpm@selenic.com>
parents: 18207
diff changeset
   208
  second -> fourth
24240
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24157
diff changeset
   209
  $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24157
diff changeset
   210
  8 t
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24157
diff changeset
   211
  7 f
18715
c4ff927b6f68 templater: properly handle file_copies with %
Matt Mackall <mpm@selenic.com>
parents: 18207
diff changeset
   212
35469
f1c54d003327 templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents: 34993
diff changeset
   213
Internal resources shouldn't be exposed (issue5699):
f1c54d003327 templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents: 34993
diff changeset
   214
35470
a33be093ec62 templater: look up symbols/resources as if they were separated (issue5699)
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
   215
  $ hg log -r. -T '{cache}{ctx}{repo}{revcache}{templ}{ui}'
a33be093ec62 templater: look up symbols/resources as if they were separated (issue5699)
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
   216
a33be093ec62 templater: look up symbols/resources as if they were separated (issue5699)
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
   217
Never crash on internal resource not available:
a33be093ec62 templater: look up symbols/resources as if they were separated (issue5699)
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
   218
a33be093ec62 templater: look up symbols/resources as if they were separated (issue5699)
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
   219
  $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n'
38427
4b73f316ba0e templatefuncs: minimize resource requirements
Yuya Nishihara <yuya@tcha.org>
parents: 38355
diff changeset
   220
  abort: template resource not available: repo
35470
a33be093ec62 templater: look up symbols/resources as if they were separated (issue5699)
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
   221
  [255]
35469
f1c54d003327 templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents: 34993
diff changeset
   222
36445
e8d37838f5df templatekw: add 'requires' flag to switch to exception-safe interface
Yuya Nishihara <yuya@tcha.org>
parents: 36246
diff changeset
   223
  $ hg config -T '{author}'
e8d37838f5df templatekw: add 'requires' flag to switch to exception-safe interface
Yuya Nishihara <yuya@tcha.org>
parents: 36246
diff changeset
   224
16678
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   225
Quoting for ui.logtemplate
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   226
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   227
  $ hg tip --config "ui.logtemplate={rev}\n"
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   228
  8
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   229
  $ hg tip --config "ui.logtemplate='{rev}\n'"
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   230
  8
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   231
  $ hg tip --config 'ui.logtemplate="{rev}\n"'
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   232
  8
28687
29c249dfb4ef templater: do not strip non-quote characters from template config
Yuya Nishihara <yuya@tcha.org>
parents: 28628
diff changeset
   233
  $ hg tip --config 'ui.logtemplate=n{rev}\n'
29c249dfb4ef templater: do not strip non-quote characters from template config
Yuya Nishihara <yuya@tcha.org>
parents: 28628
diff changeset
   234
  n8
16678
48b1674ac1e7 templater: handle SyntaxError when parsing ui.logtemplate
Martin Geisler <martin@geisler.net>
parents: 15839
diff changeset
   235
27939
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   236
Check that recursive reference does not fall into RuntimeError (issue4758):
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   237
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   238
 common mistake:
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   239
32874
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   240
  $ cat << EOF > issue4758
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   241
  > changeset = '{changeset}\n'
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   242
  > EOF
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   243
  $ hg log --style ./issue4758
27939
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   244
  abort: recursive reference 'changeset' in template
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   245
  [255]
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   246
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   247
 circular reference:
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   248
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   249
  $ cat << EOF > issue4758
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   250
  > changeset = '{foo}'
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   251
  > foo = '{changeset}'
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   252
  > EOF
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   253
  $ hg log --style ./issue4758
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   254
  abort: recursive reference 'foo' in template
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   255
  [255]
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   256
27940
cfe7da66f555 templater: abort if infinite recursion detected while compiling
Yuya Nishihara <yuya@tcha.org>
parents: 27939
diff changeset
   257
 buildmap() -> gettemplate(), where no thunk was made:
cfe7da66f555 templater: abort if infinite recursion detected while compiling
Yuya Nishihara <yuya@tcha.org>
parents: 27939
diff changeset
   258
32874
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   259
  $ cat << EOF > issue4758
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   260
  > changeset = '{files % changeset}\n'
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   261
  > EOF
dddba6f3e59c test-command-template: rewrite recursion tests by using a map file
Yuya Nishihara <yuya@tcha.org>
parents: 32684
diff changeset
   262
  $ hg log --style ./issue4758
27940
cfe7da66f555 templater: abort if infinite recursion detected while compiling
Yuya Nishihara <yuya@tcha.org>
parents: 27939
diff changeset
   263
  abort: recursive reference 'changeset' in template
cfe7da66f555 templater: abort if infinite recursion detected while compiling
Yuya Nishihara <yuya@tcha.org>
parents: 27939
diff changeset
   264
  [255]
cfe7da66f555 templater: abort if infinite recursion detected while compiling
Yuya Nishihara <yuya@tcha.org>
parents: 27939
diff changeset
   265
27939
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   266
 not a recursion if a keyword of the same name exists:
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   267
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   268
  $ cat << EOF > issue4758
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   269
  > changeset = '{tags % rev}'
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   270
  > rev = '{rev} {tag}\n'
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   271
  > EOF
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   272
  $ hg log --style ./issue4758 -r tip
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   273
  8 tip
7ed3a3c0cef1 templater: abort if infinite recursion detected while evaluation (issue4758)
Yuya Nishihara <yuya@tcha.org>
parents: 27894
diff changeset
   274
38436
da4508cdef37 tests: extract test-template-keywords.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38434
diff changeset
   275
Set up phase:
22764
1e2f54a149e8 templater: set the correct phase for parents
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 22668
diff changeset
   276
1e2f54a149e8 templater: set the correct phase for parents
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 22668
diff changeset
   277
  $ hg phase -r 5 --public
1e2f54a149e8 templater: set the correct phase for parents
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 22668
diff changeset
   278
  $ hg phase -r 7 --secret --force
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   279
25005
5ddbb024c2e9 tests: fix hidden repeatability problem with age filter test
Matt Mackall <mpm@selenic.com>
parents: 25003
diff changeset
   280
Add a dummy commit to make up for the instability of the above:
5ddbb024c2e9 tests: fix hidden repeatability problem with age filter test
Matt Mackall <mpm@selenic.com>
parents: 25003
diff changeset
   281
5ddbb024c2e9 tests: fix hidden repeatability problem with age filter test
Matt Mackall <mpm@selenic.com>
parents: 25003
diff changeset
   282
  $ echo a > a
5ddbb024c2e9 tests: fix hidden repeatability problem with age filter test
Matt Mackall <mpm@selenic.com>
parents: 25003
diff changeset
   283
  $ hg add a
5ddbb024c2e9 tests: fix hidden repeatability problem with age filter test
Matt Mackall <mpm@selenic.com>
parents: 25003
diff changeset
   284
  $ hg ci -m future
5ddbb024c2e9 tests: fix hidden repeatability problem with age filter test
Matt Mackall <mpm@selenic.com>
parents: 25003
diff changeset
   285
24985
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   286
Add a commit that does all possible modifications at once
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   287
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   288
  $ echo modify >> third
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   289
  $ touch b
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   290
  $ hg add b
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   291
  $ hg mv fourth fifth
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   292
  $ hg rm a
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   293
  $ hg ci -m "Modify, add, remove, rename"
20bff5d09018 tests: add a new commit to test-commandline-template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 24966
diff changeset
   294
38433
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   295
Error on syntax:
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   296
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   297
  $ cat <<EOF > t
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   298
  > changeset = '{c}'
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   299
  > c = q
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   300
  > x = "f
25006
517763f87141 log: add a status template
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 25005
diff changeset
   301
  > EOF
38433
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   302
  $ echo '[ui]' > .hg/hgrc
ddce7bdf7f3c tests: extract test-template-map.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38427
diff changeset
   303
  $ echo 'style = t' >> .hg/hgrc
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   304
  $ hg log
28628
ed1d90f6e921 templater: do not abuse SyntaxError to report errors in template map file
Yuya Nishihara <yuya@tcha.org>
parents: 28548
diff changeset
   305
  hg: parse error at t:3: unmatched quotes
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12283
diff changeset
   306
  [255]
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   307
25782
babd2c93bd99 templater: check existence of closing brace of template string
Yuya Nishihara <yuya@tcha.org>
parents: 25762
diff changeset
   308
  $ hg log -T '{date'
babd2c93bd99 templater: check existence of closing brace of template string
Yuya Nishihara <yuya@tcha.org>
parents: 25762
diff changeset
   309
  hg: parse error at 1: unterminated template expansion
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   310
  ({date
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   311
    ^ here)
25782
babd2c93bd99 templater: check existence of closing brace of template string
Yuya Nishihara <yuya@tcha.org>
parents: 25762
diff changeset
   312
  [255]
35680
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   313
  $ hg log -T '{date(}'
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   314
  hg: parse error at 6: not a prefix: end
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   315
  ({date(}
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   316
         ^ here)
35680
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   317
  [255]
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   318
  $ hg log -T '{date)}'
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   319
  hg: parse error at 5: invalid token
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   320
  ({date)}
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   321
        ^ here)
35680
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   322
  [255]
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   323
  $ hg log -T '{date date}'
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   324
  hg: parse error at 6: invalid token
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   325
  ({date date}
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   326
         ^ here)
35680
077ee15b8493 templater: make sure expression is terminated by '}'
Yuya Nishihara <yuya@tcha.org>
parents: 35594
diff changeset
   327
  [255]
25782
babd2c93bd99 templater: check existence of closing brace of template string
Yuya Nishihara <yuya@tcha.org>
parents: 25762
diff changeset
   328
35744
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   329
  $ hg log -T '{}'
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   330
  hg: parse error at 1: not a prefix: end
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   331
  ({}
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   332
    ^ here)
35744
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   333
  [255]
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   334
  $ hg debugtemplate -v '{()}'
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   335
  (template
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   336
    (group
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   337
      None))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   338
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   339
  * functions: 
35744
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   340
  hg: parse error: missing argument
8685192a8733 templater: fix crash by empty group expression
Yuya Nishihara <yuya@tcha.org>
parents: 35680
diff changeset
   341
  [255]
25782
babd2c93bd99 templater: check existence of closing brace of template string
Yuya Nishihara <yuya@tcha.org>
parents: 25762
diff changeset
   342
37223
08e042f0a67c templatefilters: declare input type as bytes where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37105
diff changeset
   343
Behind the scenes, this would throw TypeError without intype=bytes
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   344
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   345
  $ hg log -l 3 --template '{date|obfuscate}\n'
38299
88e7105b5cd9 templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents: 38289
diff changeset
   346
  &#48;&#46;&#48;&#48;
88e7105b5cd9 templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents: 38289
diff changeset
   347
  &#48;&#46;&#48;&#48;
88e7105b5cd9 templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents: 38289
diff changeset
   348
  &#49;&#53;&#55;&#55;&#56;&#55;&#50;&#56;&#54;&#48;&#46;&#48;&#48;
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   349
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   350
Behind the scenes, this will throw a ValueError
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   351
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   352
  $ hg log -l 3 --template 'line: {desc|shortdate}\n'
37227
9bcf096a2da2 templatefilters: declare input type as date where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37223
diff changeset
   353
  hg: parse error: invalid date: 'Modify, add, remove, rename'
9bcf096a2da2 templatefilters: declare input type as date where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37223
diff changeset
   354
  (template filter 'shortdate' is not compatible with keyword 'desc')
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   355
  [255]
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   356
37223
08e042f0a67c templatefilters: declare input type as bytes where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37105
diff changeset
   357
Behind the scenes, this would throw AttributeError without intype=bytes
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   358
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   359
  $ hg log -l 3 --template 'line: {date|escape}\n'
38299
88e7105b5cd9 templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents: 38289
diff changeset
   360
  line: 0.00
88e7105b5cd9 templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents: 38289
diff changeset
   361
  line: 0.00
88e7105b5cd9 templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents: 38289
diff changeset
   362
  line: 1577872860.00
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   363
26127
7012be5ab5bd templater: port localdate filter to a function
Yuya Nishihara <yuya@tcha.org>
parents: 26106
diff changeset
   364
  $ hg log -l 3 --template 'line: {extras|localdate}\n'
7012be5ab5bd templater: port localdate filter to a function
Yuya Nishihara <yuya@tcha.org>
parents: 26106
diff changeset
   365
  hg: parse error: localdate expects a date information
7012be5ab5bd templater: port localdate filter to a function
Yuya Nishihara <yuya@tcha.org>
parents: 26106
diff changeset
   366
  [255]
7012be5ab5bd templater: port localdate filter to a function
Yuya Nishihara <yuya@tcha.org>
parents: 26106
diff changeset
   367
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   368
Behind the scenes, this will throw ValueError
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   369
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   370
  $ hg tip --template '{author|email|date}\n'
26106
c568c4db036f templatefilters: remove redundant 'date' and 'strip' filters
Yuya Nishihara <yuya@tcha.org>
parents: 26105
diff changeset
   371
  hg: parse error: date expects a date information
17383
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   372
  [255]
099c778ceb33 templater: abort when a template filter raises an exception (issue2987)
Neil Kodner <neilk@fb.com>
parents: 17345
diff changeset
   373
31927
2abc556dbe92 templater: find keyword name more thoroughly on filtering error
Yuya Nishihara <yuya@tcha.org>
parents: 31926
diff changeset
   374
  $ hg tip -T '{author|email|shortdate}\n'
37227
9bcf096a2da2 templatefilters: declare input type as date where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37223
diff changeset
   375
  hg: parse error: invalid date: 'test'
9bcf096a2da2 templatefilters: declare input type as date where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37223
diff changeset
   376
  (template filter 'shortdate' is not compatible with keyword 'author')
31927
2abc556dbe92 templater: find keyword name more thoroughly on filtering error
Yuya Nishihara <yuya@tcha.org>
parents: 31926
diff changeset
   377
  [255]
2abc556dbe92 templater: find keyword name more thoroughly on filtering error
Yuya Nishihara <yuya@tcha.org>
parents: 31926
diff changeset
   378
2abc556dbe92 templater: find keyword name more thoroughly on filtering error
Yuya Nishihara <yuya@tcha.org>
parents: 31926
diff changeset
   379
  $ hg tip -T '{get(extras, "branch")|shortdate}\n'
37227
9bcf096a2da2 templatefilters: declare input type as date where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37223
diff changeset
   380
  hg: parse error: invalid date: 'default'
9bcf096a2da2 templatefilters: declare input type as date where appropriate
Yuya Nishihara <yuya@tcha.org>
parents: 37223
diff changeset
   381
  (incompatible use of template filter 'shortdate')
31927
2abc556dbe92 templater: find keyword name more thoroughly on filtering error
Yuya Nishihara <yuya@tcha.org>
parents: 31926
diff changeset
   382
  [255]
2abc556dbe92 templater: find keyword name more thoroughly on filtering error
Yuya Nishihara <yuya@tcha.org>
parents: 31926
diff changeset
   383
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   384
Error in nested template:
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   385
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   386
  $ hg log -T '{"date'
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   387
  hg: parse error at 2: unterminated string
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   388
  ({"date
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   389
     ^ here)
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   390
  [255]
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   391
31885
d18b624c1c06 templater: add parsing rule for key-value pair
Yuya Nishihara <yuya@tcha.org>
parents: 31882
diff changeset
   392
  $ hg log -T '{"foo{date|?}"}'
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   393
  hg: parse error at 11: syntax error
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   394
  ({"foo{date|?}"}
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   395
              ^ here)
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   396
  [255]
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   397
20857
6eb55310fcbc templater: raise error for unknown func
Sean Farley <sean.michael.farley@gmail.com>
parents: 20663
diff changeset
   398
Thrown an error if a template function doesn't exist
6eb55310fcbc templater: raise error for unknown func
Sean Farley <sean.michael.farley@gmail.com>
parents: 20663
diff changeset
   399
6eb55310fcbc templater: raise error for unknown func
Sean Farley <sean.michael.farley@gmail.com>
parents: 20663
diff changeset
   400
  $ hg tip --template '{foo()}\n'
6eb55310fcbc templater: raise error for unknown func
Sean Farley <sean.michael.farley@gmail.com>
parents: 20663
diff changeset
   401
  hg: parse error: unknown function 'foo'
6eb55310fcbc templater: raise error for unknown func
Sean Farley <sean.michael.farley@gmail.com>
parents: 20663
diff changeset
   402
  [255]
6eb55310fcbc templater: raise error for unknown func
Sean Farley <sean.michael.farley@gmail.com>
parents: 20663
diff changeset
   403
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   404
  $ cd ..
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   405
38436
da4508cdef37 tests: extract test-template-keywords.t from test-command-template.t
Yuya Nishihara <yuya@tcha.org>
parents: 38434
diff changeset
   406
Set up latesttag repository:
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   407
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   408
  $ hg init latesttag
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   409
  $ cd latesttag
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   410
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   411
  $ echo a > file
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   412
  $ hg ci -Am a -d '0 0'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   413
  adding file
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   414
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   415
  $ echo b >> file
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   416
  $ hg ci -m b -d '1 0'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   417
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   418
  $ echo c >> head1
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   419
  $ hg ci -Am h1c -d '2 0'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   420
  adding head1
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   421
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   422
  $ hg update -q 1
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   423
  $ echo d >> head2
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   424
  $ hg ci -Am h2d -d '3 0'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   425
  adding head2
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   426
  created new head
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   427
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   428
  $ echo e >> head2
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   429
  $ hg ci -m h2e -d '4 0'
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   430
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   431
  $ hg merge -q
19989
c38c3fdc8b93 date: allow %z in format (issue4040)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   432
  $ hg ci -m merge -d '5 -3600'
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   433
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   434
  $ hg tag -r 1 -m t1 -d '6 0' t1
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   435
  $ hg tag -r 2 -m t2 -d '7 0' t2
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   436
  $ hg tag -r 3 -m t3 -d '8 0' t3
33862
fb672eac2702 templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents: 33861
diff changeset
   437
  $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   438
  $ hg tag -r 5 -m t5 -d '9 0' t5
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   439
  $ hg tag -r 3 -m at3 -d '10 0' at3
33861
0e15d5ae52cf tests: use graph log in {latesttag} tests
Martin von Zweigbergk <martinvonz@google.com>
parents: 33542
diff changeset
   440
12283
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   441
  $ cd ..
850e089eb41c tests: unify test-command-template
Adrian Buehlmann <adrian@cadifra.com>
parents: 11656
diff changeset
   442
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17387
diff changeset
   443
Test new-style inline templating:
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17387
diff changeset
   444
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17387
diff changeset
   445
  $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17387
diff changeset
   446
  modified files:  .hgtags
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17387
diff changeset
   447
  
28349
7cb2f2438f85 templater: handle exception when applying map operator to non-iterable object
Yuya Nishihara <yuya@tcha.org>
parents: 28346
diff changeset
   448
7cb2f2438f85 templater: handle exception when applying map operator to non-iterable object
Yuya Nishihara <yuya@tcha.org>
parents: 28346
diff changeset
   449
  $ hg log -R latesttag -r tip -T '{rev % "a"}\n'
38229
7701c2d4a438 templater: always map over a wrapped object
Yuya Nishihara <yuya@tcha.org>
parents: 38228
diff changeset
   450
  hg: parse error: 11 is not iterable of mappings
38271
4b0f39e7406e templater: show slightly better hint on map operation error
Yuya Nishihara <yuya@tcha.org>
parents: 38267
diff changeset
   451
  (keyword 'rev' does not support map operation)
28349
7cb2f2438f85 templater: handle exception when applying map operator to non-iterable object
Yuya Nishihara <yuya@tcha.org>
parents: 28346
diff changeset
   452
  [255]
7cb2f2438f85 templater: handle exception when applying map operator to non-iterable object
Yuya Nishihara <yuya@tcha.org>
parents: 28346
diff changeset
   453
  $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n'
37404
7c902a8345ef templater: complain about invalid application of '%' operator (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 37229
diff changeset
   454
  hg: parse error: None is not iterable of mappings
7c902a8345ef templater: complain about invalid application of '%' operator (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 37229
diff changeset
   455
  [255]
7c902a8345ef templater: complain about invalid application of '%' operator (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 37229
diff changeset
   456
  $ hg log -R latesttag -r tip -T '{extras % "{key}\n" % "{key}\n"}'
37499
75c13343cf38 templater: wrap result of '%' operation so it never looks like a thunk
Yuya Nishihara <yuya@tcha.org>
parents: 37418
diff changeset
   457
  hg: parse error: list of strings is not mappable
28349
7cb2f2438f85 templater: handle exception when applying map operator to non-iterable object
Yuya Nishihara <yuya@tcha.org>
parents: 28346
diff changeset
   458
  [255]
7cb2f2438f85 templater: handle exception when applying map operator to non-iterable object
Yuya Nishihara <yuya@tcha.org>
parents: 28346
diff changeset
   459
34330
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   460
Test new-style inline templating of non-list/dict type:
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   461
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   462
  $ hg log -R latesttag -r tip -T '{manifest}\n'
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   463
  11:2bc6e9006ce2
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   464
  $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n'
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   465
  string length: 15
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   466
  $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n'
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   467
  11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc
89aec1834a86 templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents: 34329
diff changeset
   468
34534
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   469
  $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}'
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   470
  branch: default
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   471
  $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}'
37404
7c902a8345ef templater: complain about invalid application of '%' operator (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 37229
diff changeset
   472
  hg: parse error: None is not iterable of mappings
34534
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   473
  [255]
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   474
  $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}'
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   475
  branch: default
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   476
  $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}'
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   477
  0:ce3cec86e6c2
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   478
  $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}'
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   479
  9:fbc7cd862e9c
b3073e175c17 templater: wrap get/min/max result so map operation can apply to element
Yuya Nishihara <yuya@tcha.org>
parents: 34330
diff changeset
   480
34535
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   481
Test dot operator precedence:
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   482
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   483
  $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n'
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   484
  (template
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   485
    (|
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   486
      (.
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   487
        (symbol 'manifest')
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   488
        (symbol 'node'))
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   489
      (symbol 'short'))
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   490
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   491
  * keywords: manifest, node, rev
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   492
  * functions: formatnode, short
34535
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   493
  89f4071fec70
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   494
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   495
 (the following examples are invalid, but seem natural in parsing POV)
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   496
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   497
  $ hg debugtemplate -R latesttag -r0 -v '{foo|bar.baz}\n' 2> /dev/null
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   498
  (template
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   499
    (|
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   500
      (symbol 'foo')
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   501
      (.
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   502
        (symbol 'bar')
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   503
        (symbol 'baz')))
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   504
    (string '\n'))
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   505
  [255]
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   506
  $ hg debugtemplate -R latesttag -r0 -v '{foo.bar()}\n' 2> /dev/null
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   507
  (template
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   508
    (.
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   509
      (symbol 'foo')
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   510
      (func
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   511
        (symbol 'bar')
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   512
        None))
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   513
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   514
  * keywords: foo
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   515
  * functions: bar
34535
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   516
  [255]
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   517
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   518
Test evaluation of dot operator:
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   519
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   520
  $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n'
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   521
  ce3cec86e6c26bd9bdfc590a6b92abc9680f1796
34536
4c1cfe54c08d templater: extend dot operator as a short for get(dict, key)
Yuya Nishihara <yuya@tcha.org>
parents: 34535
diff changeset
   522
  $ hg log -R latesttag -r0 -T '{extras.branch}\n'
4c1cfe54c08d templater: extend dot operator as a short for get(dict, key)
Yuya Nishihara <yuya@tcha.org>
parents: 34535
diff changeset
   523
  default
38286
851fc9d42d6d templater: make date wrapper support dot/map operations
Yuya Nishihara <yuya@tcha.org>
parents: 38285
diff changeset
   524
  $ hg log -R latesttag -r0 -T '{date.unixtime} {localdate(date, "+0200").tzoffset}\n'
851fc9d42d6d templater: make date wrapper support dot/map operations
Yuya Nishihara <yuya@tcha.org>
parents: 38285
diff changeset
   525
  0 -7200
34535
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   526
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   527
  $ hg log -R latesttag -l1 -T '{author.invalid}\n'
38243
06d11cd90516 templater: promote getmember() to an interface of wrapped types
Yuya Nishihara <yuya@tcha.org>
parents: 38229
diff changeset
   528
  hg: parse error: 'test' is not a dictionary
06d11cd90516 templater: promote getmember() to an interface of wrapped types
Yuya Nishihara <yuya@tcha.org>
parents: 38229
diff changeset
   529
  (keyword 'author' does not support member operation)
34535
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   530
  [255]
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   531
  $ hg log -R latesttag -l1 -T '{min("abc").invalid}\n'
38243
06d11cd90516 templater: promote getmember() to an interface of wrapped types
Yuya Nishihara <yuya@tcha.org>
parents: 38229
diff changeset
   532
  hg: parse error: 'a' is not a dictionary
34535
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   533
  [255]
78590585c0db templater: add dot operator to easily access a sub item
Yuya Nishihara <yuya@tcha.org>
parents: 34534
diff changeset
   534
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   535
Test integer literal:
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   536
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   537
  $ hg debugtemplate -v '{(0)}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   538
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   539
    (group
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   540
      (integer '0'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   541
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   542
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   543
  * functions: 
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   544
  0
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   545
  $ hg debugtemplate -v '{(123)}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   546
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   547
    (group
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   548
      (integer '123'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   549
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   550
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   551
  * functions: 
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   552
  123
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   553
  $ hg debugtemplate -v '{(-4)}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   554
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   555
    (group
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   556
      (negate
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   557
        (integer '4')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   558
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   559
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   560
  * functions: 
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   561
  -4
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   562
  $ hg debugtemplate '{(-)}\n'
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   563
  hg: parse error at 3: not a prefix: )
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   564
  ({(-)}\n
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   565
      ^ here)
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   566
  [255]
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   567
  $ hg debugtemplate '{(-a)}\n'
30115
8e42dfde93d1 templater: provide arithmetic operations on integers
Simon Farnsworth <simonfar@fb.com>
parents: 30088
diff changeset
   568
  hg: parse error: negation needs an integer argument
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   569
  [255]
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   570
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   571
top-level integer literal is interpreted as symbol (i.e. variable name):
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   572
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   573
  $ hg debugtemplate -D 1=one -v '{1}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   574
  (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   575
    (integer '1')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   576
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   577
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   578
  * functions: 
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   579
  one
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   580
  $ hg debugtemplate -D 1=one -v '{if("t", "{1}")}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   581
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   582
    (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   583
      (symbol 'if')
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   584
      (list
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   585
        (string 't')
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   586
        (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   587
          (integer '1'))))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   588
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   589
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   590
  * functions: if
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   591
  one
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   592
  $ hg debugtemplate -D 1=one -v '{1|stringify}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   593
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   594
    (|
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   595
      (integer '1')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   596
      (symbol 'stringify'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   597
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   598
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   599
  * functions: stringify
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   600
  one
25002
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   601
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   602
unless explicit symbol is expected:
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   603
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   604
  $ hg log -Ra -r0 -T '{desc|1}\n'
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   605
  hg: parse error: expected a symbol, got 'integer'
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   606
  [255]
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   607
  $ hg log -Ra -r0 -T '{1()}\n'
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   608
  hg: parse error: expected a symbol, got 'integer'
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   609
  [255]
829faf8ab605 templater: tokenize decimal integer literal (issue4638) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24985
diff changeset
   610
25596
c1975809a6b5 templater: take any string literals as template, but not for rawstring (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25580
diff changeset
   611
Test string literal:
c1975809a6b5 templater: take any string literals as template, but not for rawstring (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25580
diff changeset
   612
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   613
  $ hg debugtemplate -Ra -r0 -v '{"string with no template fragment"}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   614
  (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   615
    (string 'string with no template fragment')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   616
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   617
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   618
  * functions: 
25596
c1975809a6b5 templater: take any string literals as template, but not for rawstring (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25580
diff changeset
   619
  string with no template fragment
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   620
  $ hg debugtemplate -Ra -r0 -v '{"template: {rev}"}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   621
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   622
    (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   623
      (string 'template: ')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   624
      (symbol 'rev'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   625
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   626
  * keywords: rev
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   627
  * functions: 
25596
c1975809a6b5 templater: take any string literals as template, but not for rawstring (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25580
diff changeset
   628
  template: 0
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   629
  $ hg debugtemplate -Ra -r0 -v '{r"rawstring: {rev}"}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   630
  (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   631
    (string 'rawstring: {rev}')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   632
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   633
  * keywords: 
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   634
  * functions: 
25596
c1975809a6b5 templater: take any string literals as template, but not for rawstring (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25580
diff changeset
   635
  rawstring: {rev}
28548
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   636
  $ hg debugtemplate -Ra -r0 -v '{files % r"rawstring: {file}"}\n'
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   637
  (template
b7a31068cc80 templater: add debugtemplate command
Yuya Nishihara <yuya@tcha.org>
parents: 28546
diff changeset
   638
    (%
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   639
      (symbol 'files')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   640
      (string 'rawstring: {file}'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   641
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   642
  * keywords: files
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   643
  * functions: 
28546
1987ed32efca templater: relax type of mapped template
Yuya Nishihara <yuya@tcha.org>
parents: 28374
diff changeset
   644
  rawstring: {file}
25597
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   645
20066
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   646
Test string escaping:
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   647
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   648
  $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   649
  >
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   650
  <>\n<[>
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   651
  <>\n<]>
64b4f0cd7336 templater: fix escaping in nested string literals (issue4102)
Matt Mackall <mpm@selenic.com>
parents: 19770
diff changeset
   652
  <>\n<
20067
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   653
24948
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   654
  $ hg log -R latesttag -r 0 \
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   655
  > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   656
  >
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   657
  <>\n<[>
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   658
  <>\n<]>
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   659
  <>\n<
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   660
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   661
  $ hg log -R latesttag -r 0 -T esc \
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   662
  > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   663
  >
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   664
  <>\n<[>
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   665
  <>\n<]>
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   666
  <>\n<
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   667
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   668
  $ cat <<'EOF' > esctmpl
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   669
  > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   670
  > EOF
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   671
  $ hg log -R latesttag -r 0 --style ./esctmpl
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   672
  >
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   673
  <>\n<[>
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   674
  <>\n<]>
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   675
  <>\n<
db7463aa080f templater: do not process \-escapes at parsestring() (issue4290)
Yuya Nishihara <yuya@tcha.org>
parents: 24903
diff changeset
   676
25638
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   677
Test string escaping of quotes:
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   678
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   679
  $ hg log -Ra -r0 -T '{"\""}\n'
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   680
  "
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   681
  $ hg log -Ra -r0 -T '{"\\\""}\n'
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   682
  \"
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   683
  $ hg log -Ra -r0 -T '{r"\""}\n'
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   684
  \"
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   685
  $ hg log -Ra -r0 -T '{r"\\\""}\n'
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   686
  \\\"
6047b60cdd09 templater: fix handling of \-escapes in raw string literals
Yuya Nishihara <yuya@tcha.org>
parents: 25637
diff changeset
   687
25695
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   688
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   689
  $ hg log -Ra -r0 -T '{"\""}\n'
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   690
  "
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   691
  $ hg log -Ra -r0 -T '{"\\\""}\n'
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   692
  \"
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   693
  $ hg log -Ra -r0 -T '{r"\""}\n'
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   694
  \"
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   695
  $ hg log -Ra -r0 -T '{r"\\\""}\n'
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   696
  \\\"
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   697
24966
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   698
Test exception in quoted template. single backslash before quotation mark is
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   699
stripped before parsing:
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   700
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   701
  $ cat <<'EOF' > escquotetmpl
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   702
  > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n"
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   703
  > EOF
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   704
  $ cd latesttag
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   705
  $ hg log -r 2 --style ../escquotetmpl
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   706
  " \" \" \\" head1
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   707
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   708
  $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"'
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   709
  valid
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   710
  $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'"
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   711
  valid
25695
ce3d4b858420 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 25676 25662
diff changeset
   712
25676
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   713
Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   714
_evalifliteral() templates (issue4733):
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   715
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   716
  $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   717
  "2
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   718
  $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   719
  "2
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   720
  $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   721
  "2
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   722
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   723
  $ hg log -r 2 -T '{if(rev, "\\\"")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   724
  \"
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   725
  $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   726
  \"
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   727
  $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   728
  \"
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   729
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   730
  $ hg log -r 2 -T '{if(rev, r"\\\"")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   731
  \\\"
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   732
  $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   733
  \\\"
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   734
  $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   735
  \\\"
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   736
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   737
escaped single quotes and errors:
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   738
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   739
  $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   740
  foo
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   741
  $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n'
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   742
  foo
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   743
  $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n'
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   744
  hg: parse error at 21: unterminated string
36669
80d7fb6c2dec templater: add hint to template parse errors to help locate issues
Ryan McElroy <rmcelroy@fb.com>
parents: 36635
diff changeset
   745
  ({if(rev, "{if(rev, \")}")}\n
36691
1b179d151578 templater: fix position of terminator character in error message
Yuya Nishihara <yuya@tcha.org>
parents: 36669
diff changeset
   746
                        ^ here)
25676
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   747
  [255]
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   748
  $ hg log -r 2 -T '{if(rev, \"\\"")}\n'
26215
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   749
  hg: parse error: trailing \ in string
25676
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   750
  [255]
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   751
  $ hg log -r 2 -T '{if(rev, r\"\\"")}\n'
26215
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   752
  hg: parse error: trailing \ in string
25676
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   753
  [255]
ec9c258e666d templater: parse \"...\" as string for 2.9.2-3.4 compatibility (issue4733)
Yuya Nishihara <yuya@tcha.org>
parents: 25638
diff changeset
   754
24966
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   755
  $ cd ..
554d6fcc3c84 templater: strip single backslash before quotation mark in quoted template
Yuya Nishihara <yuya@tcha.org>
parents: 24951
diff changeset
   756
24949
890845af1ac2 templater: strictly parse leading backslashes of '{' (issue4569) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24948
diff changeset
   757
Test leading backslashes:
890845af1ac2 templater: strictly parse leading backslashes of '{' (issue4569) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24948
diff changeset
   758
890845af1ac2 templater: strictly parse leading backslashes of '{' (issue4569) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24948
diff changeset
   759
  $ cd latesttag
25597
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   760
  $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n'
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   761
  {rev} {file}
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   762
  $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n'
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   763
  \2 \head1
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   764
  $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n'
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   765
  \{rev} \{file}
24949
890845af1ac2 templater: strictly parse leading backslashes of '{' (issue4569) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24948
diff changeset
   766
  $ cd ..
890845af1ac2 templater: strictly parse leading backslashes of '{' (issue4569) (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 24948
diff changeset
   767
25471
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   768
Test leading backslashes in "if" expression (issue4714):
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   769
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   770
  $ cd latesttag
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   771
  $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n'
25597
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   772
  {rev} \{rev}
25471
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   773
  $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n'
25597
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   774
  \2 \\{rev}
25471
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   775
  $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n'
25597
fd5bc660c9f0 templater: do not reevaluate rawstring as template (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25596
diff changeset
   776
  \{rev} \\\{rev}
25471
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   777
  $ cd ..
7298da81f5a9 templater: do not preprocess template string in "if" expression (issue4714)
Yuya Nishihara <yuya@tcha.org>
parents: 24949
diff changeset
   778
20663
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   779
"string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   780
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   781
  $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   782
  \x6e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   783
  $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   784
  \x5c\x786e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   785
  $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   786
  \x6e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   787
  $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   788
  \x5c\x786e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   789
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   790
  $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   791
  \x6e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   792
  $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   793
  \x5c\x786e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   794
  $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   795
  \x6e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   796
  $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   797
  \x5c\x786e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   798
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   799
  $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   800
  fourth
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   801
  second
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   802
  third
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   803
  $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   804
  fourth\nsecond\nthird
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   805
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   806
  $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   807
  <p>
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   808
  1st
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   809
  </p>
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   810
  <p>
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   811
  2nd
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   812
  </p>
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   813
  $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   814
  <p>
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   815
  1st\n\n2nd
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   816
  </p>
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   817
  $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   818
  1st
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   819
  
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   820
  2nd
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   821
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   822
  $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   823
  o perso
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   824
  $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   825
  no person
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   826
  $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   827
  o perso
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   828
  $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   829
  no perso
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   830
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   831
  $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   832
  -o perso-
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   833
  $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   834
  no person
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   835
  $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   836
  \x2do perso\x2d
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   837
  $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   838
  -o perso-
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   839
  $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   840
  \x2do perso\x6e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   841
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   842
  $ hg log -R a -r 8 --template '{files % "{file}\n"}'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   843
  fourth
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   844
  second
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   845
  third
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   846
21024
7731a2281cf0 spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents: 20860
diff changeset
   847
Test string escaping in nested expression:
20663
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   848
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   849
  $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   850
  fourth\x6esecond\x6ethird
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   851
  $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   852
  fourth\x6esecond\x6ethird
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   853
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   854
  $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   855
  fourth\x6esecond\x6ethird
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   856
  $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   857
  fourth\x5c\x786esecond\x5c\x786ethird
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   858
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   859
  $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   860
  3:\x6eo user, \x6eo domai\x6e
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   861
  4:\x5c\x786eew bra\x5c\x786ech
5ab28a2e9962 templater: make strings in template expressions be "string-escape"-ed correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20662
diff changeset
   862
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   863
Test quotes in nested expression are evaluated just like a $(command)
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   864
substitution in POSIX shells:
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   865
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   866
  $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n'
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   867
  8:95c24699272e
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   868
  $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n'
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   869
  {8} "95c24699272e"
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25782
diff changeset
   870
20067
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   871
Test recursive evaluation:
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   872
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   873
  $ hg init r
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   874
  $ cd r
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   875
  $ echo a > a
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   876
  $ hg ci -Am '{rev}'
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   877
  adding a
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   878
  $ hg log -r 0 --template '{if(rev, desc)}\n'
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   879
  {rev}
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   880
  $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n'
3d8bfe2ecf6d templater: only recursively evaluate string literals as templates (issue4103)
Matt Mackall <mpm@selenic.com>
parents: 20066
diff changeset
   881
  test 0
20076
faa4b3fc4197 templater: makes branches work correctly with stringify (issue4108)
Matt Mackall <mpm@selenic.com>
parents: 20067
diff changeset
   882
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   883
  $ hg branch -q 'text.{rev}'
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   884
  $ echo aa >> aa
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   885
  $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   886
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   887
  $ hg log -l1 --template '{fill(desc, "20", author, branch)}'
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   888
  {node|short}desc to
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   889
  text.{rev}be wrapped
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   890
  text.{rev}desc to be
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   891
  text.{rev}wrapped (no-eol)
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   892
  $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}'
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   893
  bcc7ff960b8e:desc to
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   894
  text.1:be wrapped
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   895
  text.1:desc to be
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   896
  text.1:wrapped (no-eol)
28344
ac371d4c007f templater: drop redundant type conversion when evaluating integer argument
Yuya Nishihara <yuya@tcha.org>
parents: 28333
diff changeset
   897
  $ hg log -l1 -T '{fill(desc, date, "", "")}\n'
ac371d4c007f templater: drop redundant type conversion when evaluating integer argument
Yuya Nishihara <yuya@tcha.org>
parents: 28333
diff changeset
   898
  hg: parse error: fill expects an integer width
ac371d4c007f templater: drop redundant type conversion when evaluating integer argument
Yuya Nishihara <yuya@tcha.org>
parents: 28333
diff changeset
   899
  [255]
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   900
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   901
  $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}'
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   902
  {node|short} (no-eol)
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   903
  $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}'
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   904
  bcc-ff---b-e (no-eol)
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   905
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   906
  $ cat >> .hg/hgrc <<EOF
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   907
  > [extensions]
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   908
  > color=
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   909
  > [color]
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   910
  > mode=ansi
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   911
  > text.{rev} = red
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   912
  > text.1 = green
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   913
  > EOF
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   914
  $ hg log --color=always -l 1 --template '{label(branch, "text\n")}'
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   915
  \x1b[0;31mtext\x1b[0m (esc)
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   916
  $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}'
20661
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   917
  \x1b[0;32mtext\x1b[0m (esc)
7e627fe63e5e templater: avoid recursive evaluation of string literals completely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20079
diff changeset
   918
20670
0084fcd5d7e2 merge with stable
Matt Mackall <mpm@selenic.com>
parents: 20668 20663
diff changeset
   919
  $ cd ..
21822
028a48105191 templater: add symbol to error
Ryan McElroy <rmcelroy@fb.com>
parents: 21821
diff changeset
   920
028a48105191 templater: add symbol to error
Ryan McElroy <rmcelroy@fb.com>
parents: 21821
diff changeset
   921
Test bad template with better error message
028a48105191 templater: add symbol to error
Ryan McElroy <rmcelroy@fb.com>
parents: 21821
diff changeset
   922
028a48105191 templater: add symbol to error
Ryan McElroy <rmcelroy@fb.com>
parents: 21821
diff changeset
   923
  $ hg log -Gv -R a --template '{desc|user()}'
028a48105191 templater: add symbol to error
Ryan McElroy <rmcelroy@fb.com>
parents: 21821
diff changeset
   924
  hg: parse error: expected a symbol, got 'func'
028a48105191 templater: add symbol to error
Ryan McElroy <rmcelroy@fb.com>
parents: 21821
diff changeset
   925
  [255]
21846
8f23f8096606 templater: introduce word function
Ryan McElroy <rmcelroy@fb.com>
parents: 21822
diff changeset
   926
26215
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   927
Test broken string escapes:
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   928
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   929
  $ hg log -T "bogus\\" -R a
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   930
  hg: parse error: trailing \ in string
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   931
  [255]
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   932
  $ hg log -T "\\xy" -R a
36635
e80f8a134731 test-command-template: glob out detailed "invalid escape" message
Yuya Nishihara <yuya@tcha.org>
parents: 36548
diff changeset
   933
  hg: parse error: invalid \x escape* (glob)
26215
72aad184f061 templater: create string unescape helper (issue4798)
Matt Mackall <mpm@selenic.com>
parents: 26188
diff changeset
   934
  [255]
26856
baa77652be68 templatefilters: try round-trip utf-8 conversion by json filter (issue4933)
Yuya Nishihara <yuya@tcha.org>
parents: 26504
diff changeset
   935
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   936
Templater supports aliases of symbol and func() styles:
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   937
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   938
  $ hg clone -q a aliases
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   939
  $ cd aliases
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   940
  $ cat <<EOF >> .hg/hgrc
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   941
  > [templatealias]
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   942
  > r = rev
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   943
  > rn = "{r}:{node|short}"
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   944
  > status(c, files) = files % "{c} {file}\n"
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   945
  > utcdate(d) = localdate(d, "UTC")
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   946
  > EOF
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   947
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   948
  $ hg debugtemplate -vr0 '{rn} {utcdate(date)|isodate}\n'
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   949
  (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   950
    (symbol 'rn')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   951
    (string ' ')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   952
    (|
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   953
      (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   954
        (symbol 'utcdate')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   955
        (symbol 'date'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   956
      (symbol 'isodate'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   957
    (string '\n'))
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   958
  * expanded:
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   959
  (template
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   960
    (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   961
      (symbol 'rev')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   962
      (string ':')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   963
      (|
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   964
        (symbol 'node')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   965
        (symbol 'short')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   966
    (string ' ')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   967
    (|
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   968
      (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   969
        (symbol 'localdate')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   970
        (list
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   971
          (symbol 'date')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   972
          (string 'UTC')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   973
      (symbol 'isodate'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   974
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   975
  * keywords: date, node, rev
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   976
  * functions: isodate, localdate, short
28957
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
   977
  0:1e4e1b8f71e0 1970-01-12 13:46 +0000
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   978
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   979
  $ hg debugtemplate -vr0 '{status("A", file_adds)}'
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   980
  (template
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   981
    (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   982
      (symbol 'status')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   983
      (list
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   984
        (string 'A')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   985
        (symbol 'file_adds'))))
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   986
  * expanded:
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   987
  (template
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   988
    (%
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   989
      (symbol 'file_adds')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   990
      (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   991
        (string 'A')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   992
        (string ' ')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   993
        (symbol 'file')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
   994
        (string '\n'))))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   995
  * keywords: file, file_adds
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
   996
  * functions: 
28957
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
   997
  A a
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   998
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
   999
A unary function alias can be called as a filter:
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1000
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1001
  $ hg debugtemplate -vr0 '{date|utcdate|isodate}\n'
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1002
  (template
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1003
    (|
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1004
      (|
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1005
        (symbol 'date')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1006
        (symbol 'utcdate'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1007
      (symbol 'isodate'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1008
    (string '\n'))
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1009
  * expanded:
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1010
  (template
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1011
    (|
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1012
      (func
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1013
        (symbol 'localdate')
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1014
        (list
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1015
          (symbol 'date')
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1016
          (string 'UTC')))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1017
      (symbol 'isodate'))
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1018
    (string '\n'))
38355
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
  1019
  * keywords: date
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38299
diff changeset
  1020
  * functions: isodate, localdate
28957
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1021
  1970-01-12 13:46 +0000
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1022
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1023
Aliases should be applied only to command arguments and templates in hgrc.
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1024
Otherwise, our stock styles and web templates could be corrupted:
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1025
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1026
  $ hg log -r0 -T '{rn} {utcdate(date)|isodate}\n'
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1027
  0:1e4e1b8f71e0 1970-01-12 13:46 +0000
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1028
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1029
  $ hg log -r0 --config ui.logtemplate='"{rn} {utcdate(date)|isodate}\n"'
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1030
  0:1e4e1b8f71e0 1970-01-12 13:46 +0000
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1031
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1032
  $ cat <<EOF > tmpl
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1033
  > changeset = 'nothing expanded:{rn}\n'
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1034
  > EOF
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1035
  $ hg log -r0 --style ./tmpl
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1036
  nothing expanded:
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1037
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1038
Aliases in formatter:
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1039
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1040
  $ hg branches -T '{pad(branch, 7)} {rn}\n'
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1041
  default 6:d41e714fe50d
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1042
  foo     4:bbe44766e73d
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1043
28958
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1044
Aliases should honor HGPLAIN:
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1045
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1046
  $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n'
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1047
  nothing expanded:
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1048
  $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n'
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1049
  0:1e4e1b8f71e0
77e566fe31ec ui: drop template aliases by HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 28957
diff changeset
  1050
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1051
Unparsable alias:
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1052
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1053
  $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}'
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1054
  (template
34073
7bbc4e113e5f parser: stabilize output of prettyformat() by using byte-safe repr()
Yuya Nishihara <yuya@tcha.org>
parents: 33950
diff changeset
  1055
    (symbol 'bad'))
29059
8eba4cdcfd81 parser: shorten prefix of alias parsing errors
Yuya Nishihara <yuya@tcha.org>
parents: 28958
diff changeset
  1056
  abort: bad definition of template alias "bad": at 2: not a prefix: end
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1057
  [255]
28957
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1058
  $ hg log --config templatealias.bad='x(' -T '{bad}'
29059
8eba4cdcfd81 parser: shorten prefix of alias parsing errors
Yuya Nishihara <yuya@tcha.org>
parents: 28958
diff changeset
  1059
  abort: bad definition of template alias "bad": at 2: not a prefix: end
28957
d813132ea361 templater: load and expand aliases by template engine (API) (issue4842)
Yuya Nishihara <yuya@tcha.org>
parents: 28912
diff changeset
  1060
  [255]
28912
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1061
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1062
  $ cd ..
867d6ba2353d templater: add parsing and expansion rules to process "templatealias" section
Yuya Nishihara <yuya@tcha.org>
parents: 28695
diff changeset
  1063
28695
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1064
Test that template function in extension is registered as expected
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1065
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1066
  $ cd a
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1067
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1068
  $ cat <<EOF > $TESTTMP/customfunc.py
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1069
  > from mercurial import registrar
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1070
  > 
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1071
  > templatefunc = registrar.templatefunc()
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1072
  > 
36548
086fc71fbb09 py3: mark all string literals in test-command-template.t as bytes
Yuya Nishihara <yuya@tcha.org>
parents: 36542
diff changeset
  1073
  > @templatefunc(b'custom()')
28695
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1074
  > def custom(context, mapping, args):
36548
086fc71fbb09 py3: mark all string literals in test-command-template.t as bytes
Yuya Nishihara <yuya@tcha.org>
parents: 36542
diff changeset
  1075
  >     return b'custom'
28695
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1076
  > EOF
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1077
  $ cat <<EOF > .hg/hgrc
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1078
  > [extensions]
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1079
  > customfunc = $TESTTMP/customfunc.py
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1080
  > EOF
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1081
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1082
  $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1083
  custom
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1084
cc103bd0dbf9 registrar: add templatefunc to mark a function as template function (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28687
diff changeset
  1085
  $ cd ..