# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 2007-07-26 21:47:31
# Node ID 7f5c3fb0a37df1ac52d69a274fb92c8f8072cd1c
# Parent  6d1d97b093843f69893f6f69e1f0d4c5881d42a7

localrepo.commit: only munge comment text if committing via dirstate

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -789,14 +789,17 @@ class localrepository(repo.repository):
                 text = self.ui.edit("\n".join(edittext), user)
                 os.chdir(olddir)
 
-            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)
             if branchname:
                 extra["branch"] = branchname
+
+            if use_dirstate:
+                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 + removed, text, trp, p1, p2,
                                    user, date, extra)
             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,