diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py index d70971a3ae80fbebdca7a0e3adb72370f08f60e1_bWVyY3VyaWFsL3dpcmVwcm90by5weQ==..f3807a135e43b0499db12dc79697e0b9589dd095_bWVyY3VyaWFsL3dpcmVwcm90by5weQ== 100644 --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -839,7 +839,24 @@ raise error.Abort(bundle2requiredmain, hint=bundle2requiredhint) - chunks = exchange.getbundlechunks(repo, 'serve', **opts) + #chunks = exchange.getbundlechunks(repo, 'serve', **opts) + try: + chunks = exchange.getbundlechunks(repo, 'serve', **opts) + except error.Abort as exc: + # cleanly forward Abort error to the client + if not exchange.bundle2requested(opts.get('bundlecaps')): + if proto.name == 'http': + return ooberror(str(exc) + '\n') + raise # cannot do better for bundle1 + ssh + # bundle2 request expect a bundle2 reply + bundler = bundle2.bundle20(repo.ui) + manargs = [('message', str(exc))] + advargs = [] + if exc.hint is not None: + advargs.append(('hint', exc.hint)) + bundler.addpart(bundle2.bundlepart('error:abort', + manargs, advargs)) + return streamres(gen=bundler.getchunks(), v1compressible=True) return streamres(gen=chunks, v1compressible=True) @wireprotocommand('heads') diff --git a/tests/crashgetbundler.py b/tests/crashgetbundler.py new file mode 100644 index 0000000000000000000000000000000000000000..f3807a135e43b0499db12dc79697e0b9589dd095_dGVzdHMvY3Jhc2hnZXRidW5kbGVyLnB5 --- /dev/null +++ b/tests/crashgetbundler.py @@ -0,0 +1,14 @@ +from __future__ import absolute_import + +from mercurial.i18n import _ +from mercurial import ( + changegroup, + error, + extensions + ) + +def abort(orig, *args, **kwargs): + raise error.Abort(_('this is an exercise')) + +def uisetup(ui): + extensions.wrapfunction(changegroup, 'getbundler', abort) diff --git a/tests/test-http-bundle1.t b/tests/test-http-bundle1.t index d70971a3ae80fbebdca7a0e3adb72370f08f60e1_dGVzdHMvdGVzdC1odHRwLWJ1bmRsZTEudA==..f3807a135e43b0499db12dc79697e0b9589dd095_dGVzdHMvdGVzdC1odHRwLWJ1bmRsZTEudA== 100644 --- a/tests/test-http-bundle1.t +++ b/tests/test-http-bundle1.t @@ -333,3 +333,15 @@ check error log $ cat error.log + +Check error reporting while pulling/cloning + + $ $RUNTESTDIR/killdaemons.py + $ hg -R test serve -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py + $ cat hg3.pid >> $DAEMON_PIDS + $ hg clone http://localhost:$HGPORT/ abort-clone + requesting all changes + abort: remote error: + this is an exercise + [255] + $ cat error.log diff --git a/tests/test-http.t b/tests/test-http.t index d70971a3ae80fbebdca7a0e3adb72370f08f60e1_dGVzdHMvdGVzdC1odHRwLnQ=..f3807a135e43b0499db12dc79697e0b9589dd095_dGVzdHMvdGVzdC1odHRwLnQ= 100644 --- a/tests/test-http.t +++ b/tests/test-http.t @@ -321,3 +321,15 @@ check error log $ cat error.log + +check abort error reporting while pulling/cloning + + $ $RUNTESTDIR/killdaemons.py + $ hg -R test serve -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py + $ cat hg3.pid >> $DAEMON_PIDS + $ hg clone http://localhost:$HGPORT/ abort-clone + requesting all changes + remote: abort: this is an exercise + abort: pull failed on remote + [255] + $ cat error.log diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t index d70971a3ae80fbebdca7a0e3adb72370f08f60e1_dGVzdHMvdGVzdC1zc2gtYnVuZGxlMS50..f3807a135e43b0499db12dc79697e0b9589dd095_dGVzdHMvdGVzdC1zc2gtYnVuZGxlMS50 100644 --- a/tests/test-ssh-bundle1.t +++ b/tests/test-ssh-bundle1.t @@ -543,3 +543,20 @@ remote: abort: pretxnchangegroup.fail hook failed [1] +abort during pull is properly reported as such + + $ echo morefoo >> ../remote/foo + $ hg -R ../remote commit --message "more foo to be pulled" + $ cat >> ../remote/.hg/hgrc << EOF + > [extensions] + > crash = ${TESTDIR}/crashgetbundler.py + > EOF + $ hg --config ui.ssh="python $TESTDIR/dummyssh" pull + pulling from ssh://user@dummy/remote + searching for changes + adding changesets + remote: abort: this is an exercise + transaction abort! + rollback completed + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/tests/test-ssh.t b/tests/test-ssh.t index d70971a3ae80fbebdca7a0e3adb72370f08f60e1_dGVzdHMvdGVzdC1zc2gudA==..f3807a135e43b0499db12dc79697e0b9589dd095_dGVzdHMvdGVzdC1zc2gudA== 100644 --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -548,3 +548,17 @@ abort: push failed on remote [255] +abort during pull is properly reported as such + + $ echo morefoo >> ../remote/foo + $ hg -R ../remote commit --message "more foo to be pulled" + $ cat >> ../remote/.hg/hgrc << EOF + > [extensions] + > crash = ${TESTDIR}/crashgetbundler.py + > EOF + $ hg --config ui.ssh="python $TESTDIR/dummyssh" pull + pulling from ssh://user@dummy/remote + searching for changes + remote: abort: this is an exercise + abort: pull failed on remote + [255]