##// END OF EJS Templates
test-grep: add tests for --follow with/without --diff and/or paths...
Yuya Nishihara -
r46049:20dd2a25 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (516 lines changed) Show them Hide them
@@ -1,815 +1,1331 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 diff of each revision for reference
324 diff of each revision for reference
325
325
326 $ hg log -p -T'== rev: {rev} ==\n'
326 $ hg log -p -T'== rev: {rev} ==\n'
327 == rev: 4 ==
327 == rev: 4 ==
328 diff -r 95040cfd017d -r 914fa752cdea port
328 diff -r 95040cfd017d -r 914fa752cdea port
329 --- a/port Thu Jan 01 00:00:03 1970 +0000
329 --- a/port Thu Jan 01 00:00:03 1970 +0000
330 +++ b/port Thu Jan 01 00:00:04 1970 +0000
330 +++ b/port Thu Jan 01 00:00:04 1970 +0000
331 @@ -1,4 +1,3 @@
331 @@ -1,4 +1,3 @@
332 export
332 export
333 vaportight
333 vaportight
334 import/export
334 import/export
335 -import/export
335 -import/export
336
336
337 == rev: 3 ==
337 == rev: 3 ==
338 diff -r 3b325e3481a1 -r 95040cfd017d port
338 diff -r 3b325e3481a1 -r 95040cfd017d port
339 --- a/port Thu Jan 01 00:00:02 1970 +0000
339 --- a/port Thu Jan 01 00:00:02 1970 +0000
340 +++ b/port Thu Jan 01 00:00:03 1970 +0000
340 +++ b/port Thu Jan 01 00:00:03 1970 +0000
341 @@ -1,3 +1,4 @@
341 @@ -1,3 +1,4 @@
342 export
342 export
343 vaportight
343 vaportight
344 import/export
344 import/export
345 +import/export
345 +import/export
346
346
347 == rev: 2 ==
347 == rev: 2 ==
348 diff -r 8b20f75c1585 -r 3b325e3481a1 port
348 diff -r 8b20f75c1585 -r 3b325e3481a1 port
349 --- a/port Thu Jan 01 00:00:01 1970 +0000
349 --- a/port Thu Jan 01 00:00:01 1970 +0000
350 +++ b/port Thu Jan 01 00:00:02 1970 +0000
350 +++ b/port Thu Jan 01 00:00:02 1970 +0000
351 @@ -1,2 +1,3 @@
351 @@ -1,2 +1,3 @@
352 -import
352 -import
353 export
353 export
354 +vaportight
354 +vaportight
355 +import/export
355 +import/export
356
356
357 == rev: 1 ==
357 == rev: 1 ==
358 diff -r f31323c92170 -r 8b20f75c1585 port
358 diff -r f31323c92170 -r 8b20f75c1585 port
359 --- a/port Thu Jan 01 00:00:00 1970 +0000
359 --- a/port Thu Jan 01 00:00:00 1970 +0000
360 +++ b/port Thu Jan 01 00:00:01 1970 +0000
360 +++ b/port Thu Jan 01 00:00:01 1970 +0000
361 @@ -1,1 +1,2 @@
361 @@ -1,1 +1,2 @@
362 import
362 import
363 +export
363 +export
364
364
365 == rev: 0 ==
365 == rev: 0 ==
366 diff -r 000000000000 -r f31323c92170 port
366 diff -r 000000000000 -r f31323c92170 port
367 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
367 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
368 +++ b/port Thu Jan 01 00:00:00 1970 +0000
368 +++ b/port Thu Jan 01 00:00:00 1970 +0000
369 @@ -0,0 +1,1 @@
369 @@ -0,0 +1,1 @@
370 +import
370 +import
371
371
372
372
373 all
373 all
374
374
375 $ hg grep --traceback --all -nu port port
375 $ hg grep --traceback --all -nu port port
376 port:4:4:-:spam:import/export
376 port:4:4:-:spam:import/export
377 port:3:4:+:eggs:import/export
377 port:3:4:+:eggs:import/export
378 port:2:1:-:spam:import
378 port:2:1:-:spam:import
379 port:2:2:+:spam:vaportight
379 port:2:2:+:spam:vaportight
380 port:2:3:+:spam:import/export
380 port:2:3:+:spam:import/export
381 port:1:2:+:eggs:export
381 port:1:2:+:eggs:export
382 port:0:1:+:spam:import
382 port:0:1:+:spam:import
383
383
384 all JSON
384 all JSON
385
385
386 $ hg grep --all -Tjson port port
386 $ hg grep --all -Tjson port port
387 [
387 [
388 {
388 {
389 "change": "-",
389 "change": "-",
390 "date": [4, 0],
390 "date": [4, 0],
391 "lineno": 4,
391 "lineno": 4,
392 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
392 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
393 "path": "port",
393 "path": "port",
394 "rev": 4,
394 "rev": 4,
395 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
395 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
396 "user": "spam"
396 "user": "spam"
397 },
397 },
398 {
398 {
399 "change": "+",
399 "change": "+",
400 "date": [3, 0],
400 "date": [3, 0],
401 "lineno": 4,
401 "lineno": 4,
402 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
402 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
403 "path": "port",
403 "path": "port",
404 "rev": 3,
404 "rev": 3,
405 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
405 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
406 "user": "eggs"
406 "user": "eggs"
407 },
407 },
408 {
408 {
409 "change": "-",
409 "change": "-",
410 "date": [2, 0],
410 "date": [2, 0],
411 "lineno": 1,
411 "lineno": 1,
412 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
412 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
413 "path": "port",
413 "path": "port",
414 "rev": 2,
414 "rev": 2,
415 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
415 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
416 "user": "spam"
416 "user": "spam"
417 },
417 },
418 {
418 {
419 "change": "+",
419 "change": "+",
420 "date": [2, 0],
420 "date": [2, 0],
421 "lineno": 2,
421 "lineno": 2,
422 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
422 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
423 "path": "port",
423 "path": "port",
424 "rev": 2,
424 "rev": 2,
425 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
425 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
426 "user": "spam"
426 "user": "spam"
427 },
427 },
428 {
428 {
429 "change": "+",
429 "change": "+",
430 "date": [2, 0],
430 "date": [2, 0],
431 "lineno": 3,
431 "lineno": 3,
432 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
432 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
433 "path": "port",
433 "path": "port",
434 "rev": 2,
434 "rev": 2,
435 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
435 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
436 "user": "spam"
436 "user": "spam"
437 },
437 },
438 {
438 {
439 "change": "+",
439 "change": "+",
440 "date": [1, 0],
440 "date": [1, 0],
441 "lineno": 2,
441 "lineno": 2,
442 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
442 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
443 "path": "port",
443 "path": "port",
444 "rev": 1,
444 "rev": 1,
445 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
445 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
446 "user": "eggs"
446 "user": "eggs"
447 },
447 },
448 {
448 {
449 "change": "+",
449 "change": "+",
450 "date": [0, 0],
450 "date": [0, 0],
451 "lineno": 1,
451 "lineno": 1,
452 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
452 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
453 "path": "port",
453 "path": "port",
454 "rev": 0,
454 "rev": 0,
455 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
455 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
456 "user": "spam"
456 "user": "spam"
457 }
457 }
458 ]
458 ]
459
459
460 other
460 other
461
461
462 $ hg grep -r tip:0 -l port port
462 $ hg grep -r tip:0 -l port port
463 port:4
463 port:4
464 port:3
464 port:3
465 port:2
465 port:2
466 port:1
466 port:1
467 port:0
467 port:0
468 $ hg grep -r tip:0 import port
468 $ hg grep -r tip:0 import port
469 port:4:import/export
469 port:4:import/export
470 port:3:import/export
470 port:3:import/export
471 port:3:import/export
471 port:3:import/export
472 port:2:import/export
472 port:2:import/export
473 port:1:import
473 port:1:import
474 port:0:import
474 port:0:import
475
475
476 $ hg cp port port2
476 $ hg cp port port2
477 $ hg commit -m 4 -u spam -d '5 0'
477 $ hg commit -m 4 -u spam -d '5 0'
478
478
479 follow
479 follow
480
480
481 $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
481 $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
482 [1]
482 [1]
483 $ echo deport >> port2
483 $ echo deport >> port2
484 $ hg commit -m 5 -u eggs -d '6 0'
484 $ hg commit -m 5 -u eggs -d '6 0'
485 $ hg grep -f --all -nu port port2
485 $ hg grep -f --all -nu port port2
486 port2:6:4:+:eggs:deport
486 port2:6:4:+:eggs:deport
487 port:4:4:-:spam:import/export
487 port:4:4:-:spam:import/export
488 port:3:4:+:eggs:import/export
488 port:3:4:+:eggs:import/export
489 port:2:1:-:spam:import
489 port:2:1:-:spam:import
490 port:2:2:+:spam:vaportight
490 port:2:2:+:spam:vaportight
491 port:2:3:+:spam:import/export
491 port:2:3:+:spam:import/export
492 port:1:2:+:eggs:export
492 port:1:2:+:eggs:export
493 port:0:1:+:spam:import
493 port:0:1:+:spam:import
494
494
495 $ hg up -q null
495 $ hg up -q null
496 $ hg grep -r 'reverse(:.)' -f port
496 $ hg grep -r 'reverse(:.)' -f port
497 port:0:import
497 port:0:import
498
498
499 Test wdir
499 Test wdir
500 (at least, this shouldn't crash)
500 (at least, this shouldn't crash)
501
501
502 $ hg up -q
502 $ hg up -q
503 $ echo wport >> port2
503 $ echo wport >> port2
504 $ hg stat
504 $ hg stat
505 M port2
505 M port2
506 $ hg grep -r 'wdir()' port
506 $ hg grep -r 'wdir()' port
507 port:2147483647:export
507 port:2147483647:export
508 port:2147483647:vaportight
508 port:2147483647:vaportight
509 port:2147483647:import/export
509 port:2147483647:import/export
510 port2:2147483647:export
510 port2:2147483647:export
511 port2:2147483647:vaportight
511 port2:2147483647:vaportight
512 port2:2147483647:import/export
512 port2:2147483647:import/export
513 port2:2147483647:deport
513 port2:2147483647:deport
514 port2:2147483647:wport
514 port2:2147483647:wport
515
515
516 $ cd ..
516 $ cd ..
517 $ hg init t2
517 $ hg init t2
518 $ cd t2
518 $ cd t2
519 $ hg grep -r tip:0 foobar foo
519 $ hg grep -r tip:0 foobar foo
520 [1]
520 [1]
521 $ hg grep -r tip:0 foobar
521 $ hg grep -r tip:0 foobar
522 [1]
522 [1]
523 $ echo blue >> color
523 $ echo blue >> color
524 $ echo black >> color
524 $ echo black >> color
525 $ hg add color
525 $ hg add color
526 $ hg ci -m 0
526 $ hg ci -m 0
527 $ echo orange >> color
527 $ echo orange >> color
528 $ hg ci -m 1
528 $ hg ci -m 1
529 $ echo black > color
529 $ echo black > color
530 $ hg ci -m 2
530 $ hg ci -m 2
531 $ echo orange >> color
531 $ echo orange >> color
532 $ echo blue >> color
532 $ echo blue >> color
533 $ hg ci -m 3
533 $ hg ci -m 3
534 $ hg grep -r tip:0 orange
534 $ hg grep -r tip:0 orange
535 color:3:orange
535 color:3:orange
536 color:1:orange
536 color:1:orange
537 $ hg grep --all orange
537 $ hg grep --all orange
538 color:3:+:orange
538 color:3:+:orange
539 color:2:-:orange
539 color:2:-:orange
540 color:1:+:orange
540 color:1:+:orange
541 $ hg grep --diff orange --color=debug
541 $ hg grep --diff orange --color=debug
542 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
542 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
543 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange]
543 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange]
544 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
544 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
545
545
546 $ hg grep --diff orange --color=yes
546 $ hg grep --diff orange --color=yes
547 \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)
547 \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)
548 \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)
548 \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)
549 \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)
549 \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)
550
550
551 $ hg grep --diff orange
551 $ hg grep --diff orange
552 color:3:+:orange
552 color:3:+:orange
553 color:2:-:orange
553 color:2:-:orange
554 color:1:+:orange
554 color:1:+:orange
555
555
556 test substring match: '^' should only match at the beginning
556 test substring match: '^' should only match at the beginning
557
557
558 $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
558 $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
559 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
559 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
560 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
560 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
561 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
561 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
562 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack
562 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack
563 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue
563 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue
564 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack
564 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack
565 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range
565 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range
566 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue
566 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue
567 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack
567 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack
568
568
569 match in last "line" without newline
569 match in last "line" without newline
570
570
571 $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
571 $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
572 $ hg ci -Amnoeol
572 $ hg ci -Amnoeol
573 adding noeol
573 adding noeol
574 $ hg grep -r tip:0 loop
574 $ hg grep -r tip:0 loop
575 noeol:4:no infinite loop
575 noeol:4:no infinite loop
576
576
577 $ cd ..
577 $ cd ..
578
578
579 Issue685: traceback in grep -r after rename
579 Issue685: traceback in grep -r after rename
580
580
581 Got a traceback when using grep on a single
581 Got a traceback when using grep on a single
582 revision with renamed files.
582 revision with renamed files.
583
583
584 $ hg init issue685
584 $ hg init issue685
585 $ cd issue685
585 $ cd issue685
586 $ echo octarine > color
586 $ echo octarine > color
587 $ hg ci -Amcolor
587 $ hg ci -Amcolor
588 adding color
588 adding color
589 $ hg rename color colour
589 $ hg rename color colour
590 $ hg ci -Am rename
590 $ hg ci -Am rename
591 $ hg grep -r tip:0 octarine
591 $ hg grep -r tip:0 octarine
592 colour:1:octarine
592 colour:1:octarine
593 color:0:octarine
593 color:0:octarine
594
594
595 Used to crash here
595 Used to crash here
596
596
597 $ hg grep -r 1 octarine
597 $ hg grep -r 1 octarine
598 colour:1:octarine
598 colour:1:octarine
599 $ cd ..
599 $ cd ..
600
600
601
601
602 Issue337: test that grep follows parent-child relationships instead
602 Issue337: test that grep follows parent-child relationships instead
603 of just using revision numbers.
603 of just using revision numbers.
604
604
605 $ hg init issue337
605 $ hg init issue337
606 $ cd issue337
606 $ cd issue337
607
607
608 $ echo white > color
608 $ echo white > color
609 $ hg commit -A -m "0 white"
609 $ hg commit -A -m "0 white"
610 adding color
610 adding color
611
611
612 $ echo red > color
612 $ echo red > color
613 $ hg commit -A -m "1 red"
613 $ hg commit -A -m "1 red"
614
614
615 $ hg update 0
615 $ hg update 0
616 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
616 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
617 $ echo black > color
617 $ echo black > color
618 $ hg commit -A -m "2 black"
618 $ hg commit -A -m "2 black"
619 created new head
619 created new head
620
620
621 $ hg update --clean 1
621 $ hg update --clean 1
622 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
622 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
623 $ echo blue > color
623 $ echo blue > color
624 $ hg commit -A -m "3 blue"
624 $ hg commit -A -m "3 blue"
625
625
626 $ hg grep --all red
626 $ hg grep --all red
627 color:3:-:red
627 color:3:-:red
628 color:1:+:red
628 color:1:+:red
629
629
630 $ hg grep --diff red
630 $ hg grep --diff red
631 color:3:-:red
631 color:3:-:red
632 color:1:+:red
632 color:1:+:red
633
633
634 Issue3885: test that changing revision order does not alter the
634 Issue3885: test that changing revision order does not alter the
635 revisions printed, just their order.
635 revisions printed, just their order.
636
636
637 $ hg grep --all red -r "all()"
637 $ hg grep --all red -r "all()"
638 color:1:+:red
638 color:1:+:red
639 color:3:-:red
639 color:3:-:red
640
640
641 $ hg grep --all red -r "reverse(all())"
641 $ hg grep --all red -r "reverse(all())"
642 color:3:-:red
642 color:3:-:red
643 color:1:+:red
643 color:1:+:red
644
644
645 $ hg grep --diff red -r "all()"
645 $ hg grep --diff red -r "all()"
646 color:1:+:red
646 color:1:+:red
647 color:3:-:red
647 color:3:-:red
648
648
649 $ hg grep --diff red -r "reverse(all())"
649 $ hg grep --diff red -r "reverse(all())"
650 color:3:-:red
650 color:3:-:red
651 color:1:+:red
651 color:1:+:red
652
652
653 $ cd ..
653 $ cd ..
654
654
655 $ hg init a
655 $ hg init a
656 $ cd a
656 $ cd a
657 $ cp "$TESTDIR/binfile.bin" .
657 $ cp "$TESTDIR/binfile.bin" .
658 $ hg add binfile.bin
658 $ hg add binfile.bin
659 $ hg ci -m 'add binfile.bin'
659 $ hg ci -m 'add binfile.bin'
660 $ hg grep "MaCam" --all
660 $ hg grep "MaCam" --all
661 binfile.bin:0:+: Binary file matches
661 binfile.bin:0:+: Binary file matches
662
662
663 $ hg grep "MaCam" --diff
663 $ hg grep "MaCam" --diff
664 binfile.bin:0:+: Binary file matches
664 binfile.bin:0:+: Binary file matches
665
665
666 $ cd ..
666 $ cd ..
667
667
668 Moved line may not be collected by "grep --diff" since it first filters
668 Moved line may not be collected by "grep --diff" since it first filters
669 the contents to be diffed by the pattern. (i.e.
669 the contents to be diffed by the pattern. (i.e.
670 "diff <(grep pat a) <(grep pat b)", not "diff a b | grep pat".)
670 "diff <(grep pat a) <(grep pat b)", not "diff a b | grep pat".)
671 This is much faster than generating full diff per revision.
671 This is much faster than generating full diff per revision.
672
672
673 $ hg init moved-line
673 $ hg init moved-line
674 $ cd moved-line
674 $ cd moved-line
675 $ cat <<'EOF' > a
675 $ cat <<'EOF' > a
676 > foo
676 > foo
677 > bar
677 > bar
678 > baz
678 > baz
679 > EOF
679 > EOF
680 $ hg ci -Am initial
680 $ hg ci -Am initial
681 adding a
681 adding a
682 $ cat <<'EOF' > a
682 $ cat <<'EOF' > a
683 > bar
683 > bar
684 > baz
684 > baz
685 > foo
685 > foo
686 > EOF
686 > EOF
687 $ hg ci -m reorder
687 $ hg ci -m reorder
688
688
689 $ hg diff -c 1
689 $ hg diff -c 1
690 diff -r a593cc55e81b -r 69789a3b6e80 a
690 diff -r a593cc55e81b -r 69789a3b6e80 a
691 --- a/a Thu Jan 01 00:00:00 1970 +0000
691 --- a/a Thu Jan 01 00:00:00 1970 +0000
692 +++ b/a Thu Jan 01 00:00:00 1970 +0000
692 +++ b/a Thu Jan 01 00:00:00 1970 +0000
693 @@ -1,3 +1,3 @@
693 @@ -1,3 +1,3 @@
694 -foo
694 -foo
695 bar
695 bar
696 baz
696 baz
697 +foo
697 +foo
698
698
699 can't find the move of "foo" at the revision 1:
699 can't find the move of "foo" at the revision 1:
700
700
701 $ hg grep --diff foo -r1
701 $ hg grep --diff foo -r1
702 [1]
702 [1]
703
703
704 "bar" isn't moved at the revisoin 1:
704 "bar" isn't moved at the revisoin 1:
705
705
706 $ hg grep --diff bar -r1
706 $ hg grep --diff bar -r1
707 [1]
707 [1]
708
708
709 $ cd ..
709 $ cd ..
710
710
711 Test for showing working of allfiles flag
711 Test for showing working of allfiles flag
712
712
713 $ hg init sng
713 $ hg init sng
714 $ cd sng
714 $ cd sng
715 $ echo "unmod" >> um
715 $ echo "unmod" >> um
716 $ echo old > old
716 $ echo old > old
717 $ hg ci -q -A -m "adds unmod to um"
717 $ hg ci -q -A -m "adds unmod to um"
718 $ echo "something else" >> new
718 $ echo "something else" >> new
719 $ hg ci -A -m "second commit"
719 $ hg ci -A -m "second commit"
720 adding new
720 adding new
721 $ hg grep -r "." "unmod"
721 $ hg grep -r "." "unmod"
722 um:1:unmod
722 um:1:unmod
723
723
724 Existing tracked files in the working directory are searched by default
724 Existing tracked files in the working directory are searched by default
725
725
726 $ echo modified >> new
726 $ echo modified >> new
727 $ echo 'added' > added; hg add added
727 $ echo 'added' > added; hg add added
728 $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
728 $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
729 $ echo 'untracked' > untracked
729 $ echo 'untracked' > untracked
730 $ hg rm old
730 $ hg rm old
731 $ hg grep ''
731 $ hg grep ''
732 added:added
732 added:added
733 new:something else
733 new:something else
734 new:modified
734 new:modified
735 um:unmod
735 um:unmod
736
736
737 #if symlink
737 #if symlink
738 Grepping a symlink greps its destination
738 Grepping a symlink greps its destination
739
739
740 $ rm -f added; ln -s symlink-added added
740 $ rm -f added; ln -s symlink-added added
741 $ hg grep '' | grep added
741 $ hg grep '' | grep added
742 added:symlink-added
742 added:symlink-added
743
743
744 But we reject symlinks as directories components of a tracked file as
744 But we reject symlinks as directories components of a tracked file as
745 usual:
745 usual:
746
746
747 $ mkdir dir; touch dir/f; hg add dir/f
747 $ mkdir dir; touch dir/f; hg add dir/f
748 $ rm -rf dir; ln -s / dir
748 $ rm -rf dir; ln -s / dir
749 $ hg grep ''
749 $ hg grep ''
750 abort: path 'dir/f' traverses symbolic link 'dir'
750 abort: path 'dir/f' traverses symbolic link 'dir'
751 [255]
751 [255]
752 #endif
752 #endif
753
753
754 But we can search files from some other revision with -rREV
754 But we can search files from some other revision with -rREV
755
755
756 $ hg grep -r. mod
756 $ hg grep -r. mod
757 um:1:unmod
757 um:1:unmod
758
758
759 $ hg grep --diff mod
759 $ hg grep --diff mod
760 um:0:+:unmod
760 um:0:+:unmod
761
761
762 $ cd ..
762 $ cd ..
763
763
764 Change Default of grep by ui.tweakdefaults, that is, the files not in current
764 Change Default of grep by ui.tweakdefaults, that is, the files not in current
765 working directory should not be grepp-ed on
765 working directory should not be grepp-ed on
766
766
767 $ hg init ab
767 $ hg init ab
768 $ cd ab
768 $ cd ab
769 $ cat <<'EOF' >> .hg/hgrc
769 $ cat <<'EOF' >> .hg/hgrc
770 > [ui]
770 > [ui]
771 > tweakdefaults = True
771 > tweakdefaults = True
772 > EOF
772 > EOF
773 $ echo "some text">>file1
773 $ echo "some text">>file1
774 $ hg add file1
774 $ hg add file1
775 $ hg commit -m "adds file1"
775 $ hg commit -m "adds file1"
776 $ hg mv file1 file2
776 $ hg mv file1 file2
777
777
778 wdir revision is hidden by default:
778 wdir revision is hidden by default:
779
779
780 $ hg grep "some"
780 $ hg grep "some"
781 file2:some text
781 file2:some text
782
782
783 but it should be available in template dict:
783 but it should be available in template dict:
784
784
785 $ hg grep "some" -Tjson
785 $ hg grep "some" -Tjson
786 [
786 [
787 {
787 {
788 "date": [0, 0],
788 "date": [0, 0],
789 "lineno": 1,
789 "lineno": 1,
790 "node": "ffffffffffffffffffffffffffffffffffffffff",
790 "node": "ffffffffffffffffffffffffffffffffffffffff",
791 "path": "file2",
791 "path": "file2",
792 "rev": 2147483647,
792 "rev": 2147483647,
793 "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
793 "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
794 "user": "test"
794 "user": "test"
795 }
795 }
796 ]
796 ]
797
797
798 $ cd ..
798 $ cd ..
799
799
800 test -rMULTIREV
800 test -rMULTIREV
801
801
802 $ cd sng
802 $ cd sng
803 $ hg rm um
803 $ hg rm um
804 $ hg commit -m "deletes um"
804 $ hg commit -m "deletes um"
805 $ hg grep -r "0:2" "unmod"
805 $ hg grep -r "0:2" "unmod"
806 um:0:unmod
806 um:0:unmod
807 um:1:unmod
807 um:1:unmod
808 $ hg grep -r "0:2" "unmod" um
808 $ hg grep -r "0:2" "unmod" um
809 um:0:unmod
809 um:0:unmod
810 um:1:unmod
810 um:1:unmod
811 $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work
811 $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work
812 um:0:unmod
812 um:0:unmod
813 um:1:unmod
813 um:1:unmod
814 $ cd ..
814 $ cd ..
815
815
816 --follow with/without --diff and/or paths
817 -----------------------------------------
818
819 For each test case, we compare the history traversal of "hg log",
820 "hg grep --diff", and "hg grep" (--all-files).
821
822 "hg grep --diff" should traverse the log in the same way as "hg log".
823 "hg grep" (--all-files) is slightly different in that it includes
824 unmodified changes.
825
826 $ hg init follow
827 $ cd follow
828
829 $ cat <<'EOF' >> .hg/hgrc
830 > [ui]
831 > logtemplate = '{rev}: {join(files % "{status} {path}", ", ")}\n'
832 > EOF
833
834 $ for f in add0 add0-mod1 add0-rm1 add0-mod2 add0-rm2 add0-mod3 add0-mod4 add0-rm4; do
835 > echo data0 >> $f
836 > done
837 $ hg ci -qAm0
838
839 $ hg cp add0 add0-cp1
840 $ hg cp add0 add0-cp1-mod1
841 $ hg cp add0 add0-cp1-mod1-rm3
842 $ hg rm add0-rm1
843 $ for f in *mod1*; do
844 > echo data1 >> $f
845 > done
846 $ hg ci -qAm1
847
848 $ hg update -q 0
849 $ hg cp add0 add0-cp2
850 $ hg cp add0 add0-cp2-mod2
851 $ hg rm add0-rm2
852 $ for f in *mod2*; do
853 > echo data2 >> $f
854 > done
855 $ hg ci -qAm2
856
857 $ hg update -q 1
858 $ hg cp add0-cp1 add0-cp1-cp3
859 $ hg cp add0-cp1-mod1 add0-cp1-mod1-cp3-mod3
860 $ hg rm add0-cp1-mod1-rm3
861 $ for f in *mod3*; do
862 > echo data3 >> $f
863 > done
864 $ hg ci -qAm3
865
866 $ hg cp add0 add0-cp4
867 $ hg cp add0 add0-cp4-mod4
868 $ hg rm add0-rm4
869 $ for f in *mod4*; do
870 > echo data4 >> $f
871 > done
872
873 $ hg log -Gr':wdir()'
874 o 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
875 |
876 @ 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
877 |
878 | o 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
879 | |
880 o | 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
881 |/
882 o 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
883
884
885 follow revision history from wdir parent:
886
887 $ hg log -f
888 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
889 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
890 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
891
892 $ hg grep --diff -f data
893 add0-cp1-mod1-cp3-mod3:3:+:data3
894 add0-mod3:3:+:data3
895 add0-cp1-mod1:1:+:data1
896 add0-cp1-mod1-rm3:1:+:data1
897 add0-mod1:1:+:data1
898 add0:0:+:data0
899 add0-mod1:0:+:data0
900 add0-mod2:0:+:data0
901 add0-mod3:0:+:data0
902 add0-mod4:0:+:data0
903 add0-rm1:0:+:data0
904 add0-rm2:0:+:data0
905 add0-rm4:0:+:data0
906
907 BROKEN: should not fall back to plain grep
908 $ hg grep -f data
909 add0:data0
910 add0-cp1:data0
911 add0-cp1-cp3:data0
912 add0-cp1-mod1:data0
913 add0-cp1-mod1:data1
914 add0-cp1-mod1-cp3-mod3:data0
915 add0-cp1-mod1-cp3-mod3:data1
916 add0-cp1-mod1-cp3-mod3:data3
917 add0-cp4:data0
918 add0-cp4-mod4:data0
919 add0-cp4-mod4:data4
920 add0-mod1:data0
921 add0-mod1:data1
922 add0-mod2:data0
923 add0-mod3:data0
924 add0-mod3:data3
925 add0-mod4:data0
926 add0-mod4:data4
927 add0-rm2:data0
928
929 follow revision history from specified revision:
930
931 $ hg log -fr2
932 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
933 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
934
935 BROKEN: should follow history
936 $ hg grep --diff -fr2 data
937 add0-cp2-mod2:2:+:data2
938 add0-mod2:2:+:data2
939
940 BROKEN: should follow history
941 $ hg grep -fr2 data
942 add0:2:data0
943 add0-cp2:2:data0
944 add0-cp2-mod2:2:data0
945 add0-cp2-mod2:2:data2
946 add0-mod1:2:data0
947 add0-mod2:2:data0
948 add0-mod2:2:data2
949 add0-mod3:2:data0
950 add0-mod4:2:data0
951 add0-rm1:2:data0
952 add0-rm4:2:data0
953
954 follow revision history from wdir:
955
956 $ hg log -fr'wdir()'
957 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
958 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
959 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
960 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
961
962 BROKEN: should follow history
963 BROKEN: should not abort because of removed file
964 $ hg grep --diff -fr'wdir()' data
965 add0-cp4-mod4:2147483647:+:data4
966 add0-mod4:2147483647:+:data4
967 add0-rm4:2147483647:-:abort: add0-rm4@None: not found in manifest!
968 [255]
969
970 BROKEN: should follow history
971 $ hg grep -fr'wdir()' data
972 add0:2147483647:data0
973 add0-cp1:2147483647:data0
974 add0-cp1-cp3:2147483647:data0
975 add0-cp1-mod1:2147483647:data0
976 add0-cp1-mod1:2147483647:data1
977 add0-cp1-mod1-cp3-mod3:2147483647:data0
978 add0-cp1-mod1-cp3-mod3:2147483647:data1
979 add0-cp1-mod1-cp3-mod3:2147483647:data3
980 add0-cp4:2147483647:data0
981 add0-cp4-mod4:2147483647:data0
982 add0-cp4-mod4:2147483647:data4
983 add0-mod1:2147483647:data0
984 add0-mod1:2147483647:data1
985 add0-mod2:2147483647:data0
986 add0-mod3:2147483647:data0
987 add0-mod3:2147483647:data3
988 add0-mod4:2147483647:data0
989 add0-mod4:2147483647:data4
990 add0-rm2:2147483647:data0
991
992 follow revision history from multiple revisions:
993
994 $ hg log -fr'1+2'
995 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
996 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
997 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
998
999 BROKEN: should follow history
1000 BROKEN: should include the revision 2
1001 $ hg grep --diff -fr'1+2' data
1002 add0-cp1-mod1:1:+:data1
1003 add0-cp1-mod1-rm3:1:+:data1
1004 add0-mod1:1:+:data1
1005
1006 BROKEN: should follow history
1007 BROKEN: should include the revision 2
1008 $ hg grep -fr'1+2' data
1009 add0:1:data0
1010 add0-cp1:1:data0
1011 add0-cp1-mod1:1:data0
1012 add0-cp1-mod1:1:data1
1013 add0-cp1-mod1-rm3:1:data0
1014 add0-cp1-mod1-rm3:1:data1
1015 add0-mod1:1:data0
1016 add0-mod1:1:data1
1017 add0-mod2:1:data0
1018 add0-mod3:1:data0
1019 add0-mod4:1:data0
1020 add0-rm2:1:data0
1021 add0-rm4:1:data0
1022
1023 follow file history from wdir parent, unmodified in wdir:
1024
1025 $ hg log -f add0-mod3
1026 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1027 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1028
1029 $ hg grep --diff -f data add0-mod3
1030 add0-mod3:3:+:data3
1031 add0-mod3:0:+:data0
1032
1033 BROKEN: should not fall back to plain grep
1034 $ hg grep -f data add0-mod3
1035 add0-mod3:data0
1036 add0-mod3:data3
1037
1038 follow file history from wdir parent, modified in wdir:
1039
1040 $ hg log -f add0-mod4
1041 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1042
1043 $ hg grep --diff -f data add0-mod4
1044 add0-mod4:0:+:data0
1045
1046 BROKEN: should not fall back to plain grep
1047 $ hg grep -f data add0-mod4
1048 add0-mod4:data0
1049 add0-mod4:data4
1050
1051 follow file history from wdir parent, copied but unmodified:
1052
1053 $ hg log -f add0-cp1-cp3
1054 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1055 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1056 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1057
1058 $ hg grep --diff -f data add0-cp1-cp3
1059 add0:0:+:data0
1060
1061 BROKEN: should not fall back to plain grep
1062 $ hg grep -f data add0-cp1-cp3
1063 add0-cp1-cp3:data0
1064
1065 follow file history from wdir parent, copied and modified:
1066
1067 $ hg log -f add0-cp1-mod1-cp3-mod3
1068 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1069 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1070 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1071
1072 $ hg grep --diff -f data add0-cp1-mod1-cp3-mod3
1073 add0-cp1-mod1-cp3-mod3:3:+:data3
1074 add0-cp1-mod1:1:+:data1
1075 add0:0:+:data0
1076
1077 BROKEN: should not fall back to plain grep
1078 $ hg grep -f data add0-cp1-mod1-cp3-mod3
1079 add0-cp1-mod1-cp3-mod3:data0
1080 add0-cp1-mod1-cp3-mod3:data1
1081 add0-cp1-mod1-cp3-mod3:data3
1082
1083 follow file history from wdir parent, copied in wdir:
1084
1085 $ hg log -f add0-cp4
1086 abort: cannot follow nonexistent file: "add0-cp4"
1087 [255]
1088
1089 $ hg grep --diff -f data add0-cp4
1090 abort: cannot follow file not in parent revision: "add0-cp4"
1091 [255]
1092
1093 BROKEN: should not fall back to plain grep
1094 $ hg grep -f data add0-cp4
1095 add0-cp4:data0
1096
1097 follow file history from wdir parent, removed:
1098
1099 $ hg log -f add0-cp1-mod1-rm3
1100 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1101 [255]
1102
1103 $ hg grep --diff -f data add0-cp1-mod1-rm3
1104 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1105 [255]
1106
1107 BROKEN: should not fall back to plain grep
1108 $ hg grep -f data add0-cp1-mod1-rm3
1109 [1]
1110
1111 follow file history from wdir parent (explicit), removed:
1112
1113 $ hg log -fr. add0-cp1-mod1-rm3
1114 abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
1115 [255]
1116
1117 $ hg grep --diff -fr. data add0-cp1-mod1-rm3
1118 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1119 [255]
1120
1121 BROKEN: should abort
1122 $ hg grep -fr. data add0-cp1-mod1-rm3
1123 [1]
1124
1125 follow file history from wdir parent, removed in wdir:
1126
1127 $ hg log -f add0-rm4
1128 abort: cannot follow file not in parent revision: "add0-rm4"
1129 [255]
1130
1131 BROKEN: may be okay, but different behavior from "hg log"
1132 $ hg grep --diff -f data add0-rm4
1133 add0-rm4:0:+:data0
1134
1135 BROKEN: should not fall back to plain grep
1136 $ hg grep -f data add0-rm4
1137 [1]
1138
1139 follow file history from wdir parent (explicit), removed in wdir:
1140
1141 $ hg log -fr. add0-rm4
1142 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1143
1144 BROKEN: should follow history
1145 $ hg grep --diff -fr. data add0-rm4
1146 [1]
1147
1148 BROKEN: should follow history
1149 $ hg grep -fr. data add0-rm4
1150 add0-rm4:3:data0
1151
1152 follow file history from wdir parent, multiple files:
1153
1154 $ hg log -f add0-mod3 add0-cp1-mod1
1155 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1156 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1157 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1158
1159 $ hg grep --diff -f data add0-mod3 add0-cp1-mod1
1160 add0-mod3:3:+:data3
1161 add0-cp1-mod1:1:+:data1
1162 add0:0:+:data0
1163 add0-mod3:0:+:data0
1164
1165 BROKEN: should not fall back to plain grep
1166 $ hg grep -f data add0-mod3 add0-cp1-mod1
1167 add0-cp1-mod1:data0
1168 add0-cp1-mod1:data1
1169 add0-mod3:data0
1170 add0-mod3:data3
1171
1172 follow file history from specified revision, modified:
1173
1174 $ hg log -fr2 add0-mod2
1175 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1176 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1177
1178 BROKEN: should follow history from the specified revision
1179 $ hg grep --diff -fr2 data add0-mod2
1180 [1]
1181
1182 BROKEN: should follow history
1183 $ hg grep -fr2 data add0-mod2
1184 add0-mod2:2:data0
1185 add0-mod2:2:data2
1186
1187 follow file history from specified revision, copied but unmodified:
1188
1189 $ hg log -fr2 add0-cp2
1190 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1191 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1192
1193 BROKEN: should follow history from the specified revision
1194 $ hg grep --diff -fr2 data add0-cp2
1195 abort: cannot follow file not in parent revision: "add0-cp2"
1196 [255]
1197
1198 BROKEN: should follow history across renames
1199 $ hg grep -fr2 data add0-cp2
1200 add0-cp2:2:data0
1201
1202 follow file history from specified revision, copied and modified:
1203
1204 $ hg log -fr2 add0-cp2-mod2
1205 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1206 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1207
1208 BROKEN: should follow history from the specified revision
1209 $ hg grep --diff -fr2 data add0-cp2-mod2
1210 abort: cannot follow file not in parent revision: "add0-cp2-mod2"
1211 [255]
1212
1213 BROKEN: should follow history across renames
1214 $ hg grep -fr2 data add0-cp2-mod2
1215 add0-cp2-mod2:2:data0
1216 add0-cp2-mod2:2:data2
1217
1218 follow file history from specified revision, removed:
1219
1220 $ hg log -fr2 add0-rm2
1221 abort: cannot follow file not in any of the specified revisions: "add0-rm2"
1222 [255]
1223
1224 BROKEN: should abort
1225 $ hg grep --diff -fr2 data add0-rm2
1226 [1]
1227
1228 BROKEN: should abort
1229 $ hg grep -fr2 data add0-rm2
1230 [1]
1231
1232 follow file history from specified revision, multiple files:
1233
1234 $ hg log -fr2 add0-cp2 add0-mod2
1235 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1236 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1237
1238 BROKEN: should follow history from the specified revision
1239 $ hg grep --diff -fr2 data add0-cp2 add0-mod2
1240 abort: cannot follow file not in parent revision: "add0-cp2"
1241 [255]
1242
1243 BROKEN: should follow history
1244 $ hg grep -fr2 data add0-cp2 add0-mod2
1245 add0-cp2:2:data0
1246 add0-mod2:2:data0
1247 add0-mod2:2:data2
1248
1249 follow file history from wdir, unmodified:
1250
1251 $ hg log -fr'wdir()' add0-mod3
1252 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1253 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1254 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1255
1256 BROKEN: should follow history
1257 $ hg grep --diff -fr'wdir()' data add0-mod3
1258 [1]
1259
1260 BROKEN: should follow history
1261 $ hg grep -fr'wdir()' data add0-mod3
1262 add0-mod3:2147483647:data0
1263 add0-mod3:2147483647:data3
1264
1265 follow file history from wdir, modified:
1266
1267 $ hg log -fr'wdir()' add0-mod4
1268 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1269 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1270
1271 BROKEN: should follow history and show the changes in wdir
1272 $ hg grep --diff -fr'wdir()' data add0-mod4
1273 [1]
1274
1275 BROKEN: should follow history
1276 $ hg grep -fr'wdir()' data add0-mod4
1277 add0-mod4:2147483647:data0
1278 add0-mod4:2147483647:data4
1279
1280 follow file history from wdir, copied but unmodified:
1281
1282 $ hg log -fr'wdir()' add0-cp4
1283 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1284 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1285
1286 BROKEN: should follow history
1287 $ hg grep --diff -fr'wdir()' data add0-cp4
1288 abort: cannot follow file not in parent revision: "add0-cp4"
1289 [255]
1290
1291 BROKEN: should follow history across renames
1292 $ hg grep -fr'wdir()' data add0-cp4
1293 add0-cp4:2147483647:data0
1294
1295 follow file history from wdir, copied and modified:
1296
1297 $ hg log -fr'wdir()' add0-cp4-mod4
1298 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1299 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1300
1301 BROKEN: should follow history
1302 $ hg grep --diff -fr'wdir()' data add0-cp4-mod4
1303 abort: cannot follow file not in parent revision: "add0-cp4-mod4"
1304 [255]
1305
1306 BROKEN: should follow history across renames
1307 $ hg grep -fr'wdir()' data add0-cp4-mod4
1308 add0-cp4-mod4:2147483647:data0
1309 add0-cp4-mod4:2147483647:data4
1310
1311 follow file history from wdir, multiple files:
1312
1313 $ hg log -fr'wdir()' add0-cp4 add0-mod4 add0-mod3
1314 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1315 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1316 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1317
1318 BROKEN: should follow history
1319 $ hg grep --diff -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1320 abort: cannot follow file not in parent revision: "add0-cp4"
1321 [255]
1322
1323 BROKEN: should follow history
1324 $ hg grep -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1325 add0-cp4:2147483647:data0
1326 add0-mod3:2147483647:data0
1327 add0-mod3:2147483647:data3
1328 add0-mod4:2147483647:data0
1329 add0-mod4:2147483647:data4
1330
1331 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now