Patchwork [1,of,2,RFC] subrepo: add constructor to SubrepoAbort

login
register
mail settings
Submitter Matt Harbison
Date Jan. 7, 2013, 4:40 a.m.
Message ID <c8d4cc041ba1ad2572d7.1357533654@Envy>
Download mbox | patch
Permalink /patch/408/
State Deferred
Headers show

Comments

Matt Harbison - Jan. 7, 2013, 4:40 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1357526787 18000
# Node ID c8d4cc041ba1ad2572d7d139802831e0ac062bfb
# Parent  2c1276825e938872ebc099c191eb202f0dbadfcc
subrepo: add constructor to SubrepoAbort

This is Angel's patch [1] with SubrepoAbort property support, but with a
--traceback in a test so that the next patch shows the effect of the code that
prints chained exception information.

[1] http://www.selenic.com/pipermail/mercurial-devel/2013-January/047464.html
Bryan O'Sullivan - Jan. 8, 2013, 10:50 p.m.
On Sun, Jan 06, 2013 at 11:40:54PM -0500, Matt Harbison wrote:
> subrepo: add constructor to SubrepoAbort

Looks reasonable.
Bryan O'Sullivan - Jan. 8, 2013, 11:46 p.m.
On Sun, Jan 6, 2013 at 8:40 PM, Matt Harbison <matt_harbison@yahoo.com>wrote:

> subrepo: add constructor to SubrepoAbort
>
> This is Angel's patch [1] with SubrepoAbort property support, but with a
> --traceback in a test so that the next patch shows the effect of the code
> that
> prints chained exception information.
>

Can you and Angel decide whose patch wins the bunfight, please?
Matt Harbison - Jan. 9, 2013, 12:03 a.m.
On Tue, 08 Jan 2013 15:46:41 -0800, Bryan O'Sullivan wrote:

> On Sun, Jan 6, 2013 at 8:40 PM, Matt Harbison
> <matt_harbison@yahoo.com>wrote:
> 
>> subrepo: add constructor to SubrepoAbort
>>
>> This is Angel's patch [1] with SubrepoAbort property support, but with
>> a --traceback in a test so that the next patch shows the effect of the
>> code that prints chained exception information.
>>
>>
> Can you and Angel decide whose patch wins the bunfight, please?

Go ahead and take his patch from his V2 series.  I was just giving context 
in case anyone wanted to apply and test it.

--Matt

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
 
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -644,7 +644,37 @@ 
   adding file changes
   added 2 changesets with 3 changes to 2 files
   (run 'hg update' to get a working copy)
-  $ hg -R issue1852b update
+  $ hg -R issue1852b update --traceback
+  Traceback (most recent call last):
+    File "*/mercurial/dispatch.py", line *, in _runcatch (glob)
+      return _dispatch(req)
+    File "*/mercurial/dispatch.py", line *, in _dispatch (glob)
+      cmdpats, cmdoptions)
+    File "*/mercurial/dispatch.py", line *, in runcommand (glob)
+      ret = _runcommand(ui, options, cmd, d)
+    File "*/mercurial/dispatch.py", line *, in _runcommand (glob)
+      return checkargs()
+    File "*/mercurial/dispatch.py", line *, in checkargs (glob)
+      return cmdfunc()
+    File "*/mercurial/dispatch.py", line *, in <lambda> (glob)
+      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
+    File "*/mercurial/util.py", line *, in check (glob)
+      return func(*args, **kwargs)
+    File "*/mercurial/commands.py", line *, in update (glob)
+      ret = hg.update(repo, rev)
+    File "*/mercurial/hg.py", line *, in update (glob)
+      stats = updaterepo(repo, node, False)
+    File "*/mercurial/hg.py", line *, in updaterepo (glob)
+      return mergemod.update(repo, node, False, overwrite, None)
+    File "*/mercurial/merge.py", line *, in update (glob)
+      stats = applyupdates(repo, action, wc, p2, pa, overwrite)
+    File "*/mercurial/merge.py", line *, in applyupdates (glob)
+      subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
+    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)
   abort: default path for subrepository not found (in subrepo sub/repo) (glob)
   [255]