diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1372,10 +1372,10 @@ class localrepository(object): if not force: raise util.Abort( _("commit with new subrepo %s excluded") % s) - if wctx.sub(s).dirty(True): + dirtyreason = wctx.sub(s).dirtyreason(True) + if dirtyreason: if not self.ui.configbool('ui', 'commitsubrepos'): - raise util.Abort( - _("uncommitted changes in subrepo %s") % s, + raise util.Abort(dirtyreason, hint=_("use --subrepos for recursive commit")) subs.append(s) commitsubs.add(s) diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -390,6 +390,18 @@ class abstractsubrepo(object): """ raise NotImplementedError + def dirtyreason(self, ignoreupdate=False): + """return reason string if it is ``dirty()`` + + Returned string should have enough information for the message + of exception. + + This returns None, otherwise. + """ + if self.dirty(ignoreupdate=ignoreupdate): + return _("uncommitted changes in subrepository '%s'" + ) % subrelpath(self) + def basestate(self): """current working directory base state, disregarding .hgsubstate state and working directory modifications""" diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t --- a/tests/test-largefiles-misc.t +++ b/tests/test-largefiles-misc.t @@ -248,7 +248,7 @@ verify that large files in subrepos hand commit: 1 subrepos update: (current) $ hg ci -m "this commit should fail without -S" - abort: uncommitted changes in subrepo subrepo + abort: uncommitted changes in subrepository 'subrepo' (use --subrepos for recursive commit) [255] diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t --- a/tests/test-subrepo-recursion.t +++ b/tests/test-subrepo-recursion.t @@ -59,7 +59,7 @@ Test recursive diff without committing a Commits: $ hg commit -m fails - abort: uncommitted changes in subrepo foo + abort: uncommitted changes in subrepository 'foo' (use --subrepos for recursive commit) [255] diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -146,7 +146,7 @@ leave sub dirty (and check ui.commitsubr $ echo c > s/a $ hg --config ui.commitsubrepos=no ci -m4 - abort: uncommitted changes in subrepo s + abort: uncommitted changes in subrepository 's' (use --subrepos for recursive commit) [255] $ hg id