##// END OF EJS Templates
py3: make sure we write bytes in a file open in bytes mode...
Pulkit Goyal -
r36513:eafd380f default
parent child Browse files
Show More
@@ -1,343 +1,343 b''
1 1 $ hg init t
2 2 $ cd t
3 3 $ echo import > port
4 4 $ hg add port
5 5 $ hg commit -m 0 -u spam -d '0 0'
6 6 $ echo export >> port
7 7 $ hg commit -m 1 -u eggs -d '1 0'
8 8 $ echo export > port
9 9 $ echo vaportight >> port
10 10 $ echo 'import/export' >> port
11 11 $ hg commit -m 2 -u spam -d '2 0'
12 12 $ echo 'import/export' >> port
13 13 $ hg commit -m 3 -u eggs -d '3 0'
14 14 $ head -n 3 port > port1
15 15 $ mv port1 port
16 16 $ hg commit -m 4 -u spam -d '4 0'
17 17
18 18 pattern error
19 19
20 20 $ hg grep '**test**'
21 21 grep: invalid match pattern: nothing to repeat
22 22 [1]
23 23
24 24 simple
25 25
26 26 $ hg grep '.*'
27 27 port:4:export
28 28 port:4:vaportight
29 29 port:4:import/export
30 30 $ hg grep port port
31 31 port:4:export
32 32 port:4:vaportight
33 33 port:4:import/export
34 34
35 35 simple with color
36 36
37 37 $ hg --config extensions.color= grep --config color.mode=ansi \
38 38 > --color=always port port
39 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)
40 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)
41 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)
42 42
43 43 simple templated
44 44
45 45 $ hg grep port \
46 46 > -T '{file}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n'
47 47 port:4:914fa752cdea:exPORT
48 48 port:4:914fa752cdea:vaPORTight
49 49 port:4:914fa752cdea:imPORT/exPORT
50 50
51 51 simple JSON (no "change" field)
52 52
53 53 $ hg grep -Tjson port
54 54 [
55 55 {
56 56 "date": [4.0, 0],
57 57 "file": "port",
58 58 "line_number": 1,
59 59 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
60 60 "rev": 4,
61 61 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
62 62 "user": "spam"
63 63 },
64 64 {
65 65 "date": [4.0, 0],
66 66 "file": "port",
67 67 "line_number": 2,
68 68 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
69 69 "rev": 4,
70 70 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
71 71 "user": "spam"
72 72 },
73 73 {
74 74 "date": [4.0, 0],
75 75 "file": "port",
76 76 "line_number": 3,
77 77 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
78 78 "rev": 4,
79 79 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
80 80 "user": "spam"
81 81 }
82 82 ]
83 83
84 84 simple JSON without matching lines
85 85
86 86 $ hg grep -Tjson -l port
87 87 [
88 88 {
89 89 "date": [4.0, 0],
90 90 "file": "port",
91 91 "line_number": 1,
92 92 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
93 93 "rev": 4,
94 94 "user": "spam"
95 95 }
96 96 ]
97 97
98 98 all
99 99
100 100 $ hg grep --traceback --all -nu port port
101 101 port:4:4:-:spam:import/export
102 102 port:3:4:+:eggs:import/export
103 103 port:2:1:-:spam:import
104 104 port:2:2:-:spam:export
105 105 port:2:1:+:spam:export
106 106 port:2:2:+:spam:vaportight
107 107 port:2:3:+:spam:import/export
108 108 port:1:2:+:eggs:export
109 109 port:0:1:+:spam:import
110 110
111 111 all JSON
112 112
113 113 $ hg grep --all -Tjson port port
114 114 [
115 115 {
116 116 "change": "-",
117 117 "date": [4.0, 0],
118 118 "file": "port",
119 119 "line_number": 4,
120 120 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
121 121 "rev": 4,
122 122 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
123 123 "user": "spam"
124 124 },
125 125 {
126 126 "change": "+",
127 127 "date": [3.0, 0],
128 128 "file": "port",
129 129 "line_number": 4,
130 130 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
131 131 "rev": 3,
132 132 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
133 133 "user": "eggs"
134 134 },
135 135 {
136 136 "change": "-",
137 137 "date": [2.0, 0],
138 138 "file": "port",
139 139 "line_number": 1,
140 140 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
141 141 "rev": 2,
142 142 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
143 143 "user": "spam"
144 144 },
145 145 {
146 146 "change": "-",
147 147 "date": [2.0, 0],
148 148 "file": "port",
149 149 "line_number": 2,
150 150 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
151 151 "rev": 2,
152 152 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
153 153 "user": "spam"
154 154 },
155 155 {
156 156 "change": "+",
157 157 "date": [2.0, 0],
158 158 "file": "port",
159 159 "line_number": 1,
160 160 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
161 161 "rev": 2,
162 162 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
163 163 "user": "spam"
164 164 },
165 165 {
166 166 "change": "+",
167 167 "date": [2.0, 0],
168 168 "file": "port",
169 169 "line_number": 2,
170 170 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
171 171 "rev": 2,
172 172 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
173 173 "user": "spam"
174 174 },
175 175 {
176 176 "change": "+",
177 177 "date": [2.0, 0],
178 178 "file": "port",
179 179 "line_number": 3,
180 180 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
181 181 "rev": 2,
182 182 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
183 183 "user": "spam"
184 184 },
185 185 {
186 186 "change": "+",
187 187 "date": [1.0, 0],
188 188 "file": "port",
189 189 "line_number": 2,
190 190 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
191 191 "rev": 1,
192 192 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
193 193 "user": "eggs"
194 194 },
195 195 {
196 196 "change": "+",
197 197 "date": [0.0, 0],
198 198 "file": "port",
199 199 "line_number": 1,
200 200 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
201 201 "rev": 0,
202 202 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
203 203 "user": "spam"
204 204 }
205 205 ]
206 206
207 207 other
208 208
209 209 $ hg grep -l port port
210 210 port:4
211 211 $ hg grep import port
212 212 port:4:import/export
213 213
214 214 $ hg cp port port2
215 215 $ hg commit -m 4 -u spam -d '5 0'
216 216
217 217 follow
218 218
219 219 $ hg grep --traceback -f 'import\n\Z' port2
220 220 port:0:import
221 221
222 222 $ echo deport >> port2
223 223 $ hg commit -m 5 -u eggs -d '6 0'
224 224 $ hg grep -f --all -nu port port2
225 225 port2:6:4:+:eggs:deport
226 226 port:4:4:-:spam:import/export
227 227 port:3:4:+:eggs:import/export
228 228 port:2:1:-:spam:import
229 229 port:2:2:-:spam:export
230 230 port:2:1:+:spam:export
231 231 port:2:2:+:spam:vaportight
232 232 port:2:3:+:spam:import/export
233 233 port:1:2:+:eggs:export
234 234 port:0:1:+:spam:import
235 235
236 236 $ hg up -q null
237 237 $ hg grep -f port
238 238 [1]
239 239
240 240 $ cd ..
241 241 $ hg init t2
242 242 $ cd t2
243 243 $ hg grep foobar foo
244 244 [1]
245 245 $ hg grep foobar
246 246 [1]
247 247 $ echo blue >> color
248 248 $ echo black >> color
249 249 $ hg add color
250 250 $ hg ci -m 0
251 251 $ echo orange >> color
252 252 $ hg ci -m 1
253 253 $ echo black > color
254 254 $ hg ci -m 2
255 255 $ echo orange >> color
256 256 $ echo blue >> color
257 257 $ hg ci -m 3
258 258 $ hg grep orange
259 259 color:3:orange
260 260 $ hg grep --all orange
261 261 color:3:+:orange
262 262 color:2:-:orange
263 263 color:1:+:orange
264 264
265 265 test substring match: '^' should only match at the beginning
266 266
267 267 $ hg grep '^.' --config extensions.color= --color debug
268 268 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
269 269 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
270 270 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
271 271
272 272 match in last "line" without newline
273 273
274 $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
274 $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
275 275 $ hg ci -Amnoeol
276 276 adding noeol
277 277 $ hg grep loop
278 278 noeol:4:no infinite loop
279 279
280 280 $ cd ..
281 281
282 282 Issue685: traceback in grep -r after rename
283 283
284 284 Got a traceback when using grep on a single
285 285 revision with renamed files.
286 286
287 287 $ hg init issue685
288 288 $ cd issue685
289 289 $ echo octarine > color
290 290 $ hg ci -Amcolor
291 291 adding color
292 292 $ hg rename color colour
293 293 $ hg ci -Am rename
294 294 $ hg grep octarine
295 295 colour:1:octarine
296 296 color:0:octarine
297 297
298 298 Used to crash here
299 299
300 300 $ hg grep -r 1 octarine
301 301 colour:1:octarine
302 302 $ cd ..
303 303
304 304
305 305 Issue337: test that grep follows parent-child relationships instead
306 306 of just using revision numbers.
307 307
308 308 $ hg init issue337
309 309 $ cd issue337
310 310
311 311 $ echo white > color
312 312 $ hg commit -A -m "0 white"
313 313 adding color
314 314
315 315 $ echo red > color
316 316 $ hg commit -A -m "1 red"
317 317
318 318 $ hg update 0
319 319 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
320 320 $ echo black > color
321 321 $ hg commit -A -m "2 black"
322 322 created new head
323 323
324 324 $ hg update --clean 1
325 325 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
326 326 $ echo blue > color
327 327 $ hg commit -A -m "3 blue"
328 328
329 329 $ hg grep --all red
330 330 color:3:-:red
331 331 color:1:+:red
332 332
333 333 $ cd ..
334 334
335 335 $ hg init a
336 336 $ cd a
337 337 $ cp "$TESTDIR/binfile.bin" .
338 338 $ hg add binfile.bin
339 339 $ hg ci -m 'add binfile.bin'
340 340 $ hg grep "MaCam" --all
341 341 binfile.bin:0:+: Binary file matches
342 342
343 343 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now