Mercurial > hg
comparison tests/test-merge-tools.t @ 38041:242eb5132203
filemerge: support specifying a python function to custom merge-tools
Eliminates the need to specify a python executable, which may not exist on
system. Additionally launching script inprocess aids portability on systems
that can't execute python via the shell.
Example usage "merge-tools.myTool.executable=python:c:\myTool.py:mergefn"
where myTool.py contains a function:
"def mergefn(ui, repo, args, **kwargs):"
where args is list of args passed to merge tool.
(by default, expanded: $local $base $other)
Invoking the specified python function was done by exposing and invoking
(hook._pythonhook -> hook.pythonhook)
author | hindlemail <tom_hindle@sil.org> |
---|---|
date | Wed, 16 May 2018 14:11:41 -0600 |
parents | a4a5c3085ea9 |
children | 6bfd1054d867 |
comparison
equal
deleted
inserted
replaced
38031:37ef6ee87488 | 38041:242eb5132203 |
---|---|
316 space | 316 space |
317 revision 0 | 317 revision 0 |
318 space | 318 space |
319 revision 2 | 319 revision 2 |
320 space | 320 space |
321 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
322 (branch merge, don't forget to commit) | |
323 $ aftermerge | |
324 # cat f | |
325 revision 1 | |
326 space | |
327 # hg stat | |
328 M f | |
329 # hg resolve --list | |
330 R f | |
331 | |
332 executable set to python script that succeeds: | |
333 | |
334 $ cat > "$TESTTMP/myworkingmerge.py" <<EOF | |
335 > def myworkingmergefn(ui, repo, args, **kwargs): | |
336 > return False | |
337 > EOF | |
338 $ beforemerge | |
339 [merge-tools] | |
340 false.whatever= | |
341 true.priority=1 | |
342 true.executable=cat | |
343 # hg update -C 1 | |
344 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:myworkingmergefn" | |
345 merging f | |
346 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
347 (branch merge, don't forget to commit) | |
348 $ aftermerge | |
349 # cat f | |
350 revision 1 | |
351 space | |
352 # hg stat | |
353 M f | |
354 # hg resolve --list | |
355 R f | |
356 | |
357 executable set to python script that fails: | |
358 | |
359 $ cat > "$TESTTMP/mybrokenmerge.py" <<EOF | |
360 > def mybrokenmergefn(ui, repo, args, **kwargs): | |
361 > ui.write(b"some fail message\n") | |
362 > return True | |
363 > EOF | |
364 $ beforemerge | |
365 [merge-tools] | |
366 false.whatever= | |
367 true.priority=1 | |
368 true.executable=cat | |
369 # hg update -C 1 | |
370 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/mybrokenmerge.py:mybrokenmergefn" | |
371 merging f | |
372 some fail message | |
373 abort: $TESTTMP/mybrokenmerge.py hook failed | |
374 [255] | |
375 $ aftermerge | |
376 # cat f | |
377 revision 1 | |
378 space | |
379 # hg stat | |
380 ? f.orig | |
381 # hg resolve --list | |
382 U f | |
383 | |
384 executable set to python script that is missing function: | |
385 | |
386 $ beforemerge | |
387 [merge-tools] | |
388 false.whatever= | |
389 true.priority=1 | |
390 true.executable=cat | |
391 # hg update -C 1 | |
392 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:missingFunction" | |
393 merging f | |
394 abort: $TESTTMP/myworkingmerge.py does not have function: missingFunction | |
395 [255] | |
396 $ aftermerge | |
397 # cat f | |
398 revision 1 | |
399 space | |
400 # hg stat | |
401 ? f.orig | |
402 # hg resolve --list | |
403 U f | |
404 | |
405 executable set to missing python script: | |
406 | |
407 $ beforemerge | |
408 [merge-tools] | |
409 false.whatever= | |
410 true.priority=1 | |
411 true.executable=cat | |
412 # hg update -C 1 | |
413 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/missingpythonscript.py:mergefn" | |
414 merging f | |
415 abort: loading python merge script failed: $TESTTMP/missingpythonscript.py | |
416 [255] | |
417 $ aftermerge | |
418 # cat f | |
419 revision 1 | |
420 space | |
421 # hg stat | |
422 ? f.orig | |
423 # hg resolve --list | |
424 U f | |
425 | |
426 executable set to python script but callable function is missing: | |
427 | |
428 $ beforemerge | |
429 [merge-tools] | |
430 false.whatever= | |
431 true.priority=1 | |
432 true.executable=cat | |
433 # hg update -C 1 | |
434 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py" | |
435 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py | |
436 [255] | |
437 $ aftermerge | |
438 # cat f | |
439 revision 1 | |
440 space | |
441 # hg stat | |
442 # hg resolve --list | |
443 U f | |
444 | |
445 executable set to python script but callable function is empty string: | |
446 | |
447 $ beforemerge | |
448 [merge-tools] | |
449 false.whatever= | |
450 true.priority=1 | |
451 true.executable=cat | |
452 # hg update -C 1 | |
453 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:" | |
454 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py: | |
455 [255] | |
456 $ aftermerge | |
457 # cat f | |
458 revision 1 | |
459 space | |
460 # hg stat | |
461 # hg resolve --list | |
462 U f | |
463 | |
464 executable set to python script but callable function is missing and path contains colon: | |
465 | |
466 $ beforemerge | |
467 [merge-tools] | |
468 false.whatever= | |
469 true.priority=1 | |
470 true.executable=cat | |
471 # hg update -C 1 | |
472 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/some:dir/myworkingmerge.py" | |
473 abort: invalid 'python:' syntax: python:$TESTTMP/some:dir/myworkingmerge.py | |
474 [255] | |
475 $ aftermerge | |
476 # cat f | |
477 revision 1 | |
478 space | |
479 # hg stat | |
480 # hg resolve --list | |
481 U f | |
482 | |
483 executable set to python script filename that contains spaces: | |
484 | |
485 $ mkdir -p "$TESTTMP/my path" | |
486 $ cat > "$TESTTMP/my path/my working merge with spaces in filename.py" <<EOF | |
487 > def myworkingmergefn(ui, repo, args, **kwargs): | |
488 > return False | |
489 > EOF | |
490 $ beforemerge | |
491 [merge-tools] | |
492 false.whatever= | |
493 true.priority=1 | |
494 true.executable=cat | |
495 # hg update -C 1 | |
496 $ hg merge -r 2 --config "merge-tools.true.executable=python:$TESTTMP/my path/my working merge with spaces in filename.py:myworkingmergefn" | |
497 merging f | |
321 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | 498 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
322 (branch merge, don't forget to commit) | 499 (branch merge, don't forget to commit) |
323 $ aftermerge | 500 $ aftermerge |
324 # cat f | 501 # cat f |
325 revision 1 | 502 revision 1 |