Created attachment 1761 [details] test repos Main repo push should fail if git subrepo push fails. Now it's not so, see log below for example: hg push pushing to https://hg.example.com/mainrepo ... pushing branch master of subrepo Dependencies/gitsubrepo To https://hg.example.com/gitsubrepo.git ! [rejected] master -> master (fetch first) <----- failure error: failed to push some refs to 'https://hg.example.com/gitsubrepo.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first merge the remote changes (e.g., hint: 'git pull') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. ... searching for changes remote: Repository size .hg:994.2 MB repo:255.0 MB total:1.2 GB remote: Last revision is now r24557:76c0aae10e55 <----- success To my mind, this is rather serious issue, as it leaves main repo in inconsistent state – .hgsubstate points to the commit in subrepo that is not available at remote server. I also believe that it must fail, as it does fail if hg subrepo push fails. To reproduce the issue, you can find test.zip in attachment. Try to push from 'loc_hg' directory.
Try this patch, please: diff -r c3712005cfc1 mercurial/subrepo.py --- a/mercurial/subrepo.py Fri Apr 04 17:50:44 2014 -0700 +++ b/mercurial/subrepo.py Fri Apr 11 15:36:54 2014 -0400 @@ -1463,8 +1463,8 @@ return False self._ui.status(_('pushing branch %s of subrepo %s\n') % (current.split('/', 2)[2], self._relpath)) - self._gitcommand(cmd + ['origin', current]) - return True + ret = self._gitdir(cmd + ['origin', current]) + return ret[1] == 0 else: self._ui.warn(_('no branch checked out in subrepo %s\n' 'cannot push revision %s\n') %
Fixed by http://selenic.com/repo/hg/rev/70312c95f2f7 Matt Mackall <mpm@selenic.com> subrepo: check return code for git push (issue4223) (please test the fix)
Yes, the patch does stop main repo push. However, there is still an issue – 'hg push' exits with 0 (zero) in case of git subrepo push failure. In case of mercurial subrepo push failure 'hg push' exits with 127.
Please test: changeset: 21488:693b4cb4330f user: Matt Mackall <mpm@selenic.com> date: Tue Apr 15 14:15:35 2014 -0400 files: mercurial/commands.py description: subrepo: return non-zero exit code when a subrepo push doesn't succeed
Works perfectly now! Thank you!