Mercurial > hg > mercurial-source
comparison mercurial/subrepo.py @ 18263:9aa6bee6e9f9
subrepo: add subrepo property to SubrepoAbort exceptions
This new property contains the path of the subrepo that generated the exception.
This information can then be used by GUI tools such as TortoiseHg.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Thu, 03 Jan 2013 17:35:58 +0100 |
parents | 9e3910db4e78 |
children | a74101cd6965 |
comparison
equal
deleted
inserted
replaced
18262:ed923a2d5ae9 | 18263:9aa6bee6e9f9 |
---|---|
14 | 14 |
15 nullstate = ('', '', 'empty') | 15 nullstate = ('', '', 'empty') |
16 | 16 |
17 class SubrepoAbort(error.Abort): | 17 class SubrepoAbort(error.Abort): |
18 """Exception class used to avoid handling a subrepo error more than once""" | 18 """Exception class used to avoid handling a subrepo error more than once""" |
19 def __init__(self, *args, **kw): | |
20 super(SubrepoAbort, self).__init__(*args, **kw) | |
21 self.subrepo = kw.get('subrepo') | |
19 | 22 |
20 def annotatesubrepoerror(func): | 23 def annotatesubrepoerror(func): |
21 def decoratedmethod(self, *args, **kargs): | 24 def decoratedmethod(self, *args, **kargs): |
22 try: | 25 try: |
23 res = func(self, *args, **kargs) | 26 res = func(self, *args, **kargs) |
24 except SubrepoAbort, ex: | 27 except SubrepoAbort, ex: |
25 # This exception has already been handled | 28 # This exception has already been handled |
26 raise ex | 29 raise ex |
27 except error.Abort, ex: | 30 except error.Abort, ex: |
28 errormsg = _('%s (in subrepo %s)') % (str(ex), subrelpath(self)) | 31 subrepo = subrelpath(self) |
32 errormsg = _('%s (in subrepo %s)') % (str(ex), subrepo) | |
29 # avoid handling this exception by raising a SubrepoAbort exception | 33 # avoid handling this exception by raising a SubrepoAbort exception |
30 raise SubrepoAbort(errormsg, hint=ex.hint) | 34 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo) |
31 return res | 35 return res |
32 return decoratedmethod | 36 return decoratedmethod |
33 | 37 |
34 def state(ctx, ui): | 38 def state(ctx, ui): |
35 """return a state dict, mapping subrepo paths configured in .hgsub | 39 """return a state dict, mapping subrepo paths configured in .hgsub |