[PATCH] histedit: use descriptive comments to combine commit messages in fold

Denis Laxalde denis at laxalde.org
Tue Jan 8 08:48:33 CST 2013


# HG changeset patch
# User Denis Laxalde <denis at laxalde.org>
# Date 1357565293 -3600
# Node ID a522e70fa65d58f667bd8de4162c6eeb67f46b3a
# Parent  83e8f22da9c2895f8cb0c7a8662e064477d63538
histedit: use descriptive comments to combine commit messages in fold

The combined template message resulting from a fold in histedit is made of
comments (i.e. "HG: [...]") intercalated between commit messages of folded
changesets instead of the previous "***".

Tests updated.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -324,11 +324,11 @@ def finishfold(ui, repo, ctx, oldctx, ne
         username = ui.username()
     commitopts['user'] = username
     # commit message
-    newmessage = '\n***\n'.join(
-        [ctx.description()] +
-        [repo[r].description() for r in internalchanges] +
-        [oldctx.description()]) + '\n'
-    commitopts['message'] = newmessage
+    allctx = [ctx] + [repo[r] for r in internalchanges] + [oldctx]
+    newmessage = ["HG: This is a fold of %d changesets." % len(allctx)]
+    newmessage += ["HG: Commit message of changeset %s.\n\n%s\n" %
+                   (c.rev(), c.description()) for c in allctx]
+    commitopts['message'] = "\n".join(newmessage)
     # date
     commitopts['date'] = max(ctx.date(), oldctx.date())
     n = collapse(repo, ctx, repo[newnode], commitopts)
diff --git a/tests/test-histedit-fold-non-commute.t b/tests/test-histedit-fold-non-commute.t
--- a/tests/test-histedit-fold-non-commute.t
+++ b/tests/test-histedit-fold-non-commute.t
@@ -104,8 +104,13 @@ fix up
   > EOF
   $ HGEDITOR="python cat.py" hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  HG: This is a fold of 2 changesets.
+  HG: Commit message of changeset 4.
+  
   d
-  ***
+  
+  HG: Commit message of changeset 7.
+  
   does not commute with e
   
   
@@ -136,13 +141,13 @@ just continue this time
 
 log after edit
   $ hg log --graph
-  @  changeset:   5:2696a654c663
+  @  changeset:   5:0ccfa1833e44
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:ec2c1cf833a8
+  o  changeset:   4:6feb8a25280e
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
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
@@ -240,10 +240,17 @@ dropped revision.
   $ echo 6 >> file
   $ HGEDITOR=cat hg histedit --continue
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  HG: This is a fold of 3 changesets.
+  HG: Commit message of changeset 1.
+  
   +4
-  ***
+  
+  HG: Commit message of changeset 4.
+  
   +5.2
-  ***
+  
+  HG: Commit message of changeset 3.
+  
   +6
   
   
@@ -256,9 +263,9 @@ dropped revision.
   HG: changed file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-backup.hg (glob)
+  saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-backup.hg
   $ hg log -G
-  @  changeset:   1:e29e02896e6c
+  @  changeset:   1:1990adcd9f2e
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
@@ -273,15 +280,17 @@ dropped revision.
   # HG changeset patch
   # User test
   # Date 0 0
-  # Node ID e29e02896e6c2b149d2228a0a64b4f3a9a4237f3
+  # Node ID 1990adcd9f2efd3d9e758a6598af417ad5d0d806
   # Parent  0189ba417d34df9dda55f88b637dcae9917b5964
   +4
-  ***
+  
+  
   +5.2
-  ***
+  
+  
   +6
   
-  diff -r 0189ba417d34 -r e29e02896e6c file
+  diff -r 0189ba417d34 -r 1990adcd9f2e file
   --- a/file	Thu Jan 01 00:00:00 1970 +0000
   +++ b/file	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,3 +1,6 @@


More information about the Mercurial-devel mailing list