comparison tests/test-bundle2.t @ 21177:952af771bc17 stable

bundle2: gracefully handle abort during unbundle Clients expect a bundle2 reply to their bundle2 submission. So we catch the Abort error and turn it into a bundle2 containing a part transporting the exception data. The unbundling of this reply will raise the error again.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 21 Apr 2014 15:48:52 -0700
parents 2a246e737f92
children 9a813e703172
comparison
equal deleted inserted replaced
21176:70fcb0a71445 21177:952af771bc17
881 o changeset: 0:cd010b8cd998 881 o changeset: 0:cd010b8cd998
882 user: Nicolas Dumazet <nicdumz.commits@gmail.com> 882 user: Nicolas Dumazet <nicdumz.commits@gmail.com>
883 date: Sat Apr 30 15:24:48 2011 +0200 883 date: Sat Apr 30 15:24:48 2011 +0200
884 summary: A 884 summary: A
885 885
886
887 Error Handling
888 ==============
889
890 Check that errors are properly returned to the client during push.
891
892 Setting up
893
894 $ cat > failpush.py << EOF
895 > """A small extension that makes push fails when using bundle2
896 >
897 > used to test error handling in bundle2
898 > """
899 >
900 > from mercurial import util
901 > from mercurial import bundle2
902 > from mercurial import exchange
903 > from mercurial import extensions
904 >
905 > def _pushbundle2failpart(orig, pushop, bundler):
906 > extradata = orig(pushop, bundler)
907 > part = bundle2.bundlepart('test:abort')
908 > bundler.addpart(part)
909 > return extradata
910 >
911 > @bundle2.parthandler("test:abort")
912 > def handleabort(op, part):
913 > raise util.Abort('Abandon ship!', hint="don't panic")
914 >
915 > def uisetup(ui):
916 > extensions.wrapfunction(exchange, '_pushbundle2extraparts', _pushbundle2failpart)
917 >
918 > EOF
919
920 $ cd main
921 $ hg up tip
922 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
923 $ echo 'I' > I
924 $ hg add I
925 $ hg ci -m 'I'
926 $ hg id
927 e7ec4e813ba6 tip
928 $ cd ..
929
930 $ cat << EOF >> $HGRCPATH
931 > [extensions]
932 > failpush=$TESTTMP/failpush.py
933 > EOF
934
935 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
936 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
937 $ cat other.pid >> $DAEMON_PIDS
938
939 Doing the actual push: Abort error
940
941 $ hg -R main push other -r e7ec4e813ba6
942 pushing to other
943 searching for changes
944 abort: Abandon ship!
945 (don't panic)
946 [255]
947
948 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
949 pushing to ssh://user@dummy/other
950 searching for changes
951 abort: Abandon ship!
952 (don't panic)
953 [255]
954
955 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
956 pushing to http://localhost:$HGPORT2/
957 searching for changes
958 abort: Abandon ship!
959 (don't panic)
960 [255]
961
962