@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-import errno, os, re, xml.dom.minidom, shutil, posixpath
+import errno, os, re, xml.dom.minidom, shutil, posixpath, sys
import stat, subprocess, tarfile
from i18n import _
import config, scmutil, util, node, error, cmdutil, bookmarks, match as matchmod
@@ -19,6 +19,7 @@
def __init__(self, *args, **kw):
super(SubrepoAbort, self).__init__(*args, **kw)
self.subrepo = kw.get('subrepo')
+ self.cause = kw.get('cause')
def annotatesubrepoerror(func):
def decoratedmethod(self, *args, **kargs):
@@ -31,7 +32,8 @@
subrepo = subrelpath(self)
errormsg = _('%s (in subrepo %s)') % (str(ex), subrepo)
# avoid handling this exception by raising a SubrepoAbort exception
- raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo)
+ raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo,
+ cause=sys.exc_info())
return res
return decoratedmethod
@@ -686,11 +686,21 @@
only to call in exception handler. returns true if traceback
printed.'''
if self.tracebackflag:
- if exc:
+ if exc is None:
+ exc = sys.exc_info()
+ cause=getattr(exc[1], 'cause', None)
+
+ if cause is not None:
+ tbc=traceback.format_tb(cause[2])
+ tbe=traceback.format_tb(exc[2])
+ feo=traceback.format_exception_only(cause[0], cause[1])
+ # exclude the frame where 'exc' was thrown
+ print >> self.ferr, 'Traceback (most recent call last):\n' \
+ + ''.join(tbe[:-1]) \
+ + ''.join(tbc) + ''.join(feo),
+ else:
traceback.print_exception(exc[0], exc[1], exc[2],
file=self.ferr)
- else:
- traceback.print_exc(file=self.ferr)
return self.tracebackflag
def geteditor(self):
@@ -673,8 +673,14 @@
File "*/mercurial/subrepo.py", line *, in submerge (glob)
mctx.sub(s).get(r)
File "*/mercurial/subrepo.py", line *, in decoratedmethod (glob)
- raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo)
- SubrepoAbort: default path for subrepository not found (in subrepo sub/repo) (glob)
+ res = func(self, *args, **kargs)
+ File "*/mercurial/subrepo.py", line *, in get (glob)
+ self._get(state)
+ File "*/mercurial/subrepo.py", line *, in _get (glob)
+ srcurl = _abssource(self._repo)
+ File "*/mercurial/subrepo.py", line *, in _abssource (glob)
+ raise util.Abort(_("default path for subrepository not found"))
+ Abort: default path for subrepository not found
abort: default path for subrepository not found (in subrepo sub/repo) (glob)
[255]