##// END OF EJS Templates
grep: don't search past the end of the searched string...
Idan Kamara -
r17923:1e6b5faf default
parent child Browse files
Show More

The requested changes are too big and content was truncated. Show full diff

1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,178 +1,182 b''
1 $ hg init t
1 $ hg init t
2 $ cd t
2 $ cd t
3 $ echo import > port
3 $ echo import > port
4 $ hg add port
4 $ hg add port
5 $ hg commit -m 0 -u spam -d '0 0'
5 $ hg commit -m 0 -u spam -d '0 0'
6 $ echo export >> port
6 $ echo export >> port
7 $ hg commit -m 1 -u eggs -d '1 0'
7 $ hg commit -m 1 -u eggs -d '1 0'
8 $ echo export > port
8 $ echo export > port
9 $ echo vaportight >> port
9 $ echo vaportight >> port
10 $ echo 'import/export' >> port
10 $ echo 'import/export' >> port
11 $ hg commit -m 2 -u spam -d '2 0'
11 $ hg commit -m 2 -u spam -d '2 0'
12 $ echo 'import/export' >> port
12 $ echo 'import/export' >> port
13 $ hg commit -m 3 -u eggs -d '3 0'
13 $ hg commit -m 3 -u eggs -d '3 0'
14 $ head -n 3 port > port1
14 $ head -n 3 port > port1
15 $ mv port1 port
15 $ mv port1 port
16 $ hg commit -m 4 -u spam -d '4 0'
16 $ hg commit -m 4 -u spam -d '4 0'
17
17
18 pattern error
18 pattern error
19
19
20 $ hg grep '**test**'
20 $ hg grep '**test**'
21 grep: invalid match pattern: nothing to repeat
21 grep: invalid match pattern: nothing to repeat
22 [1]
22 [1]
23
23
24 simple
24 simple
25
25
26 $ hg grep '.*'
27 port:4:export
28 port:4:vaportight
29 port:4:import/export
26 $ hg grep port port
30 $ hg grep port port
27 port:4:export
31 port:4:export
28 port:4:vaportight
32 port:4:vaportight
29 port:4:import/export
33 port:4:import/export
30
34
31 simple with color
35 simple with color
32
36
33 $ hg --config extensions.color= grep --config color.mode=ansi \
37 $ hg --config extensions.color= grep --config color.mode=ansi \
34 > --color=always port port
38 > --color=always port port
35 \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)
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)
36 \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)
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)
37 \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/export (esc)
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/export (esc)
38
42
39 all
43 all
40
44
41 $ hg grep --traceback --all -nu port port
45 $ hg grep --traceback --all -nu port port
42 port:4:4:-:spam:import/export
46 port:4:4:-:spam:import/export
43 port:3:4:+:eggs:import/export
47 port:3:4:+:eggs:import/export
44 port:2:1:-:spam:import
48 port:2:1:-:spam:import
45 port:2:2:-:spam:export
49 port:2:2:-:spam:export
46 port:2:1:+:spam:export
50 port:2:1:+:spam:export
47 port:2:2:+:spam:vaportight
51 port:2:2:+:spam:vaportight
48 port:2:3:+:spam:import/export
52 port:2:3:+:spam:import/export
49 port:1:2:+:eggs:export
53 port:1:2:+:eggs:export
50 port:0:1:+:spam:import
54 port:0:1:+:spam:import
51
55
52 other
56 other
53
57
54 $ hg grep -l port port
58 $ hg grep -l port port
55 port:4
59 port:4
56 $ hg grep import port
60 $ hg grep import port
57 port:4:import/export
61 port:4:import/export
58
62
59 $ hg cp port port2
63 $ hg cp port port2
60 $ hg commit -m 4 -u spam -d '5 0'
64 $ hg commit -m 4 -u spam -d '5 0'
61
65
62 follow
66 follow
63
67
64 $ hg grep --traceback -f 'import\n\Z' port2
68 $ hg grep --traceback -f 'import\n\Z' port2
65 port:0:import
69 port:0:import
66
70
67 $ echo deport >> port2
71 $ echo deport >> port2
68 $ hg commit -m 5 -u eggs -d '6 0'
72 $ hg commit -m 5 -u eggs -d '6 0'
69 $ hg grep -f --all -nu port port2
73 $ hg grep -f --all -nu port port2
70 port2:6:4:+:eggs:deport
74 port2:6:4:+:eggs:deport
71 port:4:4:-:spam:import/export
75 port:4:4:-:spam:import/export
72 port:3:4:+:eggs:import/export
76 port:3:4:+:eggs:import/export
73 port:2:1:-:spam:import
77 port:2:1:-:spam:import
74 port:2:2:-:spam:export
78 port:2:2:-:spam:export
75 port:2:1:+:spam:export
79 port:2:1:+:spam:export
76 port:2:2:+:spam:vaportight
80 port:2:2:+:spam:vaportight
77 port:2:3:+:spam:import/export
81 port:2:3:+:spam:import/export
78 port:1:2:+:eggs:export
82 port:1:2:+:eggs:export
79 port:0:1:+:spam:import
83 port:0:1:+:spam:import
80
84
81 $ cd ..
85 $ cd ..
82 $ hg init t2
86 $ hg init t2
83 $ cd t2
87 $ cd t2
84 $ hg grep foobar foo
88 $ hg grep foobar foo
85 [1]
89 [1]
86 $ hg grep foobar
90 $ hg grep foobar
87 [1]
91 [1]
88 $ echo blue >> color
92 $ echo blue >> color
89 $ echo black >> color
93 $ echo black >> color
90 $ hg add color
94 $ hg add color
91 $ hg ci -m 0
95 $ hg ci -m 0
92 $ echo orange >> color
96 $ echo orange >> color
93 $ hg ci -m 1
97 $ hg ci -m 1
94 $ echo black > color
98 $ echo black > color
95 $ hg ci -m 2
99 $ hg ci -m 2
96 $ echo orange >> color
100 $ echo orange >> color
97 $ echo blue >> color
101 $ echo blue >> color
98 $ hg ci -m 3
102 $ hg ci -m 3
99 $ hg grep orange
103 $ hg grep orange
100 color:3:orange
104 color:3:orange
101 $ hg grep --all orange
105 $ hg grep --all orange
102 color:3:+:orange
106 color:3:+:orange
103 color:2:-:orange
107 color:2:-:orange
104 color:1:+:orange
108 color:1:+:orange
105
109
106
110
107 match in last "line" without newline
111 match in last "line" without newline
108
112
109 $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
113 $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
110 $ hg ci -Amnoeol
114 $ hg ci -Amnoeol
111 adding noeol
115 adding noeol
112 $ hg grep loop
116 $ hg grep loop
113 noeol:4:no infinite loop
117 noeol:4:no infinite loop
114
118
115 $ cd ..
119 $ cd ..
116
120
117 Issue685: trackback in grep -r after rename
121 Issue685: trackback in grep -r after rename
118
122
119 Got a traceback when using grep on a single
123 Got a traceback when using grep on a single
120 revision with renamed files.
124 revision with renamed files.
121
125
122 $ hg init issue685
126 $ hg init issue685
123 $ cd issue685
127 $ cd issue685
124 $ echo octarine > color
128 $ echo octarine > color
125 $ hg ci -Amcolor
129 $ hg ci -Amcolor
126 adding color
130 adding color
127 $ hg rename color colour
131 $ hg rename color colour
128 $ hg ci -Am rename
132 $ hg ci -Am rename
129 $ hg grep octarine
133 $ hg grep octarine
130 colour:1:octarine
134 colour:1:octarine
131 color:0:octarine
135 color:0:octarine
132
136
133 Used to crash here
137 Used to crash here
134
138
135 $ hg grep -r 1 octarine
139 $ hg grep -r 1 octarine
136 colour:1:octarine
140 colour:1:octarine
137 $ cd ..
141 $ cd ..
138
142
139
143
140 Issue337: test that grep follows parent-child relationships instead
144 Issue337: test that grep follows parent-child relationships instead
141 of just using revision numbers.
145 of just using revision numbers.
142
146
143 $ hg init issue337
147 $ hg init issue337
144 $ cd issue337
148 $ cd issue337
145
149
146 $ echo white > color
150 $ echo white > color
147 $ hg commit -A -m "0 white"
151 $ hg commit -A -m "0 white"
148 adding color
152 adding color
149
153
150 $ echo red > color
154 $ echo red > color
151 $ hg commit -A -m "1 red"
155 $ hg commit -A -m "1 red"
152
156
153 $ hg update 0
157 $ hg update 0
154 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
155 $ echo black > color
159 $ echo black > color
156 $ hg commit -A -m "2 black"
160 $ hg commit -A -m "2 black"
157 created new head
161 created new head
158
162
159 $ hg update --clean 1
163 $ hg update --clean 1
160 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
161 $ echo blue > color
165 $ echo blue > color
162 $ hg commit -A -m "3 blue"
166 $ hg commit -A -m "3 blue"
163
167
164 $ hg grep --all red
168 $ hg grep --all red
165 color:3:-:red
169 color:3:-:red
166 color:1:+:red
170 color:1:+:red
167
171
168 $ cd ..
172 $ cd ..
169
173
170 $ hg init a
174 $ hg init a
171 $ cd a
175 $ cd a
172 $ cp "$TESTDIR/binfile.bin" .
176 $ cp "$TESTDIR/binfile.bin" .
173 $ hg add binfile.bin
177 $ hg add binfile.bin
174 $ hg ci -m 'add binfile.bin'
178 $ hg ci -m 'add binfile.bin'
175 $ hg grep "MaCam" --all
179 $ hg grep "MaCam" --all
176 binfile.bin:0:+: Binary file matches
180 binfile.bin:0:+: Binary file matches
177
181
178 $ cd ..
182 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now