Patchwork [1,of,3] subrepo: chain the original exception to SubrepoAbort

login
register
mail settings
Submitter Matt Harbison
Date Feb. 7, 2013, 5:42 a.m.
Message ID <8c093ee06ae1b39997e8.1360215762@Envy>
Download mbox | patch
Permalink /patch/820/
State Superseded
Headers show

Comments

Matt Harbison - Feb. 7, 2013, 5:42 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1360209249 18000
# Branch stable
# Node ID 8c093ee06ae1b39997e8793f215a638ee198ce8e
# Parent  b6b9475c563a3c8ad3b24e2602424a00a7ea2c56
subrepo: chain the original exception to SubrepoAbort

The tracebacks in subrepos are truncated at the point where the original
exception is caught and SubrepoAbort is raised in its place since 9e3910db4e78.
That hides the most relevant subrepo methods when an error occurs.  Python 2.x
doesn't support chaining exceptions, so it is manually done here for manual
printing later.
Matt Harbison - Feb. 7, 2013, 5:46 a.m.
Oops, forgot the STABLE flag for these.  If that's not appropriate, it 
looks like it applies cleanly to default too.

--Matt

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -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):
         error.Abort.__init__(self, *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 = str(ex) + ' ' + _('(in subrepo %s)') % 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