Prompt for a commit message in editor, improve error message
authorPatrick Mezard <pmezard@gmail.com>
Fri, 28 Dec 2007 14:51:16 +0100
changeset 5754 75c2071385da
parent 5699 4cf5a4950fc9
child 5755 43ee007dbd0e
child 5756 6183df642f95
Prompt for a commit message in editor, improve error message
mercurial/localrepo.py
tests/test-commit
tests/test-commit.out
tests/test-import.out
tests/test-record.out
--- a/mercurial/localrepo.py	Thu Dec 27 22:28:41 2007 +0100
+++ b/mercurial/localrepo.py	Fri Dec 28 14:51:16 2007 +0100
@@ -803,6 +803,8 @@
                 if text:
                     edittext.append(text)
                 edittext.append("")
+                edittext.append(_("HG: Please write and save a commit message"))
+                edittext.append("HG: --")
                 edittext.append("HG: user: %s" % user)
                 if p2 != nullid:
                     edittext.append("HG: branch merge")
@@ -827,7 +829,7 @@
                 while lines and not lines[0]:
                     del lines[0]
                 if not lines:
-                    return None
+                    raise util.Abort(_("commit message cannot be left blank"))
                 text = '\n'.join(lines)
 
             n = self.changelog.add(mn, changed + removed, text, trp, p1, p2,
--- a/tests/test-commit	Thu Dec 27 22:28:41 2007 +0100
+++ b/tests/test-commit	Fri Dec 28 14:51:16 2007 +0100
@@ -10,6 +10,7 @@
 cd test
 echo foo > foo
 hg add foo
+HGEDITOR=true hg commit -m ""
 hg commit -d '0 0' -m commit-1
 echo foo >> foo
 hg commit -d '1 4444444' -m commit-3
--- a/tests/test-commit.out	Thu Dec 27 22:28:41 2007 +0100
+++ b/tests/test-commit.out	Fri Dec 28 14:51:16 2007 +0100
@@ -1,6 +1,9 @@
 % commit date test
 transaction abort!
 rollback completed
+abort: commit message cannot be left blank
+transaction abort!
+rollback completed
 abort: impossible time zone offset: 4444444
 transaction abort!
 rollback completed
--- a/tests/test-import.out	Thu Dec 27 22:28:41 2007 +0100
+++ b/tests/test-import.out	Fri Dec 28 14:51:16 2007 +0100
@@ -22,6 +22,7 @@
 applying ../tip.patch
 transaction abort!
 rollback completed
+abort: commit message cannot be left blank
 % import of plain diff should be ok with message
 requesting all changes
 adding changesets
@@ -91,6 +92,7 @@
 applying patch from stdin
 transaction abort!
 rollback completed
+abort: commit message cannot be left blank
 % hg export in email, should use patch header
 requesting all changes
 adding changesets
--- a/tests/test-record.out	Thu Dec 27 22:28:41 2007 +0100
+++ b/tests/test-record.out	Fri Dec 28 14:51:16 2007 +0100
@@ -50,6 +50,7 @@
 new file mode 100644
 examine changes to 'empty-rw'? [Ynsfdaq?]  transaction abort!
 rollback completed
+abort: commit message cannot be left blank
 
 changeset:   -1:000000000000
 tag:         tip