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