Show More
@@ -0,0 +1,91 b'' | |||
|
1 | #testcases bdiff xdiff | |
|
2 | ||
|
3 | #if xdiff | |
|
4 | #require xdiff | |
|
5 | $ cat >> $HGRCPATH <<EOF | |
|
6 | > [experimental] | |
|
7 | > xdiff = true | |
|
8 | > EOF | |
|
9 | #endif | |
|
10 | ||
|
11 | Test case that makes use of the weakness of patience diff algorithm | |
|
12 | ||
|
13 | $ hg init | |
|
14 | >>> open('a', 'wb').write(b'\n'.join(list(b'a' + b'x' * 10 + b'u' + b'x' * 30 + b'a\n'))) | |
|
15 | $ hg commit -m 1 -A a | |
|
16 | >>> open('a', 'wb').write(b'\n'.join(list(b'b' + b'x' * 30 + b'u' + b'x' * 10 + b'b\n'))) | |
|
17 | #if xdiff | |
|
18 | $ hg diff | |
|
19 | diff -r f0aeecb49805 a | |
|
20 | --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
|
21 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
|
22 | @@ -1,4 +1,4 @@ | |
|
23 | -a | |
|
24 | +b | |
|
25 | x | |
|
26 | x | |
|
27 | x | |
|
28 | @@ -9,7 +9,6 @@ | |
|
29 | x | |
|
30 | x | |
|
31 | x | |
|
32 | -u | |
|
33 | x | |
|
34 | x | |
|
35 | x | |
|
36 | @@ -30,6 +29,7 @@ | |
|
37 | x | |
|
38 | x | |
|
39 | x | |
|
40 | +u | |
|
41 | x | |
|
42 | x | |
|
43 | x | |
|
44 | @@ -40,5 +40,5 @@ | |
|
45 | x | |
|
46 | x | |
|
47 | x | |
|
48 | -a | |
|
49 | +b | |
|
50 | ||
|
51 | #else | |
|
52 | $ hg diff | |
|
53 | diff -r f0aeecb49805 a | |
|
54 | --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
|
55 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
|
56 | @@ -1,15 +1,4 @@ | |
|
57 | -a | |
|
58 | -x | |
|
59 | -x | |
|
60 | -x | |
|
61 | -x | |
|
62 | -x | |
|
63 | -x | |
|
64 | -x | |
|
65 | -x | |
|
66 | -x | |
|
67 | -x | |
|
68 | -u | |
|
69 | +b | |
|
70 | x | |
|
71 | x | |
|
72 | x | |
|
73 | @@ -40,5 +29,16 @@ | |
|
74 | x | |
|
75 | x | |
|
76 | x | |
|
77 | -a | |
|
78 | +u | |
|
79 | +x | |
|
80 | +x | |
|
81 | +x | |
|
82 | +x | |
|
83 | +x | |
|
84 | +x | |
|
85 | +x | |
|
86 | +x | |
|
87 | +x | |
|
88 | +x | |
|
89 | +b | |
|
90 | ||
|
91 | #endif |
@@ -0,0 +1,339 b'' | |||
|
1 | #testcases bdiff xdiff | |
|
2 | ||
|
3 | #if xdiff | |
|
4 | #require xdiff | |
|
5 | $ cat >> $HGRCPATH <<EOF | |
|
6 | > [experimental] | |
|
7 | > xdiff = true | |
|
8 | > EOF | |
|
9 | #endif | |
|
10 | ||
|
11 | $ hg init | |
|
12 | ||
|
13 | $ cat > a.c <<'EOF' | |
|
14 | > /* | |
|
15 | > * This function returns 1. | |
|
16 | > */ | |
|
17 | > int f() { | |
|
18 | > return 1; | |
|
19 | > } | |
|
20 | > /* | |
|
21 | > * This function returns 2. | |
|
22 | > */ | |
|
23 | > int g() { | |
|
24 | > return 2; | |
|
25 | > } | |
|
26 | > /* | |
|
27 | > * This function returns 3. | |
|
28 | > */ | |
|
29 | > int h() { | |
|
30 | > return 3; | |
|
31 | > } | |
|
32 | > EOF | |
|
33 | ||
|
34 | $ cat > b.c <<'EOF' | |
|
35 | > if (x) { | |
|
36 | > do_something(); | |
|
37 | > } | |
|
38 | > | |
|
39 | > if (y) { | |
|
40 | > do_something_else(); | |
|
41 | > } | |
|
42 | > EOF | |
|
43 | ||
|
44 | $ cat > c.rb <<'EOF' | |
|
45 | > #!ruby | |
|
46 | > ["foo", "bar", "baz"].map do |i| | |
|
47 | > i.upcase | |
|
48 | > end | |
|
49 | > EOF | |
|
50 | ||
|
51 | $ cat > d.py <<'EOF' | |
|
52 | > try: | |
|
53 | > import foo | |
|
54 | > except ImportError: | |
|
55 | > pass | |
|
56 | > try: | |
|
57 | > import bar | |
|
58 | > except ImportError: | |
|
59 | > pass | |
|
60 | > EOF | |
|
61 | ||
|
62 | The below two files are taken from git: t/t4061-diff-indent.sh | |
|
63 | ||
|
64 | $ cat > spaces.txt <<'EOF' | |
|
65 | > 1 | |
|
66 | > 2 | |
|
67 | > a | |
|
68 | > | |
|
69 | > b | |
|
70 | > 3 | |
|
71 | > 4 | |
|
72 | > EOF | |
|
73 | ||
|
74 | $ cat > functions.c <<'EOF' | |
|
75 | > 1 | |
|
76 | > 2 | |
|
77 | > /* function */ | |
|
78 | > foo() { | |
|
79 | > foo | |
|
80 | > } | |
|
81 | > | |
|
82 | > 3 | |
|
83 | > 4 | |
|
84 | > EOF | |
|
85 | ||
|
86 | $ hg commit -m 1 -A . -q | |
|
87 | ||
|
88 | $ cat > a.c <<'EOF' | |
|
89 | > /* | |
|
90 | > * This function returns 1. | |
|
91 | > */ | |
|
92 | > int f() { | |
|
93 | > return 1; | |
|
94 | > } | |
|
95 | > /* | |
|
96 | > * This function returns 3. | |
|
97 | > */ | |
|
98 | > int h() { | |
|
99 | > return 3; | |
|
100 | > } | |
|
101 | > EOF | |
|
102 | ||
|
103 | $ cat > b.c <<'EOF' | |
|
104 | > if (x) { | |
|
105 | > do_something(); | |
|
106 | > } | |
|
107 | > | |
|
108 | > if (y) { | |
|
109 | > do_another_thing(); | |
|
110 | > } | |
|
111 | > | |
|
112 | > if (y) { | |
|
113 | > do_something_else(); | |
|
114 | > } | |
|
115 | > EOF | |
|
116 | ||
|
117 | $ cat > c.rb <<'EOF' | |
|
118 | > #!ruby | |
|
119 | > ["foo", "bar", "baz"].map do |i| | |
|
120 | > i | |
|
121 | > end | |
|
122 | > ["foo", "bar", "baz"].map do |i| | |
|
123 | > i.upcase | |
|
124 | > end | |
|
125 | > EOF | |
|
126 | ||
|
127 | $ cat > d.py <<'EOF' | |
|
128 | > try: | |
|
129 | > import foo | |
|
130 | > except ImportError: | |
|
131 | > pass | |
|
132 | > try: | |
|
133 | > import baz | |
|
134 | > except ImportError: | |
|
135 | > pass | |
|
136 | > try: | |
|
137 | > import bar | |
|
138 | > except ImportError: | |
|
139 | > pass | |
|
140 | > EOF | |
|
141 | ||
|
142 | $ cat > spaces.txt <<'EOF' | |
|
143 | > 1 | |
|
144 | > 2 | |
|
145 | > a | |
|
146 | > | |
|
147 | > b | |
|
148 | > a | |
|
149 | > | |
|
150 | > b | |
|
151 | > 3 | |
|
152 | > 4 | |
|
153 | > EOF | |
|
154 | ||
|
155 | $ cat > functions.c <<'EOF' | |
|
156 | > 1 | |
|
157 | > 2 | |
|
158 | > /* function */ | |
|
159 | > bar() { | |
|
160 | > foo | |
|
161 | > } | |
|
162 | > | |
|
163 | > /* function */ | |
|
164 | > foo() { | |
|
165 | > foo | |
|
166 | > } | |
|
167 | > | |
|
168 | > 3 | |
|
169 | > 4 | |
|
170 | > EOF | |
|
171 | ||
|
172 | #if xdiff | |
|
173 | $ hg diff --git | |
|
174 | diff --git a/a.c b/a.c | |
|
175 | --- a/a.c | |
|
176 | +++ b/a.c | |
|
177 | @@ -4,12 +4,6 @@ | |
|
178 | int f() { | |
|
179 | return 1; | |
|
180 | } | |
|
181 | -/* | |
|
182 | - * This function returns 2. | |
|
183 | - */ | |
|
184 | -int g() { | |
|
185 | - return 2; | |
|
186 | -} | |
|
187 | /* | |
|
188 | * This function returns 3. | |
|
189 | */ | |
|
190 | diff --git a/b.c b/b.c | |
|
191 | --- a/b.c | |
|
192 | +++ b/b.c | |
|
193 | @@ -2,6 +2,10 @@ | |
|
194 | do_something(); | |
|
195 | } | |
|
196 | ||
|
197 | +if (y) { | |
|
198 | + do_another_thing(); | |
|
199 | +} | |
|
200 | + | |
|
201 | if (y) { | |
|
202 | do_something_else(); | |
|
203 | } | |
|
204 | diff --git a/c.rb b/c.rb | |
|
205 | --- a/c.rb | |
|
206 | +++ b/c.rb | |
|
207 | @@ -1,4 +1,7 @@ | |
|
208 | #!ruby | |
|
209 | +["foo", "bar", "baz"].map do |i| | |
|
210 | + i | |
|
211 | +end | |
|
212 | ["foo", "bar", "baz"].map do |i| | |
|
213 | i.upcase | |
|
214 | end | |
|
215 | diff --git a/d.py b/d.py | |
|
216 | --- a/d.py | |
|
217 | +++ b/d.py | |
|
218 | @@ -2,6 +2,10 @@ | |
|
219 | import foo | |
|
220 | except ImportError: | |
|
221 | pass | |
|
222 | +try: | |
|
223 | + import baz | |
|
224 | +except ImportError: | |
|
225 | + pass | |
|
226 | try: | |
|
227 | import bar | |
|
228 | except ImportError: | |
|
229 | diff --git a/functions.c b/functions.c | |
|
230 | --- a/functions.c | |
|
231 | +++ b/functions.c | |
|
232 | @@ -1,5 +1,10 @@ | |
|
233 | 1 | |
|
234 | 2 | |
|
235 | +/* function */ | |
|
236 | +bar() { | |
|
237 | + foo | |
|
238 | +} | |
|
239 | + | |
|
240 | /* function */ | |
|
241 | foo() { | |
|
242 | foo | |
|
243 | diff --git a/spaces.txt b/spaces.txt | |
|
244 | --- a/spaces.txt | |
|
245 | +++ b/spaces.txt | |
|
246 | @@ -2,6 +2,9 @@ | |
|
247 | 2 | |
|
248 | a | |
|
249 | ||
|
250 | +b | |
|
251 | +a | |
|
252 | + | |
|
253 | b | |
|
254 | 3 | |
|
255 | 4 | |
|
256 | #else | |
|
257 | $ hg diff --git | |
|
258 | diff --git a/a.c b/a.c | |
|
259 | --- a/a.c | |
|
260 | +++ b/a.c | |
|
261 | @@ -5,12 +5,6 @@ | |
|
262 | return 1; | |
|
263 | } | |
|
264 | /* | |
|
265 | - * This function returns 2. | |
|
266 | - */ | |
|
267 | -int g() { | |
|
268 | - return 2; | |
|
269 | -} | |
|
270 | -/* | |
|
271 | * This function returns 3. | |
|
272 | */ | |
|
273 | int h() { | |
|
274 | diff --git a/b.c b/b.c | |
|
275 | --- a/b.c | |
|
276 | +++ b/b.c | |
|
277 | @@ -3,5 +3,9 @@ | |
|
278 | } | |
|
279 | ||
|
280 | if (y) { | |
|
281 | + do_another_thing(); | |
|
282 | +} | |
|
283 | + | |
|
284 | +if (y) { | |
|
285 | do_something_else(); | |
|
286 | } | |
|
287 | diff --git a/c.rb b/c.rb | |
|
288 | --- a/c.rb | |
|
289 | +++ b/c.rb | |
|
290 | @@ -1,4 +1,7 @@ | |
|
291 | #!ruby | |
|
292 | ["foo", "bar", "baz"].map do |i| | |
|
293 | + i | |
|
294 | +end | |
|
295 | +["foo", "bar", "baz"].map do |i| | |
|
296 | i.upcase | |
|
297 | end | |
|
298 | diff --git a/d.py b/d.py | |
|
299 | --- a/d.py | |
|
300 | +++ b/d.py | |
|
301 | @@ -3,6 +3,10 @@ | |
|
302 | except ImportError: | |
|
303 | pass | |
|
304 | try: | |
|
305 | + import baz | |
|
306 | +except ImportError: | |
|
307 | + pass | |
|
308 | +try: | |
|
309 | import bar | |
|
310 | except ImportError: | |
|
311 | pass | |
|
312 | diff --git a/functions.c b/functions.c | |
|
313 | --- a/functions.c | |
|
314 | +++ b/functions.c | |
|
315 | @@ -1,6 +1,11 @@ | |
|
316 | 1 | |
|
317 | 2 | |
|
318 | /* function */ | |
|
319 | +bar() { | |
|
320 | + foo | |
|
321 | +} | |
|
322 | + | |
|
323 | +/* function */ | |
|
324 | foo() { | |
|
325 | foo | |
|
326 | } | |
|
327 | diff --git a/spaces.txt b/spaces.txt | |
|
328 | --- a/spaces.txt | |
|
329 | +++ b/spaces.txt | |
|
330 | @@ -3,5 +3,8 @@ | |
|
331 | a | |
|
332 | ||
|
333 | b | |
|
334 | +a | |
|
335 | + | |
|
336 | +b | |
|
337 | 3 | |
|
338 | 4 | |
|
339 | #endif |
@@ -708,3 +708,12 b' def has_clang_libfuzzer():' | |||
|
708 | 708 | # libfuzzer is new in clang 6 |
|
709 | 709 | return int(mat.group(1)) > 5 |
|
710 | 710 | return False |
|
711 | ||
|
712 | @check("xdiff", "xdiff algorithm") | |
|
713 | def has_xdiff(): | |
|
714 | try: | |
|
715 | from mercurial import policy | |
|
716 | bdiff = policy.importmod('bdiff') | |
|
717 | return bdiff.xdiffblocks('', '') == [(0, 0, 0, 0)] | |
|
718 | except (ImportError, AttributeError) as ex: | |
|
719 | return False |
General Comments 0
You need to be logged in to leave comments.
Login now