##// END OF EJS Templates
pushkey: gracefully handle prepushkey hook failure (issue4455)...
Pierre-Yves David -
r23416:53a65929 stable
parent child Browse files
Show More
@@ -1754,8 +1754,14 b' class localrepository(object):'
1754 return ret
1754 return ret
1755
1755
1756 def pushkey(self, namespace, key, old, new):
1756 def pushkey(self, namespace, key, old, new):
1757 try:
1757 self.hook('prepushkey', throw=True, namespace=namespace, key=key,
1758 self.hook('prepushkey', throw=True, namespace=namespace, key=key,
1758 old=old, new=new)
1759 old=old, new=new)
1760 except error.HookAbort, exc:
1761 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
1762 if exc.hint:
1763 self.ui.write_err(_("(%s)\n") % exc.hint)
1764 return False
1759 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
1765 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
1760 ret = pushkey.push(self, namespace, key, old, new)
1766 ret = pushkey.push(self, namespace, key, old, new)
1761 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
1767 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
@@ -486,4 +486,77 b' pushing an unchanged bookmark should res'
486 no changes found
486 no changes found
487 [1]
487 [1]
488
488
489 $ cd ..
489
490 Check hook preventing push (issue4455)
491 ======================================
492
493 $ hg bookmarks
494 * @ 0:55482a6fb4b1
495 $ hg log -G
496 @ 0:55482a6fb4b1 initial
497
498 $ hg init ../issue4455-dest
499 $ hg push ../issue4455-dest # changesets only
500 pushing to ../issue4455-dest
501 searching for changes
502 adding changesets
503 adding manifests
504 adding file changes
505 added 1 changesets with 1 changes to 1 files
506 $ cat >> .hg/hgrc << EOF
507 > [paths]
508 > local=../issue4455-dest/
509 > ssh=ssh://user@dummy/issue4455-dest
510 > http=http://localhost:$HGPORT/
511 > [ui]
512 > ssh=python "$TESTDIR/dummyssh"
513 > EOF
514 $ cat >> ../issue4455-dest/.hg/hgrc << EOF
515 > [hooks]
516 > prepushkey=false
517 > [web]
518 > push_ssl = false
519 > allow_push = *
520 > EOF
521 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
522 $ hg -R ../issue4455-dest serve -p $HGPORT -d --pid-file=../issue4455.pid -E ../issue4455-error.log
523 $ cat ../issue4455.pid >> $DAEMON_PIDS
524
525 Local push
526 ----------
527
528 $ hg push -B @ local
529 pushing to $TESTTMP/issue4455-dest (glob)
530 searching for changes
531 no changes found
532 pushkey-abort: prepushkey hook exited with status 1
533 exporting bookmark @ failed!
534 [1]
535 $ hg -R ../issue4455-dest/ bookmarks
536 no bookmarks set
537
538 Using ssh
539 ---------
540
541 $ hg push -B @ ssh
542 pushing to ssh://user@dummy/issue4455-dest
543 searching for changes
544 no changes found
545 remote: pushkey-abort: prepushkey hook exited with status 1
546 exporting bookmark @ failed!
547 [1]
548 $ hg -R ../issue4455-dest/ bookmarks
549 no bookmarks set
550
551 Using http
552 ----------
553
554 $ hg push -B @ http
555 pushing to http://localhost:$HGPORT/
556 searching for changes
557 no changes found
558 remote: pushkey-abort: prepushkey hook exited with status 1
559 exporting bookmark @ failed!
560 [1]
561 $ hg -R ../issue4455-dest/ bookmarks
562 no bookmarks set
@@ -215,8 +215,9 b' test that prepushkey can prevent incomin'
215 no changes found
215 no changes found
216 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
216 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
217 prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
217 prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
218 abort: prepushkey hook exited with status 1
218 pushkey-abort: prepushkey hook exited with status 1
219 [255]
219 exporting bookmark baz failed!
220 [1]
220 $ cd ../a
221 $ cd ../a
221
222
222 test that prelistkeys can prevent listing keys
223 test that prelistkeys can prevent listing keys
@@ -392,9 +392,9 b' Test hg-ssh in read-only mode:'
392 remote: Permission denied
392 remote: Permission denied
393 remote: abort: prechangegroup.hg-ssh hook failed
393 remote: abort: prechangegroup.hg-ssh hook failed
394 remote: Permission denied
394 remote: Permission denied
395 remote: abort: prepushkey.hg-ssh hook failed
395 remote: pushkey-abort: prepushkey.hg-ssh hook failed
396 abort: unexpected response: empty string
396 updating 6c0482d977a3 to public failed!
397 [255]
397 [1]
398
398
399 $ cd ..
399 $ cd ..
400
400
General Comments 0
You need to be logged in to leave comments. Login now