##// END OF EJS Templates
bundle2: abort when a mandatory pushkey part fails...
Pierre-Yves David -
r25481:6de96cb3 default
parent child Browse files
Show More
@@ -1329,6 +1329,9 b' def handlepushkey(op, inpart):'
1329 rpart = op.reply.newpart('reply:pushkey')
1329 rpart = op.reply.newpart('reply:pushkey')
1330 rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
1330 rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
1331 rpart.addparam('return', '%i' % ret, mandatory=False)
1331 rpart.addparam('return', '%i' % ret, mandatory=False)
1332 if inpart.mandatory and not ret:
1333 raise util.Abort(_('failed to update value for "%s/%s"')
1334 % (namespace, key))
1332
1335
1333 @parthandler('reply:pushkey', ('return', 'in-reply-to'))
1336 @parthandler('reply:pushkey', ('return', 'in-reply-to'))
1334 def handlepushkeyreply(op, inpart):
1337 def handlepushkeyreply(op, inpart):
@@ -717,3 +717,145 b' Check output capture control.'
717 remote: rollback completed
717 remote: rollback completed
718 abort: pretxnchangegroup hook exited with status 1
718 abort: pretxnchangegroup hook exited with status 1
719 [255]
719 [255]
720
721 Check abort from mandatory pushkey
722
723 $ cat > mandatorypart.py << EOF
724 > from mercurial import exchange
725 > from mercurial import pushkey
726 > from mercurial import node
727 > @exchange.b2partsgenerator('failingpuskey')
728 > def addfailingpushey(pushop, bundler):
729 > enc = pushkey.encode
730 > part = bundler.newpart('pushkey')
731 > part.addparam('namespace', enc('phases'))
732 > part.addparam('key', enc(pushop.repo['cd010b8cd998'].hex()))
733 > part.addparam('old', enc(str(0))) # successful update
734 > part.addparam('new', enc(str(0)))
735 > EOF
736 $ cat >> $HGRCPATH << EOF
737 > [hooks]
738 > pretxnchangegroup=
739 > pretxnclose.failpush=
740 > prepushkey.failpush = sh -c "echo 'do not push the key !'; false"
741 > [extensions]
742 > mandatorypart=$TESTTMP/mandatorypart.py
743 > EOF
744 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS # reload http config
745 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
746 $ cat other.pid >> $DAEMON_PIDS
747
748 (Failure from a hook)
749
750 $ hg -R main push other -r e7ec4e813ba6
751 pushing to other
752 searching for changes
753 adding changesets
754 adding manifests
755 adding file changes
756 added 1 changesets with 1 changes to 1 files
757 do not push the key !
758 pushkey-abort: prepushkey.failpush hook exited with status 1
759 transaction abort!
760 Cleaning up the mess...
761 rollback completed
762 abort: failed to update value for "phases/cd010b8cd998f3981a5a8115f94f8da4ab506089"
763 [255]
764 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
765 pushing to ssh://user@dummy/other
766 searching for changes
767 remote: adding changesets
768 remote: adding manifests
769 remote: adding file changes
770 remote: added 1 changesets with 1 changes to 1 files
771 remote: do not push the key !
772 remote: pushkey-abort: prepushkey.failpush hook exited with status 1
773 remote: transaction abort!
774 remote: Cleaning up the mess...
775 remote: rollback completed
776 abort: failed to update value for "phases/cd010b8cd998f3981a5a8115f94f8da4ab506089"
777 [255]
778 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
779 pushing to http://localhost:$HGPORT2/
780 searching for changes
781 remote: adding changesets
782 remote: adding manifests
783 remote: adding file changes
784 remote: added 1 changesets with 1 changes to 1 files
785 remote: do not push the key !
786 remote: pushkey-abort: prepushkey.failpush hook exited with status 1
787 remote: transaction abort!
788 remote: Cleaning up the mess...
789 remote: rollback completed
790 abort: failed to update value for "phases/cd010b8cd998f3981a5a8115f94f8da4ab506089"
791 [255]
792
793 (Failure from a the pushkey)
794
795 $ cat > mandatorypart.py << EOF
796 > from mercurial import exchange
797 > from mercurial import pushkey
798 > from mercurial import node
799 > @exchange.b2partsgenerator('failingpuskey')
800 > def addfailingpushey(pushop, bundler):
801 > enc = pushkey.encode
802 > part = bundler.newpart('pushkey')
803 > part.addparam('namespace', enc('phases'))
804 > part.addparam('key', enc(pushop.repo['cd010b8cd998'].hex()))
805 > part.addparam('old', enc(str(4))) # will fail
806 > part.addparam('new', enc(str(3)))
807 > EOF
808 $ cat >> $HGRCPATH << EOF
809 > [hooks]
810 > prepushkey.failpush =
811 > EOF
812 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS # reload http config
813 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
814 $ cat other.pid >> $DAEMON_PIDS
815
816 $ hg -R main push other -r e7ec4e813ba6
817 pushing to other
818 searching for changes
819 adding changesets
820 adding manifests
821 adding file changes
822 added 1 changesets with 1 changes to 1 files
823 transaction abort!
824 Cleaning up the mess...
825 rollback completed
826 pushkey: lock state after "phases"
827 lock: free
828 wlock: free
829 abort: failed to update value for "phases/cd010b8cd998f3981a5a8115f94f8da4ab506089"
830 [255]
831 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
832 pushing to ssh://user@dummy/other
833 searching for changes
834 remote: adding changesets
835 remote: adding manifests
836 remote: adding file changes
837 remote: added 1 changesets with 1 changes to 1 files
838 remote: transaction abort!
839 remote: Cleaning up the mess...
840 remote: rollback completed
841 remote: pushkey: lock state after "phases"
842 remote: lock: free
843 remote: wlock: free
844 abort: failed to update value for "phases/cd010b8cd998f3981a5a8115f94f8da4ab506089"
845 [255]
846 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
847 pushing to http://localhost:$HGPORT2/
848 searching for changes
849 remote: adding changesets
850 remote: adding manifests
851 remote: adding file changes
852 remote: added 1 changesets with 1 changes to 1 files
853 remote: transaction abort!
854 remote: Cleaning up the mess...
855 remote: rollback completed
856 remote: pushkey: lock state after "phases"
857 remote: lock: free
858 remote: wlock: free
859 abort: failed to update value for "phases/cd010b8cd998f3981a5a8115f94f8da4ab506089"
860 [255]
861
General Comments 0
You need to be logged in to leave comments. Login now