##// END OF EJS Templates
test-extdiff: deduplicate tests
Matt Harbison -
r32209:c05f71e5 default
parent child Browse files
Show More
@@ -1,415 +1,378 b''
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "extdiff=" >> $HGRCPATH
3 3
4 4 $ hg init a
5 5 $ cd a
6 6 $ echo a > a
7 7 $ echo b > b
8 8 $ hg add
9 9 adding a
10 10 adding b
11 11
12 12 Should diff cloned directories:
13 13
14 14 $ hg extdiff -o -r $opt
15 15 Only in a: a
16 16 Only in a: b
17 17 [1]
18 18
19 19 $ cat <<EOF >> $HGRCPATH
20 20 > [extdiff]
21 21 > cmd.falabala = echo
22 22 > opts.falabala = diffing
23 23 > cmd.edspace = echo
24 24 > opts.edspace = "name <user@example.com>"
25 25 > EOF
26 26
27 27 $ hg falabala
28 28 diffing a.000000000000 a
29 29 [1]
30 30
31 31 $ hg help falabala
32 32 hg falabala [OPTION]... [FILE]...
33 33
34 34 use external program to diff repository (or selected files)
35 35
36 36 Show differences between revisions for the specified files, using the
37 37 following program:
38 38
39 39 'echo'
40 40
41 41 When two revision arguments are given, then changes are shown between
42 42 those revisions. If only one revision is specified then that revision is
43 43 compared to the working directory, and, when no revisions are specified,
44 44 the working directory files are compared to its parent.
45 45
46 46 options ([+] can be repeated):
47 47
48 48 -o --option OPT [+] pass option to comparison program
49 49 -r --rev REV [+] revision
50 50 -c --change REV change made by revision
51 51 --patch compare patches for two revisions
52 52 -I --include PATTERN [+] include names matching the given patterns
53 53 -X --exclude PATTERN [+] exclude names matching the given patterns
54 54 -S --subrepos recurse into subrepositories
55 55
56 56 (some details hidden, use --verbose to show complete help)
57 57
58 58 $ hg ci -d '0 0' -mtest1
59 59
60 60 $ echo b >> a
61 61 $ hg ci -d '1 0' -mtest2
62 62
63 63 Should diff cloned files directly:
64 64
65 #if windows
66 65 $ hg falabala -r 0:1
67 diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob)
66 diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
67 diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
68 68 [1]
69 #else
70 $ hg falabala -r 0:1
71 diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
72 [1]
73 #endif
74 69
75 70 Specifying an empty revision should abort.
76 71
77 72 $ hg extdiff -p diff --patch --rev 'ancestor()' --rev 1
78 73 abort: empty revision on one side of range
79 74 [255]
80 75
81 76 Test diff during merge:
82 77
83 78 $ hg update -C 0
84 79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
85 80 $ echo c >> c
86 81 $ hg add c
87 82 $ hg ci -m "new branch" -d '1 0'
88 83 created new head
89 84 $ hg merge 1
90 85 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 86 (branch merge, don't forget to commit)
92 87
93 88 Should diff cloned file against wc file:
94 89
95 #if windows
96 90 $ hg falabala
97 diffing "*\\extdiff.*\\a.2a13a4d2da36\\a" "*\\a\\a" (glob)
91 diffing "*\\extdiff.*\\a.2a13a4d2da36\\a" "*\\a\\a" (glob) (windows !)
92 diffing */extdiff.*/a.2a13a4d2da36/a */a/a (glob) (no-windows !)
98 93 [1]
99 #else
100 $ hg falabala
101 diffing */extdiff.*/a.2a13a4d2da36/a */a/a (glob)
102 [1]
103 #endif
104 94
105 95
106 96 Test --change option:
107 97
108 98 $ hg ci -d '2 0' -mtest3
109 #if windows
99
110 100 $ hg falabala -c 1
111 diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob)
101 diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
102 diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
112 103 [1]
113 #else
114 $ hg falabala -c 1
115 diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
116 [1]
117 #endif
118 104
119 105 Check diff are made from the first parent:
120 106
121 #if windows
122 107 $ hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
123 diffing "*\\extdiff.*\\a.2a13a4d2da36\\a" "a.46c0e4daeb72\\a" (glob)
108 diffing "*\\extdiff.*\\a.2a13a4d2da36\\a" "a.46c0e4daeb72\\a" (glob) (windows !)
109 diffing */extdiff.*/a.2a13a4d2da36/a a.46c0e4daeb72/a (glob) (no-windows !)
124 110 diff-like tools yield a non-zero exit code
125 #else
126 $ hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
127 diffing */extdiff.*/a.2a13a4d2da36/a a.46c0e4daeb72/a (glob)
128 diff-like tools yield a non-zero exit code
129 #endif
130 111
131 112 issue3153: ensure using extdiff with removed subrepos doesn't crash:
132 113
133 114 $ hg init suba
134 115 $ cd suba
135 116 $ echo suba > suba
136 117 $ hg add
137 118 adding suba
138 119 $ hg ci -m "adding suba file"
139 120 $ cd ..
140 121 $ echo suba=suba > .hgsub
141 122 $ hg add
142 123 adding .hgsub
143 124 $ hg ci -Sm "adding subrepo"
144 125 $ echo > .hgsub
145 126 $ hg ci -m "removing subrepo"
146 127 $ hg falabala -r 4 -r 5 -S
147 128 diffing a.398e36faf9c6 a.5ab95fb166c4
148 129 [1]
149 130
150 131 issue4463: usage of command line configuration without additional quoting
151 132
152 133 $ cat <<EOF >> $HGRCPATH
153 134 > [extdiff]
154 135 > cmd.4463a = echo
155 136 > opts.4463a = a-naked 'single quoted' "double quoted"
156 137 > 4463b = echo b-naked 'single quoted' "double quoted"
157 138 > echo =
158 139 > EOF
159 140 $ hg update -q -C 0
160 141 $ echo a >> a
161 #if windows
142
162 143 $ hg --debug 4463a | grep '^running'
163 running 'echo a-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob)
144 running 'echo a-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
145 running 'echo a-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
164 146 $ hg --debug 4463b | grep '^running'
165 running 'echo b-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob)
147 running 'echo b-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
148 running 'echo b-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
166 149 $ hg --debug echo | grep '^running'
167 running '*echo* "*\\a" "*\\a"' in */extdiff.* (glob)
168 #else
169 $ hg --debug 4463a | grep '^running'
170 running 'echo a-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
171 $ hg --debug 4463b | grep '^running'
172 running 'echo b-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
173 $ hg --debug echo | grep '^running'
174 running '*echo */a $TESTTMP/a/a' in */extdiff.* (glob)
175 #endif
150 running '*echo* "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
151 running '*echo */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
176 152
177 153 (getting options from other than extdiff section)
178 154
179 155 $ cat <<EOF >> $HGRCPATH
180 156 > [extdiff]
181 157 > # using diff-tools diffargs
182 158 > 4463b2 = echo
183 159 > # using merge-tools diffargs
184 160 > 4463b3 = echo
185 161 > # no diffargs
186 162 > 4463b4 = echo
187 163 > [diff-tools]
188 164 > 4463b2.diffargs = b2-naked 'single quoted' "double quoted"
189 165 > [merge-tools]
190 166 > 4463b3.diffargs = b3-naked 'single quoted' "double quoted"
191 167 > EOF
192 #if windows
168
193 169 $ hg --debug 4463b2 | grep '^running'
194 running 'echo b2-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob)
170 running 'echo b2-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
171 running 'echo b2-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
195 172 $ hg --debug 4463b3 | grep '^running'
196 running 'echo b3-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob)
173 running 'echo b3-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
174 running 'echo b3-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
197 175 $ hg --debug 4463b4 | grep '^running'
198 running 'echo "*\\a" "*\\a"' in */extdiff.* (glob)
176 running 'echo "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
177 running 'echo */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
199 178 $ hg --debug 4463b4 --option b4-naked --option 'being quoted' | grep '^running'
200 running 'echo b4-naked "being quoted" "*\\a" "*\\a"' in */extdiff.* (glob)
179 running 'echo b4-naked "being quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
180 running "echo b4-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob) (no-windows !)
201 181 $ hg --debug extdiff -p echo --option echo-naked --option 'being quoted' | grep '^running'
202 running 'echo echo-naked "being quoted" "*\\a" "*\\a"' in */extdiff.* (glob)
203 #else
204 $ hg --debug 4463b2 | grep '^running'
205 running 'echo b2-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
206 $ hg --debug 4463b3 | grep '^running'
207 running 'echo b3-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
208 $ hg --debug 4463b4 | grep '^running'
209 running 'echo */a $TESTTMP/a/a' in */extdiff.* (glob)
210 $ hg --debug 4463b4 --option b4-naked --option 'being quoted' | grep '^running'
211 running "echo b4-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob)
212 $ hg --debug extdiff -p echo --option echo-naked --option 'being quoted' | grep '^running'
213 running "echo echo-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob)
214 #endif
182 running 'echo echo-naked "being quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
183 running "echo echo-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob) (no-windows !)
215 184
216 185 $ touch 'sp ace'
217 186 $ hg add 'sp ace'
218 187 $ hg ci -m 'sp ace'
219 188 created new head
220 189 $ echo > 'sp ace'
221 190
222 191 Test pre-72a89cf86fcd backward compatibility with half-baked manual quoting
223 192
224 193 $ cat <<EOF >> $HGRCPATH
225 194 > [extdiff]
226 195 > odd =
227 196 > [merge-tools]
228 197 > odd.diffargs = --foo='\$clabel' '\$clabel' "--bar=\$clabel" "\$clabel"
229 198 > odd.executable = echo
230 199 > EOF
231 #if windows
200
232 201 $ hg --debug odd | grep '^running'
233 running '"*\\echo.exe" --foo="sp ace" "sp ace" --bar="sp ace" "sp ace"' in * (glob)
234 #else
235 $ hg --debug odd | grep '^running'
236 running "*/echo --foo='sp ace' 'sp ace' --bar='sp ace' 'sp ace'" in * (glob)
237 #endif
202 running '"*\\echo.exe" --foo="sp ace" "sp ace" --bar="sp ace" "sp ace"' in * (glob) (windows !)
203 running "*/echo --foo='sp ace' 'sp ace' --bar='sp ace' 'sp ace'" in * (glob) (no-windows !)
238 204
239 205 Empty argument must be quoted
240 206
241 207 $ cat <<EOF >> $HGRCPATH
242 208 > [extdiff]
243 209 > kdiff3 = echo
244 210 > [merge-tools]
245 211 > kdiff3.diffargs=--L1 \$plabel1 --L2 \$clabel \$parent \$child
246 212 > EOF
247 #if windows
213
248 214 $ hg --debug kdiff3 -r0 | grep '^running'
249 running 'echo --L1 "@0" --L2 "" a.8a5febb7f867 a' in * (glob)
250 #else
251 $ hg --debug kdiff3 -r0 | grep '^running'
252 running "echo --L1 '@0' --L2 '' a.8a5febb7f867 a" in * (glob)
253 #endif
215 running 'echo --L1 "@0" --L2 "" a.8a5febb7f867 a' in * (glob) (windows !)
216 running "echo --L1 '@0' --L2 '' a.8a5febb7f867 a" in * (glob) (no-windows !)
254 217
255 218 #if execbit
256 219
257 220 Test extdiff of multiple files in tmp dir:
258 221
259 222 $ hg update -C 0 > /dev/null
260 223 $ echo changed > a
261 224 $ echo changed > b
262 225 $ chmod +x b
263 226
264 227 Diff in working directory, before:
265 228
266 229 $ hg diff --git
267 230 diff --git a/a b/a
268 231 --- a/a
269 232 +++ b/a
270 233 @@ -1,1 +1,1 @@
271 234 -a
272 235 +changed
273 236 diff --git a/b b/b
274 237 old mode 100644
275 238 new mode 100755
276 239 --- a/b
277 240 +++ b/b
278 241 @@ -1,1 +1,1 @@
279 242 -b
280 243 +changed
281 244
282 245
283 246 Edit with extdiff -p:
284 247
285 248 Prepare custom diff/edit tool:
286 249
287 250 $ cat > 'diff tool.py' << EOT
288 251 > #!/usr/bin/env python
289 252 > import time
290 253 > time.sleep(1) # avoid unchanged-timestamp problems
291 254 > file('a/a', 'ab').write('edited\n')
292 255 > file('a/b', 'ab').write('edited\n')
293 256 > EOT
294 257
295 258 $ chmod +x 'diff tool.py'
296 259
297 260 will change to /tmp/extdiff.TMP and populate directories a.TMP and a
298 261 and start tool
299 262
300 263 $ hg extdiff -p "`pwd`/diff tool.py"
301 264 [1]
302 265
303 266 Diff in working directory, after:
304 267
305 268 $ hg diff --git
306 269 diff --git a/a b/a
307 270 --- a/a
308 271 +++ b/a
309 272 @@ -1,1 +1,2 @@
310 273 -a
311 274 +changed
312 275 +edited
313 276 diff --git a/b b/b
314 277 old mode 100644
315 278 new mode 100755
316 279 --- a/b
317 280 +++ b/b
318 281 @@ -1,1 +1,2 @@
319 282 -b
320 283 +changed
321 284 +edited
322 285
323 286 Test extdiff with --option:
324 287
325 288 $ hg extdiff -p echo -o this -c 1
326 289 this */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
327 290 [1]
328 291
329 292 $ hg falabala -o this -c 1
330 293 diffing this */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
331 294 [1]
332 295
333 296 Test extdiff's handling of options with spaces in them:
334 297
335 298 $ hg edspace -c 1
336 299 name <user@example.com> */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
337 300 [1]
338 301
339 302 $ hg extdiff -p echo -o "name <user@example.com>" -c 1
340 303 name <user@example.com> */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
341 304 [1]
342 305
343 306 Test with revsets:
344 307
345 308 $ hg extdif -p echo -c "rev(1)"
346 309 */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
347 310 [1]
348 311
349 312 $ hg extdif -p echo -r "0::1"
350 313 */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
351 314 [1]
352 315
353 316 Fallback to merge-tools.tool.executable|regkey
354 317 $ mkdir dir
355 318 $ cat > 'dir/tool.sh' << EOF
356 319 > #!/bin/sh
357 320 > echo "** custom diff **"
358 321 > EOF
359 322 $ chmod +x dir/tool.sh
360 323 $ tool=`pwd`/dir/tool.sh
361 324 $ hg --debug tl --config extdiff.tl= --config merge-tools.tl.executable=$tool
362 325 making snapshot of 2 files from rev * (glob)
363 326 a
364 327 b
365 328 making snapshot of 2 files from working directory
366 329 a
367 330 b
368 331 running '$TESTTMP/a/dir/tool.sh a.* a' in */extdiff.* (glob)
369 332 ** custom diff **
370 333 cleaning up temp directory
371 334 [1]
372 335
373 336 $ cd ..
374 337
375 338 #endif
376 339
377 340 #if symlink
378 341
379 342 Test symlinks handling (issue1909)
380 343
381 344 $ hg init testsymlinks
382 345 $ cd testsymlinks
383 346 $ echo a > a
384 347 $ hg ci -Am adda
385 348 adding a
386 349 $ echo a >> a
387 350 $ ln -s missing linka
388 351 $ hg add linka
389 352 $ hg falabala -r 0 --traceback
390 353 diffing testsymlinks.07f494440405 testsymlinks
391 354 [1]
392 355 $ cd ..
393 356
394 357 #endif
395 358
396 359 Test handling of non-ASCII paths in generated docstrings (issue5301)
397 360
398 361 >>> open("u", "w").write("\xa5\xa5")
399 362 $ U=`cat u`
400 363
401 364 $ HGPLAIN=1 hg --config hgext.extdiff= --config extdiff.cmd.td=hi help -k xyzzy
402 365 abort: no matches
403 366 (try 'hg help' for a list of topics)
404 367 [255]
405 368
406 369 $ HGPLAIN=1 hg --config hgext.extdiff= --config extdiff.cmd.td=hi help td > /dev/null
407 370
408 371 $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help -k xyzzy
409 372 abort: no matches
410 373 (try 'hg help' for a list of topics)
411 374 [255]
412 375
413 376 $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help td \
414 377 > | grep "^ '"
415 378 '\xa5\xa5'
General Comments 0
You need to be logged in to leave comments. Login now