Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 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 | 437eef39458d |
children | 08800489257e |
comparison
equal
deleted
inserted
replaced
6253:a7e3d0456d92 | 6254:3667b6e4bbd0 |
---|---|
881 os.chdir(olddir) | 881 os.chdir(olddir) |
882 | 882 |
883 if branchname: | 883 if branchname: |
884 extra["branch"] = branchname | 884 extra["branch"] = branchname |
885 | 885 |
886 if use_dirstate: | 886 lines = [line.rstrip() for line in text.rstrip().splitlines()] |
887 lines = [line.rstrip() for line in text.rstrip().splitlines()] | 887 while lines and not lines[0]: |
888 while lines and not lines[0]: | 888 del lines[0] |
889 del lines[0] | 889 if not lines and use_dirstate: |
890 if not lines: | 890 raise util.Abort(_("empty commit message")) |
891 raise util.Abort(_("empty commit message")) | 891 text = '\n'.join(lines) |
892 text = '\n'.join(lines) | |
893 | 892 |
894 n = self.changelog.add(mn, changed + removed, text, trp, p1, p2, | 893 n = self.changelog.add(mn, changed + removed, text, trp, p1, p2, |
895 user, date, extra) | 894 user, date, extra) |
896 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, | 895 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
897 parent2=xp2) | 896 parent2=xp2) |