##// END OF EJS Templates
wireproto: properly report server Abort during 'getbundle'...
Pierre-Yves David -
r30914:f3807a13 stable
parent child Browse files
Show More
@@ -0,0 +1,14 b''
1 from __future__ import absolute_import
2
3 from mercurial.i18n import _
4 from mercurial import (
5 changegroup,
6 error,
7 extensions
8 )
9
10 def abort(orig, *args, **kwargs):
11 raise error.Abort(_('this is an exercise'))
12
13 def uisetup(ui):
14 extensions.wrapfunction(changegroup, 'getbundler', abort)
@@ -839,7 +839,24 b' def getbundle(repo, proto, others):'
839 raise error.Abort(bundle2requiredmain,
839 raise error.Abort(bundle2requiredmain,
840 hint=bundle2requiredhint)
840 hint=bundle2requiredhint)
841
841
842 chunks = exchange.getbundlechunks(repo, 'serve', **opts)
842 #chunks = exchange.getbundlechunks(repo, 'serve', **opts)
843 try:
844 chunks = exchange.getbundlechunks(repo, 'serve', **opts)
845 except error.Abort as exc:
846 # cleanly forward Abort error to the client
847 if not exchange.bundle2requested(opts.get('bundlecaps')):
848 if proto.name == 'http':
849 return ooberror(str(exc) + '\n')
850 raise # cannot do better for bundle1 + ssh
851 # bundle2 request expect a bundle2 reply
852 bundler = bundle2.bundle20(repo.ui)
853 manargs = [('message', str(exc))]
854 advargs = []
855 if exc.hint is not None:
856 advargs.append(('hint', exc.hint))
857 bundler.addpart(bundle2.bundlepart('error:abort',
858 manargs, advargs))
859 return streamres(gen=bundler.getchunks(), v1compressible=True)
843 return streamres(gen=chunks, v1compressible=True)
860 return streamres(gen=chunks, v1compressible=True)
844
861
845 @wireprotocommand('heads')
862 @wireprotocommand('heads')
@@ -333,3 +333,15 b' clone of serve with repo in root and uns'
333 check error log
333 check error log
334
334
335 $ cat error.log
335 $ cat error.log
336
337 Check error reporting while pulling/cloning
338
339 $ $RUNTESTDIR/killdaemons.py
340 $ hg -R test serve -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py
341 $ cat hg3.pid >> $DAEMON_PIDS
342 $ hg clone http://localhost:$HGPORT/ abort-clone
343 requesting all changes
344 abort: remote error:
345 this is an exercise
346 [255]
347 $ cat error.log
@@ -321,3 +321,15 b' clone of serve with repo in root and uns'
321 check error log
321 check error log
322
322
323 $ cat error.log
323 $ cat error.log
324
325 check abort error reporting while pulling/cloning
326
327 $ $RUNTESTDIR/killdaemons.py
328 $ hg -R test serve -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py
329 $ cat hg3.pid >> $DAEMON_PIDS
330 $ hg clone http://localhost:$HGPORT/ abort-clone
331 requesting all changes
332 remote: abort: this is an exercise
333 abort: pull failed on remote
334 [255]
335 $ cat error.log
@@ -543,3 +543,20 b' remote hook failure is attributed to rem'
543 remote: abort: pretxnchangegroup.fail hook failed
543 remote: abort: pretxnchangegroup.fail hook failed
544 [1]
544 [1]
545
545
546 abort during pull is properly reported as such
547
548 $ echo morefoo >> ../remote/foo
549 $ hg -R ../remote commit --message "more foo to be pulled"
550 $ cat >> ../remote/.hg/hgrc << EOF
551 > [extensions]
552 > crash = ${TESTDIR}/crashgetbundler.py
553 > EOF
554 $ hg --config ui.ssh="python $TESTDIR/dummyssh" pull
555 pulling from ssh://user@dummy/remote
556 searching for changes
557 adding changesets
558 remote: abort: this is an exercise
559 transaction abort!
560 rollback completed
561 abort: stream ended unexpectedly (got 0 bytes, expected 4)
562 [255]
@@ -548,3 +548,17 b' remote hook failure is attributed to rem'
548 abort: push failed on remote
548 abort: push failed on remote
549 [255]
549 [255]
550
550
551 abort during pull is properly reported as such
552
553 $ echo morefoo >> ../remote/foo
554 $ hg -R ../remote commit --message "more foo to be pulled"
555 $ cat >> ../remote/.hg/hgrc << EOF
556 > [extensions]
557 > crash = ${TESTDIR}/crashgetbundler.py
558 > EOF
559 $ hg --config ui.ssh="python $TESTDIR/dummyssh" pull
560 pulling from ssh://user@dummy/remote
561 searching for changes
562 remote: abort: this is an exercise
563 abort: pull failed on remote
564 [255]
General Comments 0
You need to be logged in to leave comments. Login now