Patchwork [6,of,7,STABLE] histedit: save manually edited commit message into ".hg/last-message.txt"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 18, 2014, 4:18 p.m.
Message ID <5d22cadd1938d759a099.1395159524@juju>
Download mbox | patch
Permalink /patch/3965/
State Superseded
Commit a0f437e2f5a900fccd7812e66ce27b68a6ac4fad
Headers show

Comments

Katsunori FUJIWARA - March 18, 2014, 4:18 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1395158861 -32400
#      Wed Mar 19 01:07:41 2014 +0900
# Branch stable
# Node ID 5d22cadd1938d759a0997a1c12a869a80d7498b8
# Parent  1e686e55780c1e233d54c79c044c9a5c0ffa65ea
histedit: save manually edited commit message into ".hg/last-message.txt"

Before this patch, manually edited commit message for "fold" command
in histedit-ing is never saved into ".hg/last-message.txt", because it
uses "localrepository.commitctx()" instead of
"localrepository.commit()": saving into ".hg/last-message.txt" is
executed only in the latter.

This patch saves manually edited commit message for "fold" command in
histedit-ing into ".hg/last-message.txt" just after user editing.

This is the simplest implementation to fix on stable. Editing and
saving commit message for memctx should be centralized into the
framework like "localrepository.commit()" with "editor" argument or so
in the future.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -294,6 +294,7 @@ 
                          date=date,
                          extra=extra)
     new._text = cmdutil.commitforceeditor(repo, new, [])
+    repo.savecommitmessage(new.description())
     return repo.commitctx(new)
 
 def pick(ui, repo, ctx, ha, opts):
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -105,6 +105,69 @@ 
   
   
 
+check saving last-message.txt
+
+  $ cat > $TESTDIR/abortfolding.py <<EOF
+  > from mercurial import util
+  > def abortfolding(ui, repo, hooktype, **kwargs):
+  >     ctx = repo[kwargs.get('node')]
+  >     if set(ctx.files()) == set(['c', 'd', 'f']):
+  >         return True # abort folding commit only
+  >     ui.warn('allow non-folding commit\\n')
+  > EOF
+  $ cat > .hg/hgrc <<EOF
+  > [hooks]
+  > pretxncommit.abortfolding = python:$TESTDIR/abortfolding.py:abortfolding
+  > EOF
+
+  $ cat > $TESTDIR/editor.sh << EOF
+  > echo "==== before editing"
+  > cat \$1
+  > echo "===="
+  > echo "check saving last-message.txt" >> \$1
+  > EOF
+
+  $ rm -f .hg/last-message.txt
+  $ HGEDITOR="sh $TESTDIR/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle
+  > pick 6de59d13424a f
+  > fold 9c277da72c9b d
+  > EOF
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  allow non-folding commit
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  ==== before editing
+  f
+  ***
+  c
+  ***
+  d
+  
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: changed c
+  HG: changed d
+  HG: changed f
+  ====
+  transaction abort!
+  rollback completed
+  abort: pretxncommit.abortfolding hook failed
+
+  $ cat .hg/last-message.txt
+  f
+  ***
+  c
+  ***
+  d
+  
+  
+  
+  check saving last-message.txt
+
   $ cd ..
 
 folding and creating no new change doesn't break: