tests/test-grep.t
author Jun Wu <quark@fb.com>
Mon, 19 Mar 2018 04:28:29 -0700
changeset 37730 8d730f96e792
parent 37500 8bb3899a0f47
child 37770 31750413f8d7
permissions -rw-r--r--
patch: move yielding "\n" to the end of loop The original logic makes it harder to reason about - it yields the "\n" character belonging to the last line in the next loop iteration. The new code is in theory a little bit slower. But is more readable. It makes the following changes easier to read. Differential Revision: https://phab.mercurial-scm.org/D3210
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13956
ffb5c09ba822 tests: remove redundant mkdir
Martin Geisler <mg@lazybytes.net>
parents: 13920
diff changeset
     1
  $ hg init t
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     2
  $ cd t
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     3
  $ echo import > port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     4
  $ hg add port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     5
  $ hg commit -m 0 -u spam -d '0 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     6
  $ echo export >> port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     7
  $ hg commit -m 1 -u eggs -d '1 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     8
  $ echo export > port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
     9
  $ echo vaportight >> port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    10
  $ echo 'import/export' >> port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    11
  $ hg commit -m 2 -u spam -d '2 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    12
  $ echo 'import/export' >> port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    13
  $ hg commit -m 3 -u eggs -d '3 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    14
  $ head -n 3 port > port1
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    15
  $ mv port1 port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    16
  $ hg commit -m 4 -u spam -d '4 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    17
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    18
pattern error
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    19
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    20
  $ hg grep '**test**'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    21
  grep: invalid match pattern: nothing to repeat
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11902
diff changeset
    22
  [1]
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    23
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    24
simple
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    25
17923
1e6b5faf9d4e grep: don't search past the end of the searched string
Idan Kamara <idankk86@gmail.com>
parents: 17806
diff changeset
    26
  $ hg grep '.*'
1e6b5faf9d4e grep: don't search past the end of the searched string
Idan Kamara <idankk86@gmail.com>
parents: 17806
diff changeset
    27
  port:4:export
1e6b5faf9d4e grep: don't search past the end of the searched string
Idan Kamara <idankk86@gmail.com>
parents: 17806
diff changeset
    28
  port:4:vaportight
1e6b5faf9d4e grep: don't search past the end of the searched string
Idan Kamara <idankk86@gmail.com>
parents: 17806
diff changeset
    29
  port:4:import/export
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    30
  $ hg grep port port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    31
  port:4:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    32
  port:4:vaportight
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    33
  port:4:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    34
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    35
simple with color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    36
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    37
  $ hg --config extensions.color= grep --config color.mode=ansi \
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
    38
  >     --color=always port port
17806
dc7010ed0101 grep: colorize all fields
Idan Kamara <idankk86@gmail.com>
parents: 17805
diff changeset
    39
  \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
dc7010ed0101 grep: colorize all fields
Idan Kamara <idankk86@gmail.com>
parents: 17805
diff changeset
    40
  \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
21011
2db41f95c4a2 grep: highlight all matched words
Takumi IINO <trot.thunder@gmail.com>
parents: 17923
diff changeset
    41
  \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    42
29858
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    43
simple templated
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    44
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    45
  $ hg grep port \
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    46
  > -T '{file}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n'
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    47
  port:4:914fa752cdea:exPORT
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    48
  port:4:914fa752cdea:vaPORTight
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    49
  port:4:914fa752cdea:imPORT/exPORT
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    50
37500
8bb3899a0f47 formatter: make nested items somewhat readable in template output
Yuya Nishihara <yuya@tcha.org>
parents: 37449
diff changeset
    51
  $ hg grep port -T '{file}:{rev}:{texts}\n'
8bb3899a0f47 formatter: make nested items somewhat readable in template output
Yuya Nishihara <yuya@tcha.org>
parents: 37449
diff changeset
    52
  port:4:export
8bb3899a0f47 formatter: make nested items somewhat readable in template output
Yuya Nishihara <yuya@tcha.org>
parents: 37449
diff changeset
    53
  port:4:vaportight
8bb3899a0f47 formatter: make nested items somewhat readable in template output
Yuya Nishihara <yuya@tcha.org>
parents: 37449
diff changeset
    54
  port:4:import/export
8bb3899a0f47 formatter: make nested items somewhat readable in template output
Yuya Nishihara <yuya@tcha.org>
parents: 37449
diff changeset
    55
29858
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    56
simple JSON (no "change" field)
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    57
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    58
  $ hg grep -Tjson port
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    59
  [
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    60
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    61
    "date": [4.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    62
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    63
    "line_number": 1,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    64
    "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    65
    "rev": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    66
    "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    67
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    68
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    69
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    70
    "date": [4.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    71
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    72
    "line_number": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    73
    "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    74
    "rev": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    75
    "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    76
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    77
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    78
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    79
    "date": [4.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    80
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    81
    "line_number": 3,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    82
    "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    83
    "rev": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    84
    "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    85
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    86
   }
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    87
  ]
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    88
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    89
simple JSON without matching lines
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    90
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    91
  $ hg grep -Tjson -l port
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    92
  [
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    93
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    94
    "date": [4.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    95
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    96
    "line_number": 1,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    97
    "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    98
    "rev": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
    99
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   100
   }
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   101
  ]
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   102
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   103
all
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   104
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   105
  $ hg grep --traceback --all -nu port port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   106
  port:4:4:-:spam:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   107
  port:3:4:+:eggs:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   108
  port:2:1:-:spam:import
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   109
  port:2:2:-:spam:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   110
  port:2:1:+:spam:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   111
  port:2:2:+:spam:vaportight
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   112
  port:2:3:+:spam:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   113
  port:1:2:+:eggs:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   114
  port:0:1:+:spam:import
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   115
29858
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   116
all JSON
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   117
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   118
  $ hg grep --all -Tjson port port
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   119
  [
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   120
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   121
    "change": "-",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   122
    "date": [4.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   123
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   124
    "line_number": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   125
    "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   126
    "rev": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   127
    "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   128
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   129
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   130
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   131
    "change": "+",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   132
    "date": [3.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   133
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   134
    "line_number": 4,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   135
    "node": "95040cfd017d658c536071c6290230a613c4c2a6",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   136
    "rev": 3,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   137
    "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   138
    "user": "eggs"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   139
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   140
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   141
    "change": "-",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   142
    "date": [2.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   143
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   144
    "line_number": 1,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   145
    "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   146
    "rev": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   147
    "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   148
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   149
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   150
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   151
    "change": "-",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   152
    "date": [2.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   153
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   154
    "line_number": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   155
    "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   156
    "rev": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   157
    "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   158
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   159
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   160
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   161
    "change": "+",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   162
    "date": [2.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   163
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   164
    "line_number": 1,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   165
    "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   166
    "rev": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   167
    "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   168
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   169
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   170
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   171
    "change": "+",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   172
    "date": [2.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   173
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   174
    "line_number": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   175
    "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   176
    "rev": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   177
    "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   178
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   179
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   180
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   181
    "change": "+",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   182
    "date": [2.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   183
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   184
    "line_number": 3,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   185
    "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   186
    "rev": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   187
    "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   188
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   189
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   190
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   191
    "change": "+",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   192
    "date": [1.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   193
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   194
    "line_number": 2,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   195
    "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   196
    "rev": 1,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   197
    "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   198
    "user": "eggs"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   199
   },
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   200
   {
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   201
    "change": "+",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   202
    "date": [0.0, 0],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   203
    "file": "port",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   204
    "line_number": 1,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   205
    "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   206
    "rev": 0,
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   207
    "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   208
    "user": "spam"
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   209
   }
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   210
  ]
33461139c31c grep: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents: 29854
diff changeset
   211
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   212
other
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   213
17805
21c93988ca70 test-grep: add a test for -l
Idan Kamara <idankk86@gmail.com>
parents: 16912
diff changeset
   214
  $ hg grep -l port port
21c93988ca70 test-grep: add a test for -l
Idan Kamara <idankk86@gmail.com>
parents: 16912
diff changeset
   215
  port:4
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   216
  $ hg grep import port
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   217
  port:4:import/export
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
   218
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   219
  $ hg cp port port2
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   220
  $ hg commit -m 4 -u spam -d '5 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   221
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   222
follow
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   223
15765
1ef46bcd76f8 grep: make multiline mode the default (BC)
Matt Mackall <mpm@selenic.com>
parents: 15293
diff changeset
   224
  $ hg grep --traceback -f 'import\n\Z' port2
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   225
  port:0:import
15765
1ef46bcd76f8 grep: make multiline mode the default (BC)
Matt Mackall <mpm@selenic.com>
parents: 15293
diff changeset
   226
  
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   227
  $ echo deport >> port2
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   228
  $ hg commit -m 5 -u eggs -d '6 0'
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   229
  $ hg grep -f --all -nu port port2
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   230
  port2:6:4:+:eggs:deport
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   231
  port:4:4:-:spam:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   232
  port:3:4:+:eggs:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   233
  port:2:1:-:spam:import
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   234
  port:2:2:-:spam:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   235
  port:2:1:+:spam:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   236
  port:2:2:+:spam:vaportight
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   237
  port:2:3:+:spam:import/export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   238
  port:1:2:+:eggs:export
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   239
  port:0:1:+:spam:import
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
   240
24064
c260887cdbcd log: fix --follow null parent not to include revision 0
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
   241
  $ hg up -q null
c260887cdbcd log: fix --follow null parent not to include revision 0
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
   242
  $ hg grep -f port
c260887cdbcd log: fix --follow null parent not to include revision 0
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
   243
  [1]
c260887cdbcd log: fix --follow null parent not to include revision 0
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
   244
37447
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   245
Test wdir
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   246
(at least, this shouldn't crash)
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   247
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   248
  $ hg up -q
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   249
  $ echo wport >> port2
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   250
  $ hg stat
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   251
  M port2
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   252
  $ hg grep -r 'wdir()' port
37449
a0d71618074f revlog: detect pseudo file nodeids to raise WdirUnsupported exception
Yuya Nishihara <yuya@tcha.org>
parents: 37447
diff changeset
   253
  abort: working directory revision cannot be specified
37447
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   254
  [255]
067e8d1178a2 workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents: 37133
diff changeset
   255
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   256
  $ cd ..
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   257
  $ hg init t2
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   258
  $ cd t2
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   259
  $ hg grep foobar foo
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11902
diff changeset
   260
  [1]
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   261
  $ hg grep foobar
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11902
diff changeset
   262
  [1]
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   263
  $ echo blue >> color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   264
  $ echo black >> color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   265
  $ hg add color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   266
  $ hg ci -m 0
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   267
  $ echo orange >> color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   268
  $ hg ci -m 1
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   269
  $ echo black > color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   270
  $ hg ci -m 2
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   271
  $ echo orange >> color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   272
  $ echo blue >> color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   273
  $ hg ci -m 3
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   274
  $ hg grep orange
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   275
  color:3:orange
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   276
  $ hg grep --all orange
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   277
  color:3:+:orange
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   278
  color:2:-:orange
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   279
  color:1:+:orange
5106
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
   280
29854
b842b1adfea2 grep: refactor loop that yields matched text with label
Yuya Nishihara <yuya@tcha.org>
parents: 24064
diff changeset
   281
test substring match: '^' should only match at the beginning
b842b1adfea2 grep: refactor loop that yields matched text with label
Yuya Nishihara <yuya@tcha.org>
parents: 24064
diff changeset
   282
b842b1adfea2 grep: refactor loop that yields matched text with label
Yuya Nishihara <yuya@tcha.org>
parents: 24064
diff changeset
   283
  $ hg grep '^.' --config extensions.color= --color debug
b842b1adfea2 grep: refactor loop that yields matched text with label
Yuya Nishihara <yuya@tcha.org>
parents: 24064
diff changeset
   284
  [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
b842b1adfea2 grep: refactor loop that yields matched text with label
Yuya Nishihara <yuya@tcha.org>
parents: 24064
diff changeset
   285
  [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
b842b1adfea2 grep: refactor loop that yields matched text with label
Yuya Nishihara <yuya@tcha.org>
parents: 24064
diff changeset
   286
  [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   287
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   288
match in last "line" without newline
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   289
36495
eafd380fe1b8 py3: make sure we write bytes in a file open in bytes mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29858
diff changeset
   290
  $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   291
  $ hg ci -Amnoeol
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   292
  adding noeol
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   293
  $ hg grep loop
15293
0e34699d6988 grep: correct handling of matching lines without line ending (issue3050)
Mads Kiilerich <mads@kiilerich.com>
parents: 13956
diff changeset
   294
  noeol:4:no infinite loop
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   295
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   296
  $ cd ..
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   297
21024
7731a2281cf0 spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents: 21011
diff changeset
   298
Issue685: traceback in grep -r after rename
12399
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 12316
diff changeset
   299
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   300
Got a traceback when using grep on a single
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   301
revision with renamed files.
7240
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
   302
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   303
  $ hg init issue685
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   304
  $ cd issue685
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   305
  $ echo octarine > color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   306
  $ hg ci -Amcolor
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   307
  adding color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   308
  $ hg rename color colour
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   309
  $ hg ci -Am rename
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   310
  $ hg grep octarine
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   311
  colour:1:octarine
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   312
  color:0:octarine
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   313
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   314
Used to crash here
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   315
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   316
  $ hg grep -r 1 octarine
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   317
  colour:1:octarine
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   318
  $ cd ..
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   319
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   320
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   321
Issue337: test that grep follows parent-child relationships instead
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   322
of just using revision numbers.
7240
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
   323
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   324
  $ hg init issue337
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   325
  $ cd issue337
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
   326
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   327
  $ echo white > color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   328
  $ hg commit -A -m "0 white"
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   329
  adding color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   330
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   331
  $ echo red > color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   332
  $ hg commit -A -m "1 red"
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
   333
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   334
  $ hg update 0
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   335
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   336
  $ echo black > color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   337
  $ hg commit -A -m "2 black"
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   338
  created new head
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
   339
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   340
  $ hg update --clean 1
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   341
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   342
  $ echo blue > color
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   343
  $ hg commit -A -m "3 blue"
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
   344
11902
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   345
  $ hg grep --all red
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   346
  color:3:-:red
3c9a5ed9b1e2 tests: unify test-grep
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11141
diff changeset
   347
  color:1:+:red
13920
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   348
37133
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   349
Issue3885: test that changing revision order does not alter the
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   350
revisions printed, just their order.
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   351
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   352
  $ hg grep --all red -r "all()"
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   353
  color:1:+:red
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   354
  color:3:-:red
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   355
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   356
  $ hg grep --all red -r "reverse(all())"
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   357
  color:3:-:red
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   358
  color:1:+:red
a2a6755a3def grep: fixes erroneous output of grep in forward order (issue3885)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents: 36495
diff changeset
   359
16912
6ef3107c661e tests: cleanup of tests that got lost in their own nested directories
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
   360
  $ cd ..
6ef3107c661e tests: cleanup of tests that got lost in their own nested directories
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
   361
13920
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   362
  $ hg init a
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   363
  $ cd a
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 15765
diff changeset
   364
  $ cp "$TESTDIR/binfile.bin" .
13920
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   365
  $ hg add binfile.bin
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   366
  $ hg ci -m 'add binfile.bin'
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   367
  $ hg grep "MaCam" --all
332e400764e5 grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents: 12942
diff changeset
   368
  binfile.bin:0:+: Binary file matches
16912
6ef3107c661e tests: cleanup of tests that got lost in their own nested directories
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
   369
6ef3107c661e tests: cleanup of tests that got lost in their own nested directories
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
   370
  $ cd ..