changeset 8499:fb9b83df45f3

commit: move description trimming into changelog
author Matt Mackall <mpm@selenic.com>
date Mon, 18 May 2009 17:36:24 -0500
parents a5182c39766a
children 1024bef53d9e
files mercurial/changelog.py mercurial/localrepo.py
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Mon May 18 17:36:24 2009 -0500
+++ b/mercurial/changelog.py	Mon May 18 17:36:24 2009 -0500
@@ -209,6 +209,10 @@
         if "\n" in user:
             raise error.RevlogError(_("username %s contains a newline")
                                     % repr(user))
+
+        # strip trailing whitespace and leading and trailing empty lines
+        desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
+
         user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
 
         if date:
--- a/mercurial/localrepo.py	Mon May 18 17:36:24 2009 -0500
+++ b/mercurial/localrepo.py	Mon May 18 17:36:24 2009 -0500
@@ -884,15 +884,10 @@
             mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
                                    p2.manifestnode(), (new, drop))
 
-            text = ctx.description()
-            lines = [line.rstrip() for line in text.rstrip().splitlines()]
-            while lines and not lines[0]:
-                del lines[0]
-            text = '\n'.join(lines)
-
+            # update changelog
             self.changelog.delayupdate()
-            n = self.changelog.add(mn, changed + removed, text, trp,
-                                   p1.node(), p2.node(),
+            n = self.changelog.add(mn, changed + removed, ctx.description(),
+                                   trp, p1.node(), p2.node(),
                                    user, ctx.date(), ctx.extra().copy())
             p = lambda: self.changelog.writepending() and self.root or ""
             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,