Patchwork subrepo: append subrepo path to subrepo push error messages

login
register
mail settings
Submitter Angel Ezquerra
Date Dec. 14, 2012, 8:41 a.m.
Message ID <CAMefLFHmSPvwFRQt8R=8dVYL7Db6KCPWK-NjTw73WwB-qWVHBg@mail.gmail.com>
Download mbox | patch
Permalink /patch/104/
State Superseded
Headers show

Comments

Angel Ezquerra - Dec. 14, 2012, 8:41 a.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1355438273 -3600
# Node ID b5af4658272135a1a9bbe67affc1955dd478861f
# Parent  34a1a639d8358e43f4bcba7b0cff19f4e4e6958d
subrepo: append subrepo path to subrepo push error messages

This change appends the subrepo path to subrepo push errors. That is, when there
is an error pushing a subrepo, rather than displaying:

pushing subrepo MYSUBREPO to PATH
searching for changes
abort: push creates new remote head HEADHASH!
hint: did you forget to merge? use push -f to force

mercurial will show:

pushing subrepo MYSUBREPO to PATH
searching for changes
abort: push creates new remote head HEADHASH! (on subrepo MYSUBREPO)
hint: did you forget to merge? use push -f to force

The rationale for this change is that the current error messages make it hard
for TortoiseHg (and similar tools) to tell the user which subrepo caused the
push failure.

   $ hg push -f
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hg_18076_append_subrepo_path_to_subrepo_push_error_messages.patch
Type: application/octet-stream
Size: 2102 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121214/301731e6/attachment.obj>
Angel Ezquerra - Dec. 14, 2012, 8:43 a.m.
On Fri, Dec 14, 2012 at 9:41 AM, Angel Ezquerra
<angel.ezquerra at gmail.com> wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra at gmail.com>
> # Date 1355438273 -3600
> # Node ID b5af4658272135a1a9bbe67affc1955dd478861f
> # Parent  34a1a639d8358e43f4bcba7b0cff19f4e4e6958d
> subrepo: append subrepo path to subrepo push error messages
>
> This change appends the subrepo path to subrepo push errors. That is, when there
> is an error pushing a subrepo, rather than displaying:
>
> pushing subrepo MYSUBREPO to PATH
> searching for changes
> abort: push creates new remote head HEADHASH!
> hint: did you forget to merge? use push -f to force
>
> mercurial will show:
>
> pushing subrepo MYSUBREPO to PATH
> searching for changes
> abort: push creates new remote head HEADHASH! (on subrepo MYSUBREPO)
> hint: did you forget to merge? use push -f to force
>
> The rationale for this change is that the current error messages make it hard
> for TortoiseHg (and similar tools) to tell the user which subrepo caused the
> push failure.
>
> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> --- a/mercurial/subrepo.py
> +++ b/mercurial/subrepo.py
> @@ -567,7 +567,12 @@
>          self._repo.ui.status(_('pushing subrepo %s to %s\n') %
>              (subrelpath(self), dsturl))
>          other = hg.peer(self._repo, {'ssh': ssh}, dsturl)
> -        return self._repo.push(other, force, newbranch=newbranch)
> +        try:
> +            res = self._repo.push(other, force, newbranch=newbranch)
> +        except error.Abort, ex:
> +            errormsg = ex.message + (' (on subrepo %s)' % self._path)
> +            raise util.Abort(errormsg,  hint=ex.hint)
> +        return res
>
>      def outgoing(self, ui, dest, opts):
>          return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts)
> diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
> --- a/tests/test-subrepo.t
> +++ b/tests/test-subrepo.t
> @@ -320,7 +320,7 @@
>    no changes found
>    pushing subrepo s to $TESTTMP/t/s (glob)
>    searching for changes
> -  abort: push creates new remote head 12a213df6fa9!
> +  abort: push creates new remote head 12a213df6fa9! (on subrepo
> $TESTTMP/t/s (glob))
>    (did you forget to merge? use push -f to force)
>    [255]
>    $ hg push -f

Please note that I was not able to run the test that I modified on my
Windows7 machine. I think it may be due to my PC configuration. If you
guys think this change makes sense I will try to sort the problem and
run the test.

I believe there are no other tests that need to be modified.

Cheers,

Angel
Matt Harbison - Dec. 15, 2012, 4:59 a.m.
On Fri, 14 Dec 2012 09:41:27 +0100, Angel Ezquerra wrote:

> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra at gmail.com>
> # Date 1355438273 -3600
> # Node ID b5af4658272135a1a9bbe67affc1955dd478861f
> # Parent 34a1a639d8358e43f4bcba7b0cff19f4e4e6958d
> subrepo: append subrepo path to subrepo push error messages

[...]

> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py ---
> a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -567,7 +567,12 @@
>          self._repo.ui.status(_('pushing subrepo %s to %s\n') %
>              (subrelpath(self), dsturl))
>          other = hg.peer(self._repo, {'ssh': ssh}, dsturl)
> -        return self._repo.push(other, force, newbranch=newbranch)
> +        try:
> +            res = self._repo.push(other, force, newbranch=newbranch)
> +        except error.Abort, ex:
> +            errormsg = ex.message + (' (on subrepo %s)' % self._path)
> +            raise util.Abort(errormsg,  hint=ex.hint)
> +        return res

I really like this idea.  I'd suggest changing self._path to
subrelpath(self) though, so that deeply nested subrepos print like this:

  abort: push creates new remote head 0fcb2198c4a8! (on subrepo s\ss)

instead of just naming subrepo 'ss'.  I think that's more consistent with 
other subrepo references than to list the absolute path or local name 
(e.g. the output of commit).

--Matt

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -567,7 +567,12 @@ 
         self._repo.ui.status(_('pushing subrepo %s to %s\n') %
             (subrelpath(self), dsturl))
         other = hg.peer(self._repo, {'ssh': ssh}, dsturl)
-        return self._repo.push(other, force, newbranch=newbranch)
+        try:
+            res = self._repo.push(other, force, newbranch=newbranch)
+        except error.Abort, ex:
+            errormsg = ex.message + (' (on subrepo %s)' % self._path)
+            raise util.Abort(errormsg,  hint=ex.hint)
+        return res

     def outgoing(self, ui, dest, opts):
         return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts)
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -320,7 +320,7 @@ 
   no changes found
   pushing subrepo s to $TESTTMP/t/s (glob)
   searching for changes
-  abort: push creates new remote head 12a213df6fa9!
+  abort: push creates new remote head 12a213df6fa9! (on subrepo
$TESTTMP/t/s (glob))
   (did you forget to merge? use push -f to force)
   [255]