changeset 5989:056033a7689f stable

fold: make sure to save commit messages in last-message.txt on rewrites
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 29 Jul 2021 22:45:51 +0300
parents 5578f21b43c1
children 189f4775ac2b
files CHANGELOG hgext3rd/evolve/rewriteutil.py tests/test-fold.t
diffstat 3 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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
--- 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 ..