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

login
register
mail settings
Submitter Denis Laxalde
Date Jan. 15, 2013, 2:34 p.m.
Message ID <50F568F4.3080109@laxalde.org>
Download mbox | patch
Permalink /patch/629/
State Rejected
Headers show

Comments

Denis Laxalde - Jan. 15, 2013, 2:34 p.m.
# HG changeset patch
# User Denis Laxalde <denis@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.

    $ 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 @@
Dave S - Jan. 15, 2013, 6:39 p.m.
On Tue, Jan 15, 2013 at 6:34 AM, Denis Laxalde <denis@laxalde.org> wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@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.

Interesting.   Something about this patch confused Patchworks, and
right after these lines:

> $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

All this stuff got left in the comments section, and not in the patch block:

>    $ 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 @@


/dps
Pierre-Yves David - Jan. 15, 2013, 8:12 p.m.
On 15 janv. 2013, at 21:08, Kevin Bullock wrote:

> On Jan 15, 2013, at 8:34 AM, Denis Laxalde wrote:
> 
>> # HG changeset patch
>> # User Denis Laxalde <denis@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 "***".
> 
> What happens when I don't edit the message, save, and quit my editor? Does the commit message include the new 'HG: ' lines, or the same '***' as before, or just no separation?

No separation, HG: dropping is done by Mercurial itself post editor call.
Augie Fackler - Jan. 16, 2013, 3:28 p.m.
On Tue, Jan 15, 2013 at 3:16 PM, Kevin Bullock <
kbullock+mercurial@ringworld.org> wrote:

> I'm -1 then. Would be better if we could preserve the '***' separator in
> the committed message.



I agree. If the user makes no edit, the *** should stay.
Pierre-Yves David - Jan. 16, 2013, 4:20 p.m.
On Wed, Jan 16, 2013 at 10:28:48AM -0500, Augie Fackler wrote:
> On Tue, Jan 15, 2013 at 3:16 PM, Kevin Bullock <
> kbullock+mercurial@ringworld.org> wrote:
> 
> > I'm -1 then. Would be better if we could preserve the '***' separator in
> > the committed message.
> 
> 
> 
> I agree. If the user makes no edit, the *** should stay.

Hum, how would we detect that? In particular how do we distinguish non
edition vs "the user decided it was ok as is"

Patch

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