Show added files as "added" in editor commit message (issue 1330)
authorPatrick Mezard <pmezard@gmail.com>
Thu, 09 Oct 2008 14:16:17 +0200
changeset 7072 4e0d54fbd34f
parent 7071 643c751e60b2
child 7075 6db6f6db026a
Show added files as "added" in editor commit message (issue 1330)
mercurial/localrepo.py
tests/test-commit
tests/test-commit.out
--- a/mercurial/localrepo.py	Wed Oct 08 19:58:35 2008 -0500
+++ b/mercurial/localrepo.py	Thu Oct 09 14:16:17 2008 +0200
@@ -860,6 +860,13 @@
                     else:
                         remove.append(f)
 
+            updated, added = [], []
+            for f in util.sort(changed):
+                if f in m1 or f in m2:
+                    updated.append(f)
+                else:
+                    added.append(f)
+
             # update manifest
             m1.update(new)
             removed = []
@@ -888,9 +895,10 @@
                     edittext.append("HG: branch merge")
                 if branchname:
                     edittext.append("HG: branch '%s'" % util.tolocal(branchname))
-                edittext.extend(["HG: changed %s" % f for f in changed])
+                edittext.extend(["HG: added %s" % f for f in added])
+                edittext.extend(["HG: changed %s" % f for f in updated])
                 edittext.extend(["HG: removed %s" % f for f in removed])
-                if not changed and not remove:
+                if not added and not updated and not removed:
                     edittext.append("HG: no files changed")
                 edittext.append("")
                 # run editor in the repository root
--- a/tests/test-commit	Wed Oct 08 19:58:35 2008 -0500
+++ b/tests/test-commit	Thu Oct 09 14:16:17 2008 +0200
@@ -106,5 +106,21 @@
 hg ci -mmerge -I a
 echo % should succeed
 hg ci -mmerge
+cd ..
+
+
+echo % test commit message content
+hg init commitmsg
+cd commitmsg
+echo changed > changed
+echo removed > removed
+hg ci -qAm init
+
+hg rm removed
+echo changed >> changed
+echo added > added
+hg add added
+HGEDITOR=cat hg ci -A
+cd ..
 
 exit 0
--- a/tests/test-commit.out	Wed Oct 08 19:58:35 2008 -0500
+++ b/tests/test-commit.out	Thu Oct 09 14:16:17 2008 +0200
@@ -106,3 +106,16 @@
 % should fail because we are specifying a pattern
 abort: cannot partially commit a merge (do not specify files or patterns)
 % should succeed
+% test commit message content
+
+
+HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+HG: --
+HG: user: test
+HG: branch 'default'
+HG: added added
+HG: changed changed
+HG: removed removed
+transaction abort!
+rollback completed
+abort: empty commit message