changeset 6254:3667b6e4bbd0

localrepo.commit: normalize commit message even for rawcommit. This normalization consists of: - stripping trailing whitespace - always using "\n" as the line separator I think the main reason rawcommit was skipping this normalization was an attempt to preserve hashes during an hg->hg conversion. While this is a nice goal, it's not particularly interesting in practice. Since SHA-1 is so strong, the only safe way to do it is to have absolutely identical revisions. But: - if the original revision was created with a recent version of hg, the commit message will be the same, with or without that normalization - if it was created with an ancient version of hg that didn't do any normalization, even if the commit message is identical, the file list in the changelog is likely to be different (e.g. no removed files), and there were some old issues with e.g. extra file merging, which will end up changing the hash anyway - in any case, if one *really* has to preserve hashes, it's easier (and faster) to fake a partial conversion using something like: hg clone -U -r rev orig-repo new-repo hg -R new-repo log --template '#node# #node#\n' > new-repo/.hg/shamap Additionally, we've had some reports of problems arising from this lack of normalization - e.g. issue871, and a user that was wondering why hg export/hg import was not preserving hashes when there was nothing unusual going on (it was just import doing the normalization that had been skipped). This also means that it's even more unlikely to get identical revisions when going $VCS->hg->$VCS.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 14 Mar 2008 09:56:58 -0300
parents a7e3d0456d92
children ae83d927c629
files mercurial/localrepo.py tests/test-convert-git.out
diffstat 2 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Mar 14 09:56:58 2008 -0300
+++ b/mercurial/localrepo.py	Fri Mar 14 09:56:58 2008 -0300
@@ -883,13 +883,12 @@
             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:
-                    raise util.Abort(_("empty commit message"))
-                text = '\n'.join(lines)
+            lines = [line.rstrip() for line in text.rstrip().splitlines()]
+            while lines and not lines[0]:
+                del lines[0]
+            if not lines and use_dirstate:
+                raise util.Abort(_("empty commit message"))
+            text = '\n'.join(lines)
 
             n = self.changelog.add(mn, changed + removed, text, trp, p1, p2,
                                    user, date, extra)
--- a/tests/test-convert-git.out	Fri Mar 14 09:56:58 2008 -0300
+++ b/tests/test-convert-git.out	Fri Mar 14 09:56:58 2008 -0300
@@ -10,10 +10,10 @@
 2 t4.1
 1 t4.2
 0 Merge branch other
-changeset:   5:c6d72c98aa00
+changeset:   5:4ab1af49a271
 tag:         tip
-parent:      3:a18bdfccf429
-parent:      4:48cb5b72ce56
+parent:      3:0222ab0998d7
+parent:      4:5333c870e3c2
 user:        test <test@example.org>
 date:        Mon Jan 01 00:00:15 2007 +0000
 files:       a