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.
rm 'd/b'
assuming destination git-repo-hg
initializing destination git-repo-hg repository
scanning source...
sorting...
converting...
5 t1
4 t2
3 t3
2 t4.1
1 t4.2
0 Merge branch other
changeset: 5:4ab1af49a271
tag: tip
parent: 3:0222ab0998d7
parent: 4:5333c870e3c2
user: test <test@example.org>
date: Mon Jan 01 00:00:15 2007 +0000
files: a
description:
Merge branch other
committer: test <test@example.org>
% full conversion
o 9 "Discard change to foo" files: foo
|\
| o 8 "change foo" files: foo
| |
o | 7 "change bar" files: bar
|/
o 6 "(octopus merge fixup)" files:
|\
| o 5 "Octopus merge" files: baz
| |\
o | | 4 "add baz" files: baz
| | |
+---o 3 "add bar" files: bar
| |
o | 2 "add quux" files: quux
| |
| o 1 "change foo" files: foo
|/
o 0 "add foo" files: foo
245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
% foo bar baz: octopus merge
o 8 "Discard change to foo" files: foo
|\
| o 7 "change foo" files: foo
| |
o | 6 "change bar" files: bar
|/
o 5 "(octopus merge fixup)" files:
|\
| o 4 "Octopus merge" files: baz
| |\
o | | 3 "add baz" files: baz
| | |
+---o 2 "add bar" files: bar
| |
| o 1 "change foo" files: foo
|/
o 0 "add foo" files: foo
245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
% foo baz quux: only some parents of an octopus merge; "discard" a head
o 6 "Discard change to foo" files: foo
|
o 5 "change foo" files: foo
|
o 4 "Octopus merge" files:
|\
| o 3 "add baz" files: baz
| |
| o 2 "add quux" files: quux
| |
o | 1 "change foo" files: foo
|/
o 0 "add foo" files: foo
354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux