Show More
@@ -49,12 +49,12 b' def _pythonhook(ui, repo, name, hname, f' | |||||
49 | with demandimport.deactivated(): |
|
49 | with demandimport.deactivated(): | |
50 | try: |
|
50 | try: | |
51 | obj = __import__(modname) |
|
51 | obj = __import__(modname) | |
52 | except ImportError: |
|
52 | except (ImportError, SyntaxError): | |
53 | e1 = sys.exc_info() |
|
53 | e1 = sys.exc_info() | |
54 | try: |
|
54 | try: | |
55 | # extensions are loaded with hgext_ prefix |
|
55 | # extensions are loaded with hgext_ prefix | |
56 | obj = __import__("hgext_%s" % modname) |
|
56 | obj = __import__("hgext_%s" % modname) | |
57 | except ImportError: |
|
57 | except (ImportError, SyntaxError): | |
58 | e2 = sys.exc_info() |
|
58 | e2 = sys.exc_info() | |
59 | if ui.tracebackflag: |
|
59 | if ui.tracebackflag: | |
60 | ui.warn(_('exception from first failed import ' |
|
60 | ui.warn(_('exception from first failed import ' |
@@ -436,6 +436,10 b' preoutgoing hook can prevent outgoing ch' | |||||
436 | > unreachable = 1 |
|
436 | > unreachable = 1 | |
437 | > EOF |
|
437 | > EOF | |
438 |
|
438 | |||
|
439 | $ cat > syntaxerror.py << EOF | |||
|
440 | > (foo | |||
|
441 | > EOF | |||
|
442 | ||||
439 | test python hooks |
|
443 | test python hooks | |
440 |
|
444 | |||
441 | #if windows |
|
445 | #if windows | |
@@ -518,6 +522,30 b' test python hooks' | |||||
518 | [255] |
|
522 | [255] | |
519 |
|
523 | |||
520 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
524 | $ echo '[hooks]' > ../a/.hg/hgrc | |
|
525 | $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc | |||
|
526 | $ hg pull ../a | |||
|
527 | pulling from ../a | |||
|
528 | searching for changes | |||
|
529 | abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed | |||
|
530 | (run with --traceback for stack trace) | |||
|
531 | [255] | |||
|
532 | ||||
|
533 | $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | |||
|
534 | pulling from ../a | |||
|
535 | searching for changes | |||
|
536 | exception from first failed import attempt: | |||
|
537 | Traceback (most recent call last): | |||
|
538 | ||||
|
539 | ^ | |||
|
540 | SyntaxError: invalid syntax | |||
|
541 | exception from second failed import attempt: | |||
|
542 | Traceback (most recent call last): | |||
|
543 | ImportError: No module named hgext_syntaxerror | |||
|
544 | Traceback (most recent call last): | |||
|
545 | HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed | |||
|
546 | abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed | |||
|
547 | ||||
|
548 | $ echo '[hooks]' > ../a/.hg/hgrc | |||
521 | $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc |
|
549 | $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc | |
522 | $ hg pull ../a |
|
550 | $ hg pull ../a | |
523 | pulling from ../a |
|
551 | pulling from ../a |
General Comments 0
You need to be logged in to leave comments.
Login now