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

Angel Ezquerra angel.ezquerra at gmail.com
Fri Dec 14 02:41:27 CST 2012


# 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
-------------- 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>


More information about the Mercurial-devel mailing list