diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -135,12 +135,24 @@ def dorecord(ui, repo, commitfunc, cmdsu """ checkunfinished(repo, commit=True) - merge = len(repo[None].parents()) > 1 + wctx = repo[None] + merge = len(wctx.parents()) > 1 if merge: raise error.Abort(_('cannot partially commit a merge ' '(use "hg commit" instead)')) + def fail(f, msg): + raise error.Abort('%s: %s' % (f, msg)) + + force = opts.get('force') + if not force: + vdirs = [] + match.explicitdir = vdirs.append + match.bad = fail + status = repo.status(match=match) + if not force: + repo.checkcommitpatterns(wctx, vdirs, match, status, fail) diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True) diffopts.nodates = True diffopts.git = True diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t --- a/tests/test-commit-interactive.t +++ b/tests/test-commit-interactive.t @@ -59,6 +59,14 @@ Select files but no hunks +Abort for untracked + + $ touch untracked + $ hg commit -i -m should-fail empty-rw untracked + abort: untracked: file not tracked! + [255] + $ rm untracked + Record empty file $ hg commit -i -d '0 0' -m empty empty-rw<