Erik Zielke committed da45667

Saving collected commit messages to a file, when there is not commit messages for all patchs. Added test for feature.

Comments (0)

Files changed (2)

     editedmessages = ui.edit(allmessages, ui.username)
     if editedmessages != allmessages:
-        commitmessages = parsemessage(ui, editedmessages, appliedbefore)
+        commitmessages = parsemessage(ui, editedmessages,
+                                      appliedbefore, oldwrite)
         if commitmessages:
             savecommitcomments(ui, repo, mq, appliedbefore, commitmessages)
             ui.write = oldwrite
        "HG: Applied patches:\n"
        "HG: --\n")
-def parsemessage(ui, text, appliedbefore):
+def parsemessage(ui, text, appliedbefore, oldwrite):
     """Parses the edited text.
     It parses it to a map from patch name to lines of the commit messages
     if set(commitcomments.keys()) != set(appliedbeforenames):
+        f = open('editcommitmsgs.backup', 'w')
+        f.write(text)
+        f.close()
+        ui.write = oldwrite
         ui.warn(_("abort: Could not find comments for all patches\n"))
+        ui.write(_("backup saved to editcommitmsgs.backup\n"))
         return None
     return commitcomments


   $ HGEDITOR="'`pwd`'"/editor3 
   $ hg qeditcommitmsgs
   abort: Could not find comments for all patches
+  backup saved to editcommitmsgs.backup
+  $ cat editcommitmsgs.backup
+  HG: Enter commit messages for the different patches.
+  HG: Lines beginning with 'HG:' is used to apply the
+  HG: messages to the right patch, and gives some status on the patch
+  HG: Which can help you write the commit messages, so please do not
+  HG: edit them
+  HG: --
+  HG: Applied patches:
+  HG: --
+  HG: Patch: p1
+  This is the first patch
+  HG: --
+  HG: Patch: p2
+  This is the second patch
+  This is second line of second patch
+  HG: --
   $ hg log -l1 --template "{desc}\n"
   This is the third patch
   $ hg log -l1 --template "{desc}\n" -r -2
   HG: no files changed
   HG: --