# HG changeset patch # User Anton Shestakov # Date 1627587951 -10800 # Node ID 056033a7689fda9ff8385f3c6f97027be31d20c3 # Parent 5578f21b43c1634ed76bee55cc2b510416fcb164 fold: make sure to save commit messages in last-message.txt on rewrites diff -r 5578f21b43c1 -r 056033a7689f CHANGELOG --- a/CHANGELOG Wed Aug 04 00:46:06 2021 +0300 +++ b/CHANGELOG Thu Jul 29 22:45:51 2021 +0300 @@ -4,6 +4,9 @@ 10.3.3 - in progress -------------------- + * fold: make sure to save commit messages in last-message.txt, also affects + metaedit (issue6549) + topic (0.22.3) * topic: correctly update from public commits with a (now hidden) topic diff -r 5578f21b43c1 -r 056033a7689f hgext3rd/evolve/rewriteutil.py --- a/hgext3rd/evolve/rewriteutil.py Wed Aug 04 00:46:06 2021 +0300 +++ b/hgext3rd/evolve/rewriteutil.py Thu Jul 29 22:45:51 2021 +0300 @@ -258,13 +258,15 @@ for pctx in head.parents(): for dst, src in copies.pathcopies(pctx, head).items(): wctx[dst].markcopied(src) + editor = None + if commitopts.get(b'edit'): + editor = cmdutil.commitforceeditor new = wctx.tomemctx(text=message, parents=newbases, date=date, extra=extra, - user=user) - if commitopts.get(b'edit'): - new._text = cmdutil.commitforceeditor(repo, new, []) + user=user, + editor=editor) revcount = len(repo) newid = repo.commitctx(new) created = len(repo) != revcount diff -r 5578f21b43c1 -r 056033a7689f tests/test-fold.t --- a/tests/test-fold.t Wed Aug 04 00:46:06 2021 +0300 +++ b/tests/test-fold.t Thu Jul 29 22:45:51 2021 +0300 @@ -446,3 +446,34 @@ 2 changesets folded $ cd .. + +Saving the last user-edited message in last-message.txt +https://bz.mercurial-scm.org/show_bug.cgi?id=6549 + + $ hg init issue6549 + $ cd issue6549 + + $ echo A > foo + $ hg ci -qAm A + $ echo B > foo + $ hg ci -m B + + $ cat > editor.sh << 'EOF' + > echo 'Big commit message that was crafted with care.' > "$1" + > echo '' >> "$1" + > echo 'It would be a shame if something happened to it.' >> "$1" + > EOF + $ HGEDITOR="sh ./editor.sh" hg fold --exact --rev 'all()' + 2 changesets folded + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ hg glog + @ 2: Big commit message that was crafted with care. + + It would be a shame if something happened to it. + $ cat .hg/last-message.txt + Big commit message that was crafted with care. + + It would be a shame if something happened to it. + + $ cd ..