diff --git a/hgext/mq.py b/hgext/mq.py index ebf7906ab6..bb49cca120 100644 --- a/hgext/mq.py +++ b/hgext/mq.py @@ -139,7 +139,7 @@ class queue: # 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) diff --git a/mercurial/commands.py b/mercurial/commands.py index 3387955929..5a23303faa 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1713,14 +1713,14 @@ def import_(ui, repo, patch1, *patches, **opts): 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) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py index e98f18d8f5..d8ed135654 100644 --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -550,12 +550,15 @@ class localrepository(object): # 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)