changeset 2301:7c2623aedeb4

Strip empty lines and trailing spaces around commit messages. Fixes issue213 and part of issue249 (trying to keep node id on import)
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 17 May 2006 19:38:41 +0200
parents 52b9b6751b2c
children 506fcf779cae
files hgext/mq.py mercurial/commands.py mercurial/localrepo.py
diffstat 3 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed May 17 19:00:16 2006 +0200
+++ b/hgext/mq.py	Wed May 17 19:38:41 2006 +0200
@@ -139,7 +139,7 @@
                 # when looking for tags (subject: from: etc) they
                 # end once you find a blank line in the source
                 format = "tagdone"
-            else:
+            elif message or line:
                 message.append(line)
             comments.append(line)
 
--- a/mercurial/commands.py	Wed May 17 19:00:16 2006 +0200
+++ b/mercurial/commands.py	Wed May 17 19:38:41 2006 +0200
@@ -1713,14 +1713,14 @@
             elif line == '# HG changeset patch':
                 hgpatch = True
                 message = []       # We may have collected garbage
-            else:
+            elif message or line:
                 message.append(line)
 
         # make sure message isn't empty
         if not message:
             message = _("imported patch %s\n") % patch
         else:
-            message = "%s\n" % '\n'.join(message)
+            message = '\n'.join(message).rstrip()
         ui.debug(_('message:\n%s\n') % message)
 
         files = util.patch(strip, pf, ui)
--- a/mercurial/localrepo.py	Wed May 17 19:00:16 2006 +0200
+++ b/mercurial/localrepo.py	Wed May 17 19:38:41 2006 +0200
@@ -550,12 +550,15 @@
             # run editor in the repository root
             olddir = os.getcwd()
             os.chdir(self.root)
-            edittext = self.ui.edit("\n".join(edittext), user)
+            text = self.ui.edit("\n".join(edittext), user)
             os.chdir(olddir)
-            if not edittext.rstrip():
-                return None
-            text = edittext
 
+        lines = [line.rstrip() for line in text.rstrip().splitlines()]
+        while lines and not lines[0]:
+            del lines[0]
+        if not lines:
+            return None
+        text = '\n'.join(lines)
         n = self.changelog.add(mn, changed + remove, text, tr, p1, p2, user, date)
         self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
                   parent2=xp2)