##// END OF EJS Templates
test-grep: document that trivially moved lines might not be detected...
Yuya Nishihara -
r45998:9c8d2cf7 default
parent child Browse files
Show More
@@ -1,747 +1,790 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* (glob)
21 grep: invalid match pattern: nothing to repeat* (glob)
22 [1]
22 [1]
23
23
24 simple
24 simple
25
25
26 $ hg grep -r tip:0 '.*'
26 $ hg grep -r tip:0 '.*'
27 port:4:export
27 port:4:export
28 port:4:vaportight
28 port:4:vaportight
29 port:4:import/export
29 port:4:import/export
30 port:3:export
30 port:3:export
31 port:3:vaportight
31 port:3:vaportight
32 port:3:import/export
32 port:3:import/export
33 port:3:import/export
33 port:3:import/export
34 port:2:export
34 port:2:export
35 port:2:vaportight
35 port:2:vaportight
36 port:2:import/export
36 port:2:import/export
37 port:1:import
37 port:1:import
38 port:1:export
38 port:1:export
39 port:0:import
39 port:0:import
40 $ hg grep -r tip:0 port port
40 $ hg grep -r tip:0 port port
41 port:4:export
41 port:4:export
42 port:4:vaportight
42 port:4:vaportight
43 port:4:import/export
43 port:4:import/export
44 port:3:export
44 port:3:export
45 port:3:vaportight
45 port:3:vaportight
46 port:3:import/export
46 port:3:import/export
47 port:3:import/export
47 port:3:import/export
48 port:2:export
48 port:2:export
49 port:2:vaportight
49 port:2:vaportight
50 port:2:import/export
50 port:2:import/export
51 port:1:import
51 port:1:import
52 port:1:export
52 port:1:export
53 port:0:import
53 port:0:import
54
54
55 simple from subdirectory
55 simple from subdirectory
56
56
57 $ mkdir dir
57 $ mkdir dir
58 $ cd dir
58 $ cd dir
59 $ hg grep -r tip:0 port
59 $ hg grep -r tip:0 port
60 port:4:export
60 port:4:export
61 port:4:vaportight
61 port:4:vaportight
62 port:4:import/export
62 port:4:import/export
63 port:3:export
63 port:3:export
64 port:3:vaportight
64 port:3:vaportight
65 port:3:import/export
65 port:3:import/export
66 port:3:import/export
66 port:3:import/export
67 port:2:export
67 port:2:export
68 port:2:vaportight
68 port:2:vaportight
69 port:2:import/export
69 port:2:import/export
70 port:1:import
70 port:1:import
71 port:1:export
71 port:1:export
72 port:0:import
72 port:0:import
73 $ hg grep -r tip:0 port --config ui.relative-paths=yes
73 $ hg grep -r tip:0 port --config ui.relative-paths=yes
74 ../port:4:export
74 ../port:4:export
75 ../port:4:vaportight
75 ../port:4:vaportight
76 ../port:4:import/export
76 ../port:4:import/export
77 ../port:3:export
77 ../port:3:export
78 ../port:3:vaportight
78 ../port:3:vaportight
79 ../port:3:import/export
79 ../port:3:import/export
80 ../port:3:import/export
80 ../port:3:import/export
81 ../port:2:export
81 ../port:2:export
82 ../port:2:vaportight
82 ../port:2:vaportight
83 ../port:2:import/export
83 ../port:2:import/export
84 ../port:1:import
84 ../port:1:import
85 ../port:1:export
85 ../port:1:export
86 ../port:0:import
86 ../port:0:import
87 $ cd ..
87 $ cd ..
88
88
89 simple with color
89 simple with color
90
90
91 $ hg --config extensions.color= grep --config color.mode=ansi \
91 $ hg --config extensions.color= grep --config color.mode=ansi \
92 > --color=always port port -r tip:0
92 > --color=always port port -r tip:0
93 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
93 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
94 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
94 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
95 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
95 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
96 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
96 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
97 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
97 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
98 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
98 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
99 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
99 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
100 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
100 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
101 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
101 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
102 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
102 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc)
103 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m (esc)
103 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m (esc)
104 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
104 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
105 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m0\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m (esc)
105 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m0\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m (esc)
106
106
107 simple templated
107 simple templated
108
108
109 $ hg grep port -r tip:0 \
109 $ hg grep port -r tip:0 \
110 > -T '{path}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n'
110 > -T '{path}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n'
111 port:4:914fa752cdea:exPORT
111 port:4:914fa752cdea:exPORT
112 port:4:914fa752cdea:vaPORTight
112 port:4:914fa752cdea:vaPORTight
113 port:4:914fa752cdea:imPORT/exPORT
113 port:4:914fa752cdea:imPORT/exPORT
114 port:3:95040cfd017d:exPORT
114 port:3:95040cfd017d:exPORT
115 port:3:95040cfd017d:vaPORTight
115 port:3:95040cfd017d:vaPORTight
116 port:3:95040cfd017d:imPORT/exPORT
116 port:3:95040cfd017d:imPORT/exPORT
117 port:3:95040cfd017d:imPORT/exPORT
117 port:3:95040cfd017d:imPORT/exPORT
118 port:2:3b325e3481a1:exPORT
118 port:2:3b325e3481a1:exPORT
119 port:2:3b325e3481a1:vaPORTight
119 port:2:3b325e3481a1:vaPORTight
120 port:2:3b325e3481a1:imPORT/exPORT
120 port:2:3b325e3481a1:imPORT/exPORT
121 port:1:8b20f75c1585:imPORT
121 port:1:8b20f75c1585:imPORT
122 port:1:8b20f75c1585:exPORT
122 port:1:8b20f75c1585:exPORT
123 port:0:f31323c92170:imPORT
123 port:0:f31323c92170:imPORT
124
124
125 $ hg grep port -r tip:0 -T '{path}:{rev}:{texts}\n'
125 $ hg grep port -r tip:0 -T '{path}:{rev}:{texts}\n'
126 port:4:export
126 port:4:export
127 port:4:vaportight
127 port:4:vaportight
128 port:4:import/export
128 port:4:import/export
129 port:3:export
129 port:3:export
130 port:3:vaportight
130 port:3:vaportight
131 port:3:import/export
131 port:3:import/export
132 port:3:import/export
132 port:3:import/export
133 port:2:export
133 port:2:export
134 port:2:vaportight
134 port:2:vaportight
135 port:2:import/export
135 port:2:import/export
136 port:1:import
136 port:1:import
137 port:1:export
137 port:1:export
138 port:0:import
138 port:0:import
139
139
140 $ hg grep port -r tip:0 -T '{path}:{tags}:{texts}\n'
140 $ hg grep port -r tip:0 -T '{path}:{tags}:{texts}\n'
141 port:tip:export
141 port:tip:export
142 port:tip:vaportight
142 port:tip:vaportight
143 port:tip:import/export
143 port:tip:import/export
144 port::export
144 port::export
145 port::vaportight
145 port::vaportight
146 port::import/export
146 port::import/export
147 port::import/export
147 port::import/export
148 port::export
148 port::export
149 port::vaportight
149 port::vaportight
150 port::import/export
150 port::import/export
151 port::import
151 port::import
152 port::export
152 port::export
153 port::import
153 port::import
154
154
155 simple JSON (no "change" field)
155 simple JSON (no "change" field)
156
156
157 $ hg grep -r tip:0 -Tjson port
157 $ hg grep -r tip:0 -Tjson port
158 [
158 [
159 {
159 {
160 "date": [4, 0],
160 "date": [4, 0],
161 "lineno": 1,
161 "lineno": 1,
162 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
162 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
163 "path": "port",
163 "path": "port",
164 "rev": 4,
164 "rev": 4,
165 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
165 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
166 "user": "spam"
166 "user": "spam"
167 },
167 },
168 {
168 {
169 "date": [4, 0],
169 "date": [4, 0],
170 "lineno": 2,
170 "lineno": 2,
171 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
171 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
172 "path": "port",
172 "path": "port",
173 "rev": 4,
173 "rev": 4,
174 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
174 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
175 "user": "spam"
175 "user": "spam"
176 },
176 },
177 {
177 {
178 "date": [4, 0],
178 "date": [4, 0],
179 "lineno": 3,
179 "lineno": 3,
180 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
180 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
181 "path": "port",
181 "path": "port",
182 "rev": 4,
182 "rev": 4,
183 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
183 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
184 "user": "spam"
184 "user": "spam"
185 },
185 },
186 {
186 {
187 "date": [3, 0],
187 "date": [3, 0],
188 "lineno": 1,
188 "lineno": 1,
189 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
189 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
190 "path": "port",
190 "path": "port",
191 "rev": 3,
191 "rev": 3,
192 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
192 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
193 "user": "eggs"
193 "user": "eggs"
194 },
194 },
195 {
195 {
196 "date": [3, 0],
196 "date": [3, 0],
197 "lineno": 2,
197 "lineno": 2,
198 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
198 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
199 "path": "port",
199 "path": "port",
200 "rev": 3,
200 "rev": 3,
201 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
201 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
202 "user": "eggs"
202 "user": "eggs"
203 },
203 },
204 {
204 {
205 "date": [3, 0],
205 "date": [3, 0],
206 "lineno": 3,
206 "lineno": 3,
207 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
207 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
208 "path": "port",
208 "path": "port",
209 "rev": 3,
209 "rev": 3,
210 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
210 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
211 "user": "eggs"
211 "user": "eggs"
212 },
212 },
213 {
213 {
214 "date": [3, 0],
214 "date": [3, 0],
215 "lineno": 4,
215 "lineno": 4,
216 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
216 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
217 "path": "port",
217 "path": "port",
218 "rev": 3,
218 "rev": 3,
219 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
219 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
220 "user": "eggs"
220 "user": "eggs"
221 },
221 },
222 {
222 {
223 "date": [2, 0],
223 "date": [2, 0],
224 "lineno": 1,
224 "lineno": 1,
225 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
225 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
226 "path": "port",
226 "path": "port",
227 "rev": 2,
227 "rev": 2,
228 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
228 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
229 "user": "spam"
229 "user": "spam"
230 },
230 },
231 {
231 {
232 "date": [2, 0],
232 "date": [2, 0],
233 "lineno": 2,
233 "lineno": 2,
234 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
234 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
235 "path": "port",
235 "path": "port",
236 "rev": 2,
236 "rev": 2,
237 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
237 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
238 "user": "spam"
238 "user": "spam"
239 },
239 },
240 {
240 {
241 "date": [2, 0],
241 "date": [2, 0],
242 "lineno": 3,
242 "lineno": 3,
243 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
243 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
244 "path": "port",
244 "path": "port",
245 "rev": 2,
245 "rev": 2,
246 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
246 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
247 "user": "spam"
247 "user": "spam"
248 },
248 },
249 {
249 {
250 "date": [1, 0],
250 "date": [1, 0],
251 "lineno": 1,
251 "lineno": 1,
252 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
252 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
253 "path": "port",
253 "path": "port",
254 "rev": 1,
254 "rev": 1,
255 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
255 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
256 "user": "eggs"
256 "user": "eggs"
257 },
257 },
258 {
258 {
259 "date": [1, 0],
259 "date": [1, 0],
260 "lineno": 2,
260 "lineno": 2,
261 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
261 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
262 "path": "port",
262 "path": "port",
263 "rev": 1,
263 "rev": 1,
264 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
264 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
265 "user": "eggs"
265 "user": "eggs"
266 },
266 },
267 {
267 {
268 "date": [0, 0],
268 "date": [0, 0],
269 "lineno": 1,
269 "lineno": 1,
270 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
270 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
271 "path": "port",
271 "path": "port",
272 "rev": 0,
272 "rev": 0,
273 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
273 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
274 "user": "spam"
274 "user": "spam"
275 }
275 }
276 ]
276 ]
277
277
278 simple JSON without matching lines
278 simple JSON without matching lines
279
279
280 $ hg grep -r tip:0 -Tjson -l port
280 $ hg grep -r tip:0 -Tjson -l port
281 [
281 [
282 {
282 {
283 "date": [4, 0],
283 "date": [4, 0],
284 "lineno": 1,
284 "lineno": 1,
285 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
285 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
286 "path": "port",
286 "path": "port",
287 "rev": 4,
287 "rev": 4,
288 "user": "spam"
288 "user": "spam"
289 },
289 },
290 {
290 {
291 "date": [3, 0],
291 "date": [3, 0],
292 "lineno": 1,
292 "lineno": 1,
293 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
293 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
294 "path": "port",
294 "path": "port",
295 "rev": 3,
295 "rev": 3,
296 "user": "eggs"
296 "user": "eggs"
297 },
297 },
298 {
298 {
299 "date": [2, 0],
299 "date": [2, 0],
300 "lineno": 1,
300 "lineno": 1,
301 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
301 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
302 "path": "port",
302 "path": "port",
303 "rev": 2,
303 "rev": 2,
304 "user": "spam"
304 "user": "spam"
305 },
305 },
306 {
306 {
307 "date": [1, 0],
307 "date": [1, 0],
308 "lineno": 1,
308 "lineno": 1,
309 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
309 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
310 "path": "port",
310 "path": "port",
311 "rev": 1,
311 "rev": 1,
312 "user": "eggs"
312 "user": "eggs"
313 },
313 },
314 {
314 {
315 "date": [0, 0],
315 "date": [0, 0],
316 "lineno": 1,
316 "lineno": 1,
317 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
317 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
318 "path": "port",
318 "path": "port",
319 "rev": 0,
319 "rev": 0,
320 "user": "spam"
320 "user": "spam"
321 }
321 }
322 ]
322 ]
323
323
324 all
324 all
325
325
326 $ hg grep --traceback --all -nu port port
326 $ hg grep --traceback --all -nu port port
327 port:4:4:-:spam:import/export
327 port:4:4:-:spam:import/export
328 port:3:4:+:eggs:import/export
328 port:3:4:+:eggs:import/export
329 port:2:1:-:spam:import
329 port:2:1:-:spam:import
330 port:2:2:-:spam:export
330 port:2:2:-:spam:export
331 port:2:1:+:spam:export
331 port:2:1:+:spam:export
332 port:2:2:+:spam:vaportight
332 port:2:2:+:spam:vaportight
333 port:2:3:+:spam:import/export
333 port:2:3:+:spam:import/export
334 port:1:2:+:eggs:export
334 port:1:2:+:eggs:export
335 port:0:1:+:spam:import
335 port:0:1:+:spam:import
336
336
337 all JSON
337 all JSON
338
338
339 $ hg grep --all -Tjson port port
339 $ hg grep --all -Tjson port port
340 [
340 [
341 {
341 {
342 "change": "-",
342 "change": "-",
343 "date": [4, 0],
343 "date": [4, 0],
344 "lineno": 4,
344 "lineno": 4,
345 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
345 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
346 "path": "port",
346 "path": "port",
347 "rev": 4,
347 "rev": 4,
348 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
348 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
349 "user": "spam"
349 "user": "spam"
350 },
350 },
351 {
351 {
352 "change": "+",
352 "change": "+",
353 "date": [3, 0],
353 "date": [3, 0],
354 "lineno": 4,
354 "lineno": 4,
355 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
355 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
356 "path": "port",
356 "path": "port",
357 "rev": 3,
357 "rev": 3,
358 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
358 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
359 "user": "eggs"
359 "user": "eggs"
360 },
360 },
361 {
361 {
362 "change": "-",
362 "change": "-",
363 "date": [2, 0],
363 "date": [2, 0],
364 "lineno": 1,
364 "lineno": 1,
365 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
365 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
366 "path": "port",
366 "path": "port",
367 "rev": 2,
367 "rev": 2,
368 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
368 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
369 "user": "spam"
369 "user": "spam"
370 },
370 },
371 {
371 {
372 "change": "-",
372 "change": "-",
373 "date": [2, 0],
373 "date": [2, 0],
374 "lineno": 2,
374 "lineno": 2,
375 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
375 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
376 "path": "port",
376 "path": "port",
377 "rev": 2,
377 "rev": 2,
378 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
378 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
379 "user": "spam"
379 "user": "spam"
380 },
380 },
381 {
381 {
382 "change": "+",
382 "change": "+",
383 "date": [2, 0],
383 "date": [2, 0],
384 "lineno": 1,
384 "lineno": 1,
385 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
385 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
386 "path": "port",
386 "path": "port",
387 "rev": 2,
387 "rev": 2,
388 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
388 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
389 "user": "spam"
389 "user": "spam"
390 },
390 },
391 {
391 {
392 "change": "+",
392 "change": "+",
393 "date": [2, 0],
393 "date": [2, 0],
394 "lineno": 2,
394 "lineno": 2,
395 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
395 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
396 "path": "port",
396 "path": "port",
397 "rev": 2,
397 "rev": 2,
398 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
398 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
399 "user": "spam"
399 "user": "spam"
400 },
400 },
401 {
401 {
402 "change": "+",
402 "change": "+",
403 "date": [2, 0],
403 "date": [2, 0],
404 "lineno": 3,
404 "lineno": 3,
405 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
405 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
406 "path": "port",
406 "path": "port",
407 "rev": 2,
407 "rev": 2,
408 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
408 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
409 "user": "spam"
409 "user": "spam"
410 },
410 },
411 {
411 {
412 "change": "+",
412 "change": "+",
413 "date": [1, 0],
413 "date": [1, 0],
414 "lineno": 2,
414 "lineno": 2,
415 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
415 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
416 "path": "port",
416 "path": "port",
417 "rev": 1,
417 "rev": 1,
418 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
418 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
419 "user": "eggs"
419 "user": "eggs"
420 },
420 },
421 {
421 {
422 "change": "+",
422 "change": "+",
423 "date": [0, 0],
423 "date": [0, 0],
424 "lineno": 1,
424 "lineno": 1,
425 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
425 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
426 "path": "port",
426 "path": "port",
427 "rev": 0,
427 "rev": 0,
428 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
428 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
429 "user": "spam"
429 "user": "spam"
430 }
430 }
431 ]
431 ]
432
432
433 other
433 other
434
434
435 $ hg grep -r tip:0 -l port port
435 $ hg grep -r tip:0 -l port port
436 port:4
436 port:4
437 port:3
437 port:3
438 port:2
438 port:2
439 port:1
439 port:1
440 port:0
440 port:0
441 $ hg grep -r tip:0 import port
441 $ hg grep -r tip:0 import port
442 port:4:import/export
442 port:4:import/export
443 port:3:import/export
443 port:3:import/export
444 port:3:import/export
444 port:3:import/export
445 port:2:import/export
445 port:2:import/export
446 port:1:import
446 port:1:import
447 port:0:import
447 port:0:import
448
448
449 $ hg cp port port2
449 $ hg cp port port2
450 $ hg commit -m 4 -u spam -d '5 0'
450 $ hg commit -m 4 -u spam -d '5 0'
451
451
452 follow
452 follow
453
453
454 $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
454 $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
455 [1]
455 [1]
456 $ echo deport >> port2
456 $ echo deport >> port2
457 $ hg commit -m 5 -u eggs -d '6 0'
457 $ hg commit -m 5 -u eggs -d '6 0'
458 $ hg grep -f --all -nu port port2
458 $ hg grep -f --all -nu port port2
459 port2:6:4:+:eggs:deport
459 port2:6:4:+:eggs:deport
460 port:4:4:-:spam:import/export
460 port:4:4:-:spam:import/export
461 port:3:4:+:eggs:import/export
461 port:3:4:+:eggs:import/export
462 port:2:1:-:spam:import
462 port:2:1:-:spam:import
463 port:2:2:-:spam:export
463 port:2:2:-:spam:export
464 port:2:1:+:spam:export
464 port:2:1:+:spam:export
465 port:2:2:+:spam:vaportight
465 port:2:2:+:spam:vaportight
466 port:2:3:+:spam:import/export
466 port:2:3:+:spam:import/export
467 port:1:2:+:eggs:export
467 port:1:2:+:eggs:export
468 port:0:1:+:spam:import
468 port:0:1:+:spam:import
469
469
470 $ hg up -q null
470 $ hg up -q null
471 $ hg grep -r 'reverse(:.)' -f port
471 $ hg grep -r 'reverse(:.)' -f port
472 port:0:import
472 port:0:import
473
473
474 Test wdir
474 Test wdir
475 (at least, this shouldn't crash)
475 (at least, this shouldn't crash)
476
476
477 $ hg up -q
477 $ hg up -q
478 $ echo wport >> port2
478 $ echo wport >> port2
479 $ hg stat
479 $ hg stat
480 M port2
480 M port2
481 $ hg grep -r 'wdir()' port
481 $ hg grep -r 'wdir()' port
482 port:2147483647:export
482 port:2147483647:export
483 port:2147483647:vaportight
483 port:2147483647:vaportight
484 port:2147483647:import/export
484 port:2147483647:import/export
485 port2:2147483647:export
485 port2:2147483647:export
486 port2:2147483647:vaportight
486 port2:2147483647:vaportight
487 port2:2147483647:import/export
487 port2:2147483647:import/export
488 port2:2147483647:deport
488 port2:2147483647:deport
489 port2:2147483647:wport
489 port2:2147483647:wport
490
490
491 $ cd ..
491 $ cd ..
492 $ hg init t2
492 $ hg init t2
493 $ cd t2
493 $ cd t2
494 $ hg grep -r tip:0 foobar foo
494 $ hg grep -r tip:0 foobar foo
495 [1]
495 [1]
496 $ hg grep -r tip:0 foobar
496 $ hg grep -r tip:0 foobar
497 [1]
497 [1]
498 $ echo blue >> color
498 $ echo blue >> color
499 $ echo black >> color
499 $ echo black >> color
500 $ hg add color
500 $ hg add color
501 $ hg ci -m 0
501 $ hg ci -m 0
502 $ echo orange >> color
502 $ echo orange >> color
503 $ hg ci -m 1
503 $ hg ci -m 1
504 $ echo black > color
504 $ echo black > color
505 $ hg ci -m 2
505 $ hg ci -m 2
506 $ echo orange >> color
506 $ echo orange >> color
507 $ echo blue >> color
507 $ echo blue >> color
508 $ hg ci -m 3
508 $ hg ci -m 3
509 $ hg grep -r tip:0 orange
509 $ hg grep -r tip:0 orange
510 color:3:orange
510 color:3:orange
511 color:1:orange
511 color:1:orange
512 $ hg grep --all orange
512 $ hg grep --all orange
513 color:3:+:orange
513 color:3:+:orange
514 color:2:-:orange
514 color:2:-:orange
515 color:1:+:orange
515 color:1:+:orange
516 $ hg grep --diff orange --color=debug
516 $ hg grep --diff orange --color=debug
517 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
517 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
518 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange]
518 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange]
519 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
519 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
520
520
521 $ hg grep --diff orange --color=yes
521 $ hg grep --diff orange --color=yes
522 \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32;1m+\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc)
522 \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32;1m+\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc)
523 \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1m-\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc)
523 \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1m-\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc)
524 \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32;1m+\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc)
524 \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32;1m+\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc)
525
525
526 $ hg grep --diff orange
526 $ hg grep --diff orange
527 color:3:+:orange
527 color:3:+:orange
528 color:2:-:orange
528 color:2:-:orange
529 color:1:+:orange
529 color:1:+:orange
530
530
531 test substring match: '^' should only match at the beginning
531 test substring match: '^' should only match at the beginning
532
532
533 $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
533 $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
534 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
534 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
535 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
535 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
536 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
536 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
537 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack
537 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack
538 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue
538 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue
539 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack
539 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack
540 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range
540 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range
541 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue
541 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue
542 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack
542 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack
543
543
544 match in last "line" without newline
544 match in last "line" without newline
545
545
546 $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
546 $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
547 $ hg ci -Amnoeol
547 $ hg ci -Amnoeol
548 adding noeol
548 adding noeol
549 $ hg grep -r tip:0 loop
549 $ hg grep -r tip:0 loop
550 noeol:4:no infinite loop
550 noeol:4:no infinite loop
551
551
552 $ cd ..
552 $ cd ..
553
553
554 Issue685: traceback in grep -r after rename
554 Issue685: traceback in grep -r after rename
555
555
556 Got a traceback when using grep on a single
556 Got a traceback when using grep on a single
557 revision with renamed files.
557 revision with renamed files.
558
558
559 $ hg init issue685
559 $ hg init issue685
560 $ cd issue685
560 $ cd issue685
561 $ echo octarine > color
561 $ echo octarine > color
562 $ hg ci -Amcolor
562 $ hg ci -Amcolor
563 adding color
563 adding color
564 $ hg rename color colour
564 $ hg rename color colour
565 $ hg ci -Am rename
565 $ hg ci -Am rename
566 $ hg grep -r tip:0 octarine
566 $ hg grep -r tip:0 octarine
567 colour:1:octarine
567 colour:1:octarine
568 color:0:octarine
568 color:0:octarine
569
569
570 Used to crash here
570 Used to crash here
571
571
572 $ hg grep -r 1 octarine
572 $ hg grep -r 1 octarine
573 colour:1:octarine
573 colour:1:octarine
574 $ cd ..
574 $ cd ..
575
575
576
576
577 Issue337: test that grep follows parent-child relationships instead
577 Issue337: test that grep follows parent-child relationships instead
578 of just using revision numbers.
578 of just using revision numbers.
579
579
580 $ hg init issue337
580 $ hg init issue337
581 $ cd issue337
581 $ cd issue337
582
582
583 $ echo white > color
583 $ echo white > color
584 $ hg commit -A -m "0 white"
584 $ hg commit -A -m "0 white"
585 adding color
585 adding color
586
586
587 $ echo red > color
587 $ echo red > color
588 $ hg commit -A -m "1 red"
588 $ hg commit -A -m "1 red"
589
589
590 $ hg update 0
590 $ hg update 0
591 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
591 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
592 $ echo black > color
592 $ echo black > color
593 $ hg commit -A -m "2 black"
593 $ hg commit -A -m "2 black"
594 created new head
594 created new head
595
595
596 $ hg update --clean 1
596 $ hg update --clean 1
597 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
597 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
598 $ echo blue > color
598 $ echo blue > color
599 $ hg commit -A -m "3 blue"
599 $ hg commit -A -m "3 blue"
600
600
601 $ hg grep --all red
601 $ hg grep --all red
602 color:3:-:red
602 color:3:-:red
603 color:1:+:red
603 color:1:+:red
604
604
605 $ hg grep --diff red
605 $ hg grep --diff red
606 color:3:-:red
606 color:3:-:red
607 color:1:+:red
607 color:1:+:red
608
608
609 Issue3885: test that changing revision order does not alter the
609 Issue3885: test that changing revision order does not alter the
610 revisions printed, just their order.
610 revisions printed, just their order.
611
611
612 $ hg grep --all red -r "all()"
612 $ hg grep --all red -r "all()"
613 color:1:+:red
613 color:1:+:red
614 color:3:-:red
614 color:3:-:red
615
615
616 $ hg grep --all red -r "reverse(all())"
616 $ hg grep --all red -r "reverse(all())"
617 color:3:-:red
617 color:3:-:red
618 color:1:+:red
618 color:1:+:red
619
619
620 $ hg grep --diff red -r "all()"
620 $ hg grep --diff red -r "all()"
621 color:1:+:red
621 color:1:+:red
622 color:3:-:red
622 color:3:-:red
623
623
624 $ hg grep --diff red -r "reverse(all())"
624 $ hg grep --diff red -r "reverse(all())"
625 color:3:-:red
625 color:3:-:red
626 color:1:+:red
626 color:1:+:red
627
627
628 $ cd ..
628 $ cd ..
629
629
630 $ hg init a
630 $ hg init a
631 $ cd a
631 $ cd a
632 $ cp "$TESTDIR/binfile.bin" .
632 $ cp "$TESTDIR/binfile.bin" .
633 $ hg add binfile.bin
633 $ hg add binfile.bin
634 $ hg ci -m 'add binfile.bin'
634 $ hg ci -m 'add binfile.bin'
635 $ hg grep "MaCam" --all
635 $ hg grep "MaCam" --all
636 binfile.bin:0:+: Binary file matches
636 binfile.bin:0:+: Binary file matches
637
637
638 $ hg grep "MaCam" --diff
638 $ hg grep "MaCam" --diff
639 binfile.bin:0:+: Binary file matches
639 binfile.bin:0:+: Binary file matches
640
640
641 $ cd ..
641 $ cd ..
642
642
643 Moved line may not be collected by "grep --diff" since it first filters
644 the contents to be diffed by the pattern. (i.e.
645 "diff <(grep pat a) <(grep pat b)", not "diff a b | grep pat".)
646 This is much faster than generating full diff per revision.
647
648 $ hg init moved-line
649 $ cd moved-line
650 $ cat <<'EOF' > a
651 > foo
652 > bar
653 > baz
654 > EOF
655 $ hg ci -Am initial
656 adding a
657 $ cat <<'EOF' > a
658 > bar
659 > baz
660 > foo
661 > EOF
662 $ hg ci -m reorder
663
664 $ hg diff -c 1
665 diff -r a593cc55e81b -r 69789a3b6e80 a
666 --- a/a Thu Jan 01 00:00:00 1970 +0000
667 +++ b/a Thu Jan 01 00:00:00 1970 +0000
668 @@ -1,3 +1,3 @@
669 -foo
670 bar
671 baz
672 +foo
673
674 can't find the move of "foo" at the revision 1:
675
676 $ hg grep --diff foo -r1
677 [1]
678
679 "bar" isn't moved at the revisoin 1:
680
681 $ hg grep --diff bar -r1
682 [1]
683
684 $ cd ..
685
643 Test for showing working of allfiles flag
686 Test for showing working of allfiles flag
644
687
645 $ hg init sng
688 $ hg init sng
646 $ cd sng
689 $ cd sng
647 $ echo "unmod" >> um
690 $ echo "unmod" >> um
648 $ echo old > old
691 $ echo old > old
649 $ hg ci -q -A -m "adds unmod to um"
692 $ hg ci -q -A -m "adds unmod to um"
650 $ echo "something else" >> new
693 $ echo "something else" >> new
651 $ hg ci -A -m "second commit"
694 $ hg ci -A -m "second commit"
652 adding new
695 adding new
653 $ hg grep -r "." "unmod"
696 $ hg grep -r "." "unmod"
654 um:1:unmod
697 um:1:unmod
655
698
656 Existing tracked files in the working directory are searched by default
699 Existing tracked files in the working directory are searched by default
657
700
658 $ echo modified >> new
701 $ echo modified >> new
659 $ echo 'added' > added; hg add added
702 $ echo 'added' > added; hg add added
660 $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
703 $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
661 $ echo 'untracked' > untracked
704 $ echo 'untracked' > untracked
662 $ hg rm old
705 $ hg rm old
663 $ hg grep ''
706 $ hg grep ''
664 added:added
707 added:added
665 new:something else
708 new:something else
666 new:modified
709 new:modified
667 um:unmod
710 um:unmod
668
711
669 #if symlink
712 #if symlink
670 Grepping a symlink greps its destination
713 Grepping a symlink greps its destination
671
714
672 $ rm -f added; ln -s symlink-added added
715 $ rm -f added; ln -s symlink-added added
673 $ hg grep '' | grep added
716 $ hg grep '' | grep added
674 added:symlink-added
717 added:symlink-added
675
718
676 But we reject symlinks as directories components of a tracked file as
719 But we reject symlinks as directories components of a tracked file as
677 usual:
720 usual:
678
721
679 $ mkdir dir; touch dir/f; hg add dir/f
722 $ mkdir dir; touch dir/f; hg add dir/f
680 $ rm -rf dir; ln -s / dir
723 $ rm -rf dir; ln -s / dir
681 $ hg grep ''
724 $ hg grep ''
682 abort: path 'dir/f' traverses symbolic link 'dir'
725 abort: path 'dir/f' traverses symbolic link 'dir'
683 [255]
726 [255]
684 #endif
727 #endif
685
728
686 But we can search files from some other revision with -rREV
729 But we can search files from some other revision with -rREV
687
730
688 $ hg grep -r. mod
731 $ hg grep -r. mod
689 um:1:unmod
732 um:1:unmod
690
733
691 $ hg grep --diff mod
734 $ hg grep --diff mod
692 um:0:+:unmod
735 um:0:+:unmod
693
736
694 $ cd ..
737 $ cd ..
695
738
696 Change Default of grep by ui.tweakdefaults, that is, the files not in current
739 Change Default of grep by ui.tweakdefaults, that is, the files not in current
697 working directory should not be grepp-ed on
740 working directory should not be grepp-ed on
698
741
699 $ hg init ab
742 $ hg init ab
700 $ cd ab
743 $ cd ab
701 $ cat <<'EOF' >> .hg/hgrc
744 $ cat <<'EOF' >> .hg/hgrc
702 > [ui]
745 > [ui]
703 > tweakdefaults = True
746 > tweakdefaults = True
704 > EOF
747 > EOF
705 $ echo "some text">>file1
748 $ echo "some text">>file1
706 $ hg add file1
749 $ hg add file1
707 $ hg commit -m "adds file1"
750 $ hg commit -m "adds file1"
708 $ hg mv file1 file2
751 $ hg mv file1 file2
709
752
710 wdir revision is hidden by default:
753 wdir revision is hidden by default:
711
754
712 $ hg grep "some"
755 $ hg grep "some"
713 file2:some text
756 file2:some text
714
757
715 but it should be available in template dict:
758 but it should be available in template dict:
716
759
717 $ hg grep "some" -Tjson
760 $ hg grep "some" -Tjson
718 [
761 [
719 {
762 {
720 "date": [0, 0],
763 "date": [0, 0],
721 "lineno": 1,
764 "lineno": 1,
722 "node": "ffffffffffffffffffffffffffffffffffffffff",
765 "node": "ffffffffffffffffffffffffffffffffffffffff",
723 "path": "file2",
766 "path": "file2",
724 "rev": 2147483647,
767 "rev": 2147483647,
725 "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
768 "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
726 "user": "test"
769 "user": "test"
727 }
770 }
728 ]
771 ]
729
772
730 $ cd ..
773 $ cd ..
731
774
732 test -rMULTIREV
775 test -rMULTIREV
733
776
734 $ cd sng
777 $ cd sng
735 $ hg rm um
778 $ hg rm um
736 $ hg commit -m "deletes um"
779 $ hg commit -m "deletes um"
737 $ hg grep -r "0:2" "unmod"
780 $ hg grep -r "0:2" "unmod"
738 um:0:unmod
781 um:0:unmod
739 um:1:unmod
782 um:1:unmod
740 $ hg grep -r "0:2" "unmod" um
783 $ hg grep -r "0:2" "unmod" um
741 um:0:unmod
784 um:0:unmod
742 um:1:unmod
785 um:1:unmod
743 $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work
786 $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work
744 um:0:unmod
787 um:0:unmod
745 um:1:unmod
788 um:1:unmod
746 $ cd ..
789 $ cd ..
747
790
General Comments 0
You need to be logged in to leave comments. Login now