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

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

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