Mercurial > hg-stable
comparison mercurial/subrepo.py @ 18964:ca480d710fe6
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.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 06 Feb 2013 22:54:09 -0500 |
parents | 27e8dfc2c338 |
children | 88d1b59f6906 |
comparison
equal
deleted
inserted
replaced
18963:c31b8dc9de67 | 18964:ca480d710fe6 |
---|---|
3 # Copyright 2009-2010 Matt Mackall <mpm@selenic.com> | 3 # Copyright 2009-2010 Matt Mackall <mpm@selenic.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 import errno, os, re, xml.dom.minidom, shutil, posixpath | 8 import errno, os, re, xml.dom.minidom, shutil, posixpath, sys |
9 import stat, subprocess, tarfile | 9 import stat, subprocess, tarfile |
10 from i18n import _ | 10 from i18n import _ |
11 import config, scmutil, util, node, error, cmdutil, bookmarks, match as matchmod | 11 import config, scmutil, util, node, error, cmdutil, bookmarks, match as matchmod |
12 hg = None | 12 hg = None |
13 propertycache = util.propertycache | 13 propertycache = util.propertycache |
39 class SubrepoAbort(error.Abort): | 39 class SubrepoAbort(error.Abort): |
40 """Exception class used to avoid handling a subrepo error more than once""" | 40 """Exception class used to avoid handling a subrepo error more than once""" |
41 def __init__(self, *args, **kw): | 41 def __init__(self, *args, **kw): |
42 error.Abort.__init__(self, *args, **kw) | 42 error.Abort.__init__(self, *args, **kw) |
43 self.subrepo = kw.get('subrepo') | 43 self.subrepo = kw.get('subrepo') |
44 self.cause = kw.get('cause') | |
44 | 45 |
45 def annotatesubrepoerror(func): | 46 def annotatesubrepoerror(func): |
46 def decoratedmethod(self, *args, **kargs): | 47 def decoratedmethod(self, *args, **kargs): |
47 try: | 48 try: |
48 res = func(self, *args, **kargs) | 49 res = func(self, *args, **kargs) |
51 raise ex | 52 raise ex |
52 except error.Abort, ex: | 53 except error.Abort, ex: |
53 subrepo = subrelpath(self) | 54 subrepo = subrelpath(self) |
54 errormsg = str(ex) + ' ' + _('(in subrepo %s)') % subrepo | 55 errormsg = str(ex) + ' ' + _('(in subrepo %s)') % subrepo |
55 # avoid handling this exception by raising a SubrepoAbort exception | 56 # avoid handling this exception by raising a SubrepoAbort exception |
56 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo) | 57 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo, |
58 cause=sys.exc_info()) | |
57 return res | 59 return res |
58 return decoratedmethod | 60 return decoratedmethod |
59 | 61 |
60 def state(ctx, ui): | 62 def state(ctx, ui): |
61 """return a state dict, mapping subrepo paths configured in .hgsub | 63 """return a state dict, mapping subrepo paths configured in .hgsub |