Show More
@@ -435,6 +435,9 b' def fixfile(ui, opts, fixers, fixctx, pa' | |||||
435 | starting with the file's content in the fixctx. Fixers that support line |
|
435 | starting with the file's content in the fixctx. Fixers that support line | |
436 | ranges will affect lines that have changed relative to any of the basectxs |
|
436 | ranges will affect lines that have changed relative to any of the basectxs | |
437 | (i.e. they will only avoid lines that are common to all basectxs). |
|
437 | (i.e. they will only avoid lines that are common to all basectxs). | |
|
438 | ||||
|
439 | A fixer tool's stdout will become the file's new content if and only if it | |||
|
440 | exits with code zero. | |||
438 | """ |
|
441 | """ | |
439 | newdata = fixctx[path].data() |
|
442 | newdata = fixctx[path].data() | |
440 | for fixername, fixer in fixers.iteritems(): |
|
443 | for fixername, fixer in fixers.iteritems(): | |
@@ -454,8 +457,11 b' def fixfile(ui, opts, fixers, fixctx, pa' | |||||
454 | newerdata, stderr = proc.communicate(newdata) |
|
457 | newerdata, stderr = proc.communicate(newdata) | |
455 | if stderr: |
|
458 | if stderr: | |
456 | showstderr(ui, fixctx.rev(), fixername, stderr) |
|
459 | showstderr(ui, fixctx.rev(), fixername, stderr) | |
457 | else: |
|
460 | if proc.returncode == 0: | |
458 | newdata = newerdata |
|
461 | newdata = newerdata | |
|
462 | elif not stderr: | |||
|
463 | showstderr(ui, fixctx.rev(), fixername, | |||
|
464 | _('exited with status %d\n') % (proc.returncode,)) | |||
459 | return newdata |
|
465 | return newdata | |
460 |
|
466 | |||
461 | def showstderr(ui, rev, fixername, stderr): |
|
467 | def showstderr(ui, rev, fixername, stderr): |
@@ -502,12 +502,13 b' write back to the file, so for example t' | |||||
502 |
|
502 | |||
503 | $ cd .. |
|
503 | $ cd .. | |
504 |
|
504 | |||
505 |
When a fixer prints to stderr, we assume that it has failed. We |
|
505 | When a fixer prints to stderr, we don't assume that it has failed. We show the | |
506 |
error messages to the user, and we s |
|
506 | error messages to the user, and we still let the fixer affect the file it was | |
507 |
fi |
|
507 | fixing if its exit code is zero. Some code formatters might emit error messages | |
508 |
and nothing on stdout, which would cause us the clear the file |
|
508 | on stderr and nothing on stdout, which would cause us the clear the file, | |
509 | user which fixer failed and which revision, but we assume that the fixer will |
|
509 | except that they also exit with a non-zero code. We show the user which fixer | |
510 | print the filename if it is relevant. |
|
510 | emitted the stderr, and which revision, but we assume that the fixer will print | |
|
511 | the filename if it is relevant (since the issue may be non-specific). | |||
511 |
|
512 | |||
512 | $ hg init showstderr |
|
513 | $ hg init showstderr | |
513 | $ cd showstderr |
|
514 | $ cd showstderr | |
@@ -515,17 +516,37 b' print the filename if it is relevant.' | |||||
515 | $ printf "hello\n" > hello.txt |
|
516 | $ printf "hello\n" > hello.txt | |
516 | $ hg add |
|
517 | $ hg add | |
517 | adding hello.txt |
|
518 | adding hello.txt | |
518 |
$ cat > |
|
519 | $ cat > $TESTTMP/fail.sh <<'EOF' | |
519 | > printf 'HELLO\n' |
|
520 | > printf 'HELLO\n' | |
520 | > printf "$@: some\nerror" >&2 |
|
521 | > printf "$@: some\nerror" >&2 | |
|
522 | > exit 0 # success despite the stderr output | |||
521 | > EOF |
|
523 | > EOF | |
522 |
$ hg --config "fix.fail:command=sh $TESTTMP/ |
|
524 | $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \ | |
523 | > --config "fix.fail:fileset=hello.txt" \ |
|
525 | > --config "fix.fail:fileset=hello.txt" \ | |
524 | > fix --working-dir |
|
526 | > fix --working-dir | |
525 | [wdir] fail: hello.txt: some |
|
527 | [wdir] fail: hello.txt: some | |
526 | [wdir] fail: error |
|
528 | [wdir] fail: error | |
527 | $ cat hello.txt |
|
529 | $ cat hello.txt | |
528 | hello |
|
530 | HELLO | |
|
531 | ||||
|
532 | $ printf "goodbye\n" > hello.txt | |||
|
533 | $ cat > $TESTTMP/work.sh <<'EOF' | |||
|
534 | > printf 'GOODBYE\n' | |||
|
535 | > printf "$@: some\nerror\n" >&2 | |||
|
536 | > exit 42 # success despite the stdout output | |||
|
537 | > EOF | |||
|
538 | $ hg --config "fix.fail:command=sh $TESTTMP/work.sh {rootpath}" \ | |||
|
539 | > --config "fix.fail:fileset=hello.txt" \ | |||
|
540 | > fix --working-dir | |||
|
541 | [wdir] fail: hello.txt: some | |||
|
542 | [wdir] fail: error | |||
|
543 | $ cat hello.txt | |||
|
544 | goodbye | |||
|
545 | ||||
|
546 | $ hg --config "fix.fail:command=exit 42" \ | |||
|
547 | > --config "fix.fail:fileset=hello.txt" \ | |||
|
548 | > fix --working-dir | |||
|
549 | [wdir] fail: exited with status 42 | |||
529 |
|
550 | |||
530 | $ cd .. |
|
551 | $ cd .. | |
531 |
|
552 |
General Comments 0
You need to be logged in to leave comments.
Login now