[PATCH] subrepo: append subrepo path to subrepo push error messages

Angel Ezquerra angel.ezquerra at gmail.com
Fri Dec 14 02:43:50 CST 2012


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


More information about the Mercurial-devel mailing list