Patchwork [1,of,2] subrepo: add subrepo property to SubrepoAbort exceptions

login
register
mail settings
Submitter Angel Ezquerra
Date Jan. 3, 2013, 5:17 p.m.
Message ID <5a1a5555319c13de73e5.1357233430@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/368/
State Superseded
Headers show

Comments

Angel Ezquerra - Jan. 3, 2013, 5:17 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1357230958 -3600
# Node ID 5a1a5555319c13de73e51d271de5356b4a0656d0
# Parent  2c1276825e938872ebc099c191eb202f0dbadfcc
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.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -16,6 +16,9 @@ 
 
 class SubrepoAbort(error.Abort):
     """Exception class used to avoid handling a subrepo error more than once"""
+    def __init__(self, *args, **kw):
+        super(SubrepoAbort, self).__init__(*args, **kw)
+        self.subrepo = kw.get('subrepo')
 
 def annotatesubrepoerror(func):
     def decoratedmethod(self, *args, **kargs):
@@ -25,9 +28,10 @@ 
             # This exception has already been handled
             raise ex
         except error.Abort, ex:
-            errormsg = _('%s (in subrepo %s)') % (str(ex), subrelpath(self))
+            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)
+            raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo)
         return res
     return decoratedmethod