Patchwork histedit: improve documentation and behaviour of dates (issue4820)

login
register
mail settings
Submitter Ben Schmidt
Date Feb. 19, 2017, 3:51 a.m.
Message ID <4037ff1c9713d73b21dd.1487476306@Thoughtful.local>
Download mbox | patch
Permalink /patch/18675/
State Accepted
Headers show

Comments

Ben Schmidt - Feb. 19, 2017, 3:51 a.m.
# HG changeset patch
# User Ben Schmidt <insightfuls@users.noreply.github.com>
# Date 1487413828 -39600
#      Sat Feb 18 21:30:28 2017 +1100
# Node ID 4037ff1c9713d73b21ddc182580eacacba254ea7
# Parent  1f51b4658f21bbb797e922d155c1046eddccf91d
histedit: improve documentation and behaviour of dates (issue4820)

This clarifies in the histedit documentation that the 'edit' action preserves
the date and that the 'fold' action uses the later date. The documentation was
previously silent on this issue which left users in doubt.

It also adjusts and documents the new behaviour of 'roll'. It now fits nicely
with the behaviour of 'commit --amend' and the 'edit' action, by discarding the
date as well as the commit message of the second commit. Previously it used the
later date, like 'fold', but this often wasn't desirable, for example, in the
common use case of using 'roll' to add forgotten changes to a changeset
(because 'hg add' was previously forgotten or not all changes were identified
while using 'hg record').
Augie Fackler - Feb. 20, 2017, 1:23 a.m.
On Sun, Feb 19, 2017 at 02:51:46PM +1100, Ben Schmidt wrote:
> # HG changeset patch
> # User Ben Schmidt <insightfuls@users.noreply.github.com>
> # Date 1487413828 -39600
> #      Sat Feb 18 21:30:28 2017 +1100
> # Node ID 4037ff1c9713d73b21ddc182580eacacba254ea7
> # Parent  1f51b4658f21bbb797e922d155c1046eddccf91d
> histedit: improve documentation and behaviour of dates (issue4820)
>
> This clarifies in the histedit documentation that the 'edit' action preserves
> the date and that the 'fold' action uses the later date. The documentation was
> previously silent on this issue which left users in doubt.

Wow, that's a great fix.

> It also adjusts and documents the new behaviour of 'roll'. It now fits nicely
> with the behaviour of 'commit --amend' and the 'edit' action, by discarding the
> date as well as the commit message of the second commit. Previously it used the
> later date, like 'fold', but this often wasn't desirable, for example, in the
> common use case of using 'roll' to add forgotten changes to a changeset
> (because 'hg add' was previously forgotten or not all changes were identified
> while using 'hg record').

This...could stand to be its own patch (generally any time a commit
message contains the word "also" that's a sign you've really got two patches).

I'm also not sure I'm sold: why shouldn't roll advance the date?

>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -36,7 +36,7 @@
>   #  p, pick = use commit
>   #  e, edit = use commit, but stop for amending
>   #  f, fold = use commit, but combine it with the one above
> - #  r, roll = like fold, but discard this commit's description
> + #  r, roll = like fold, but discard this commit's description and date
>   #  d, drop = remove commit from history
>   #  m, mess = edit commit message without changing commit content
>   #
> @@ -58,7 +58,7 @@
>   #  p, pick = use commit
>   #  e, edit = use commit, but stop for amending
>   #  f, fold = use commit, but combine it with the one above
> - #  r, roll = like fold, but discard this commit's description
> + #  r, roll = like fold, but discard this commit's description and date
>   #  d, drop = remove commit from history
>   #  m, mess = edit commit message without changing commit content
>   #
> @@ -71,11 +71,11 @@
>   ***
>   Add delta
>
> -Edit the commit message to your liking, then close the editor. For
> -this example, let's assume that the commit message was changed to
> -``Add beta and delta.`` After histedit has run and had a chance to
> -remove any old or temporary revisions it needed, the history looks
> -like this::
> +Edit the commit message to your liking, then close the editor. The date used
> +for the commit will be the later of the two commits' dates. For this example,
> +let's assume that the commit message was changed to ``Add beta and delta.``
> +After histedit has run and had a chance to remove any old or temporary
> +revisions it needed, the history looks like this::
>
>   @  2[tip]   989b4d060121   2009-04-27 18:04 -0500   durin42
>   |    Add beta and delta.
> @@ -97,9 +97,10 @@
>  allowing you to edit files freely, or even use ``hg record`` to commit
>  some changes as a separate commit. When you're done, any remaining
>  uncommitted changes will be committed as well. When done, run ``hg
> -histedit --continue`` to finish this step. You'll be prompted for a
> -new commit message, but the default commit message will be the
> -original message for the ``edit`` ed revision.
> +histedit --continue`` to finish this step. If there are uncommitted
> +changes, you'll be prompted for a new commit message, but the default
> +commit message will be the original message for the ``edit`` ed
> +revision, and the date of the original commit will be preserved.
>
>  The ``message`` operation will give you a chance to revise a commit
>  message without changing the contents. It's a shortcut for doing
> @@ -724,6 +725,15 @@
>          """
>          return True
>
> +    def firstdate(self):
> +        """Returns true if the rule should preserve the date of the first
> +        change.
> +
> +        This exists mainly so that 'rollup' rules can be a subclass of
> +        'fold'.
> +        """
> +        return False
> +
>      def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges):
>          parent = ctx.parents()[0].node()
>          repo.ui.pushbuffer()
> @@ -742,7 +752,10 @@
>                  [oldctx.description()]) + '\n'
>          commitopts['message'] = newmessage
>          # date
> -        commitopts['date'] = max(ctx.date(), oldctx.date())
> +        if self.firstdate():
> +            commitopts['date'] = ctx.date()
> +        else:
> +            commitopts['date'] = max(ctx.date(), oldctx.date())
>          extra = ctx.extra().copy()
>          # histedit_source
>          # note: ctx is likely a temporary commit but that the best we can do
> @@ -809,7 +822,7 @@
>          return True
>
>  @action(["roll", "r"],
> -        _("like fold, but discard this commit's description"))
> +        _("like fold, but discard this commit's description and date"))
>  class rollup(fold):
>      def mergedescs(self):
>          return False
> @@ -817,6 +830,9 @@
>      def skipprompt(self):
>          return True
>
> +    def firstdate(self):
> +        return True
> +
>  @action(["drop", "d"],
>          _('remove commit from history'))
>  class drop(histeditaction):
> @@ -884,11 +900,11 @@
>
>      - `mess` to reword the changeset commit message
>
> -    - `fold` to combine it with the preceding changeset
> +    - `fold` to combine it with the preceding changeset (using the later date)
>
> -    - `roll` like fold, but discarding this commit's description
> +    - `roll` like fold, but discarding this commit's description and date
>
> -    - `edit` to edit this changeset
> +    - `edit` to edit this changeset (preserving date)
>
>      There are a number of ways to select the root changeset:
>
> diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
> --- a/tests/test-histedit-arguments.t
> +++ b/tests/test-histedit-arguments.t
> @@ -72,7 +72,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>
>  Run on a revision not ancestors of the current working directory.
> @@ -308,7 +308,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>
>  Test --continue with --keep
> @@ -544,7 +544,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>
>    $ cd ..
> diff --git a/tests/test-histedit-bookmark-motion.t b/tests/test-histedit-bookmark-motion.t
> --- a/tests/test-histedit-bookmark-motion.t
> +++ b/tests/test-histedit-bookmark-motion.t
> @@ -78,7 +78,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>    $ hg histedit 1 --commands - --verbose << EOF | grep histedit
>    > pick 177f92b77385 2 c
> @@ -141,7 +141,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>    $ hg histedit 1 --commands - --verbose << EOF | grep histedit
>    > pick b346ab9a313d 1 c
> diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t
> --- a/tests/test-histedit-commute.t
> +++ b/tests/test-histedit-commute.t
> @@ -72,7 +72,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>
>  edit the history
> @@ -350,7 +350,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>
>  should also work if a commit message is missing
> diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
> --- a/tests/test-histedit-edit.t
> +++ b/tests/test-histedit-edit.t
> @@ -478,5 +478,5 @@
>    #  p, fold = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
> 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
> @@ -5,6 +5,12 @@
>    > histedit=
>    > EOF
>
> +  $ modwithdate ()
> +  > {
> +  >     echo $1 > $1
> +  >     hg ci -m $1 -d "$2 0"
> +  > }
> +
>    $ initrepo ()
>    > {
>    >     hg init $1
> @@ -14,12 +20,14 @@
>    >         hg add $x
>    >     done
>    >     hg ci -m 'Initial commit'
> -  >     for x in a b c d e f ; do
> -  >         echo $x > $x
> -  >         hg ci -m $x
> -  >     done
> +  >     modwithdate a 1
> +  >     modwithdate b 2
> +  >     modwithdate c 3
> +  >     modwithdate d 4
> +  >     modwithdate e 5
> +  >     modwithdate f 6
>    >     echo 'I can haz no commute' > e
> -  >     hg ci -m 'does not commute with e'
> +  >     hg ci -m 'does not commute with e' -d '7 0'
>    >     cd ..
>    > }
>
> @@ -34,48 +42,48 @@
>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
>    $ cat $EDITED
> -  pick 65a9a84f33fd 3 c
> -  pick 00f1c5383965 4 d
> -  fold 39522b764e3d 7 does not commute with e
> -  pick 7b4e2f4b7bcd 5 e
> -  pick 500cac37a696 6 f
> +  pick 092e4ce14829 3 c
> +  pick ae78f4c9d74f 4 d
> +  fold 42abbb61bede 7 does not commute with e
> +  pick 7f3755409b00 5 e
> +  pick dd184f2faeb0 6 f
>
>  log before edit
>    $ hg log --graph
> -  @  changeset:   7:39522b764e3d
> +  @  changeset:   7:42abbb61bede
>    |  tag:         tip
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:07 1970 +0000
>    |  summary:     does not commute with e
>    |
> -  o  changeset:   6:500cac37a696
> +  o  changeset:   6:dd184f2faeb0
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>    |  summary:     f
>    |
> -  o  changeset:   5:7b4e2f4b7bcd
> +  o  changeset:   5:7f3755409b00
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:05 1970 +0000
>    |  summary:     e
>    |
> -  o  changeset:   4:00f1c5383965
> +  o  changeset:   4:ae78f4c9d74f
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:04 1970 +0000
>    |  summary:     d
>    |
> -  o  changeset:   3:65a9a84f33fd
> +  o  changeset:   3:092e4ce14829
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>    |  summary:     c
>    |
> -  o  changeset:   2:da6535b52e45
> +  o  changeset:   2:40ccdd8beb95
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>    |  summary:     b
>    |
> -  o  changeset:   1:c1f09da44841
> +  o  changeset:   1:cd997a145b29
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>    |  summary:     a
>    |
>    o  changeset:   0:1715188a53c7
> @@ -89,7 +97,7 @@
>    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    merging e
>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
> -  Fix up the change (fold 39522b764e3d)
> +  Fix up the change (fold 42abbb61bede)
>    (hg histedit --continue to resume)
>
>  fix up
> @@ -113,7 +121,7 @@
>    HG: changed e
>    merging e
>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
> -  Fix up the change (pick 7b4e2f4b7bcd)
> +  Fix up the change (pick 7f3755409b00)
>    (hg histedit --continue to resume)
>
>  just continue this time
> @@ -124,34 +132,34 @@
>    continue: hg histedit --continue
>    $ hg diff
>    $ hg histedit --continue 2>&1 | fixbundle
> -  7b4e2f4b7bcd: skipping changeset (no changes)
> +  7f3755409b00: skipping changeset (no changes)
>
>  log after edit
>    $ hg log --graph
> -  @  changeset:   5:d9cf42e54966
> +  @  changeset:   5:1300355b1a54
>    |  tag:         tip
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>    |  summary:     f
>    |
> -  o  changeset:   4:10486af2e984
> +  o  changeset:   4:e2ac33269083
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:07 1970 +0000
>    |  summary:     d
>    |
> -  o  changeset:   3:65a9a84f33fd
> +  o  changeset:   3:092e4ce14829
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>    |  summary:     c
>    |
> -  o  changeset:   2:da6535b52e45
> +  o  changeset:   2:40ccdd8beb95
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>    |  summary:     b
>    |
> -  o  changeset:   1:c1f09da44841
> +  o  changeset:   1:cd997a145b29
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>    |  summary:     a
>    |
>    o  changeset:   0:1715188a53c7
> @@ -175,7 +183,7 @@
>
>    $ cd ..
>
> -Repeat test using "roll", not "fold". "roll" folds in changes but drops message
> +Repeat test using "roll", not "fold". "roll" folds in changes but drops message and date
>
>    $ initrepo r2
>    $ cd r2
> @@ -189,48 +197,48 @@
>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
>    $ cat $EDITED
> -  pick 65a9a84f33fd 3 c
> -  pick 00f1c5383965 4 d
> -  roll 39522b764e3d 7 does not commute with e
> -  pick 7b4e2f4b7bcd 5 e
> -  pick 500cac37a696 6 f
> +  pick 092e4ce14829 3 c
> +  pick ae78f4c9d74f 4 d
> +  roll 42abbb61bede 7 does not commute with e
> +  pick 7f3755409b00 5 e
> +  pick dd184f2faeb0 6 f
>
>  log before edit
>    $ hg log --graph
> -  @  changeset:   7:39522b764e3d
> +  @  changeset:   7:42abbb61bede
>    |  tag:         tip
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:07 1970 +0000
>    |  summary:     does not commute with e
>    |
> -  o  changeset:   6:500cac37a696
> +  o  changeset:   6:dd184f2faeb0
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>    |  summary:     f
>    |
> -  o  changeset:   5:7b4e2f4b7bcd
> +  o  changeset:   5:7f3755409b00
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:05 1970 +0000
>    |  summary:     e
>    |
> -  o  changeset:   4:00f1c5383965
> +  o  changeset:   4:ae78f4c9d74f
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:04 1970 +0000
>    |  summary:     d
>    |
> -  o  changeset:   3:65a9a84f33fd
> +  o  changeset:   3:092e4ce14829
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>    |  summary:     c
>    |
> -  o  changeset:   2:da6535b52e45
> +  o  changeset:   2:40ccdd8beb95
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>    |  summary:     b
>    |
> -  o  changeset:   1:c1f09da44841
> +  o  changeset:   1:cd997a145b29
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>    |  summary:     a
>    |
>    o  changeset:   0:1715188a53c7
> @@ -244,7 +252,7 @@
>    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    merging e
>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
> -  Fix up the change (roll 39522b764e3d)
> +  Fix up the change (roll 42abbb61bede)
>    (hg histedit --continue to resume)
>
>  fix up
> @@ -255,7 +263,7 @@
>    $ hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
>    merging e
>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
> -  Fix up the change (pick 7b4e2f4b7bcd)
> +  Fix up the change (pick 7f3755409b00)
>    (hg histedit --continue to resume)
>
>  just continue this time
> @@ -264,34 +272,34 @@
>    (no more unresolved files)
>    continue: hg histedit --continue
>    $ hg histedit --continue 2>&1 | fixbundle
> -  7b4e2f4b7bcd: skipping changeset (no changes)
> +  7f3755409b00: skipping changeset (no changes)
>
>  log after edit
>    $ hg log --graph
> -  @  changeset:   5:e7c4f5d4eb75
> +  @  changeset:   5:b538bcb461be
>    |  tag:         tip
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>    |  summary:     f
>    |
> -  o  changeset:   4:803d1bb561fc
> +  o  changeset:   4:317e37cb6d66
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:04 1970 +0000
>    |  summary:     d
>    |
> -  o  changeset:   3:65a9a84f33fd
> +  o  changeset:   3:092e4ce14829
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>    |  summary:     c
>    |
> -  o  changeset:   2:da6535b52e45
> +  o  changeset:   2:40ccdd8beb95
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>    |  summary:     b
>    |
> -  o  changeset:   1:c1f09da44841
> +  o  changeset:   1:cd997a145b29
>    |  user:        test
> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>    |  summary:     a
>    |
>    o  changeset:   0:1715188a53c7
> @@ -316,16 +324,16 @@
>  description is taken from rollup target commit
>
>    $ hg log --debug --rev 4
> -  changeset:   4:803d1bb561fceac3129ec778db9da249a3106fc3
> +  changeset:   4:317e37cb6d66c1c84628c00e5bf4c8c292831951
>    phase:       draft
> -  parent:      3:65a9a84f33fdeb1ad5679b3941ec885d2b24027b
> +  parent:      3:092e4ce14829f4974399ce4316d59f64ef0b6725
>    parent:      -1:0000000000000000000000000000000000000000
>    manifest:    4:b068a323d969f22af1296ec6a5ea9384cef437ac
>    user:        test
> -  date:        Thu Jan 01 00:00:00 1970 +0000
> +  date:        Thu Jan 01 00:00:04 1970 +0000
>    files:       d e
>    extra:       branch=default
> -  extra:       histedit_source=00f1c53839651fa5c76d423606811ea5455a79d0,39522b764e3d26103f08bd1fa2ccd3e3d7dbcf4e
> +  extra:       histedit_source=ae78f4c9d74ffa4b6cb5045001c303fe9204e890,42abbb61bede6f4366fa1e74a664343e5d558a70
>    description:
>    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
> @@ -20,52 +20,60 @@
>
>  Simple folding
>  --------------------
> +  $ addwithdate ()
> +  > {
> +  >     echo $1 > $1
> +  >     hg add $1
> +  >     hg ci -m $1 -d "$2 0"
> +  > }
> +
>    $ initrepo ()
>    > {
>    >     hg init r
>    >     cd r
> -  >     for x in a b c d e f ; do
> -  >         echo $x > $x
> -  >         hg add $x
> -  >         hg ci -m $x
> -  >     done
> +  >     addwithdate a 1
> +  >     addwithdate b 2
> +  >     addwithdate c 3
> +  >     addwithdate d 4
> +  >     addwithdate e 5
> +  >     addwithdate f 6
>    > }
>
>    $ initrepo
>
>  log before edit
>    $ hg logt --graph
> -  @  5:652413bf663e f
> +  @  5:178e35e0ce73 f
>    |
> -  o  4:e860deea161a e
> +  o  4:1ddb6c90f2ee e
>    |
> -  o  3:055a42cdd887 d
> +  o  3:532247a8969b d
>    |
> -  o  2:177f92b77385 c
> +  o  2:ff2c9fa2018b c
>    |
> -  o  1:d2ae7f538514 b
> +  o  1:97d72e5f12c7 b
>    |
> -  o  0:cb9a9f314b8b a
> +  o  0:8580ff50825a a
>
>
> -  $ hg histedit 177f92b77385 --commands - 2>&1 <<EOF | fixbundle
> -  > pick e860deea161a e
> -  > pick 652413bf663e f
> -  > fold 177f92b77385 c
> -  > pick 055a42cdd887 d
> +  $ hg histedit ff2c9fa2018b --commands - 2>&1 <<EOF | fixbundle
> +  > pick 1ddb6c90f2ee e
> +  > pick 178e35e0ce73 f
> +  > fold ff2c9fa2018b c
> +  > pick 532247a8969b d
>    > EOF
>
>  log after edit
>    $ hg logt --graph
> -  @  4:9c277da72c9b d
> +  @  4:c4d7f3def76d d
>    |
> -  o  3:6de59d13424a f
> +  o  3:575228819b7e f
>    |
> -  o  2:ee283cb5f2d5 e
> +  o  2:505a591af19e e
>    |
> -  o  1:d2ae7f538514 b
> +  o  1:97d72e5f12c7 b
>    |
> -  o  0:cb9a9f314b8b a
> +  o  0:8580ff50825a a
>
>
>  post-fold manifest
> @@ -78,19 +86,19 @@
>    f
>
>
> -check histedit_source
> +check histedit_source, including that it uses the later date, from the first changeset
>
>    $ hg log --debug --rev 3
> -  changeset:   3:6de59d13424a8a13acd3e975514aed29dd0d9b2d
> +  changeset:   3:575228819b7e6ed69e8c0a6a383ee59a80db7358
>    phase:       draft
> -  parent:      2:ee283cb5f2d5955443f23a27b697a04339e9a39a
> +  parent:      2:505a591af19eed18f560af827b9e03d2076773dc
>    parent:      -1:0000000000000000000000000000000000000000
>    manifest:    3:81eede616954057198ead0b2c73b41d1f392829a
>    user:        test
> -  date:        Thu Jan 01 00:00:00 1970 +0000
> +  date:        Thu Jan 01 00:00:06 1970 +0000
>    files+:      c f
>    extra:       branch=default
> -  extra:       histedit_source=a4f7421b80f79fcc59fff01bcbf4a53d127dd6d3,177f92b773850b59254aa5e923436f921b55483b
> +  extra:       histedit_source=7cad1d7030207872dfd1c3a7cb430f24f2884086,ff2c9fa2018b15fa74b33363bda9527323e2a99f
>    description:
>    f
>    ***
> @@ -98,43 +106,43 @@
>
>
>
> -rollup will fold without preserving the folded commit's message
> +rollup will fold without preserving the folded commit's message or date
>
>    $ OLDHGEDITOR=$HGEDITOR
>    $ HGEDITOR=false
> -  $ hg histedit d2ae7f538514 --commands - 2>&1 <<EOF | fixbundle
> -  > pick d2ae7f538514 b
> -  > roll ee283cb5f2d5 e
> -  > pick 6de59d13424a f
> -  > pick 9c277da72c9b d
> +  $ hg histedit 97d72e5f12c7 --commands - 2>&1 <<EOF | fixbundle
> +  > pick 97d72e5f12c7 b
> +  > roll 505a591af19e e
> +  > pick 575228819b7e f
> +  > pick c4d7f3def76d d
>    > EOF
>
>    $ HGEDITOR=$OLDHGEDITOR
>
>  log after edit
>    $ hg logt --graph
> -  @  3:c4a9eb7989fc d
> +  @  3:bab801520cec d
>    |
> -  o  2:8e03a72b6f83 f
> +  o  2:58c8f2bfc151 f
>    |
> -  o  1:391ee782c689 b
> +  o  1:5d939c56c72e b
>    |
> -  o  0:cb9a9f314b8b a
> +  o  0:8580ff50825a a
>
>
>  description is taken from rollup target commit
>
>    $ hg log --debug --rev 1
> -  changeset:   1:391ee782c68930be438ccf4c6a403daedbfbffa5
> +  changeset:   1:5d939c56c72e77e29f5167696218e2131a40f5cf
>    phase:       draft
> -  parent:      0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
> +  parent:      0:8580ff50825a50c8f716709acdf8de0deddcd6ab
>    parent:      -1:0000000000000000000000000000000000000000
>    manifest:    1:b5e112a3a8354e269b1524729f0918662d847c38
>    user:        test
> -  date:        Thu Jan 01 00:00:00 1970 +0000
> +  date:        Thu Jan 01 00:00:02 1970 +0000
>    files+:      b e
>    extra:       branch=default
> -  extra:       histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a
> +  extra:       histedit_source=97d72e5f12c7e84f85064aa72e5a297142c36ed9,505a591af19eed18f560af827b9e03d2076773dc
>    description:
>    b
>
> @@ -163,13 +171,13 @@
>    > EOF
>
>    $ rm -f .hg/last-message.txt
> -  $ hg status --rev '8e03a72b6f83^1::c4a9eb7989fc'
> +  $ hg status --rev '58c8f2bfc151^1::bab801520cec'
>    A c
>    A d
>    A f
> -  $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF
> -  > pick 8e03a72b6f83 f
> -  > fold c4a9eb7989fc d
> +  $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 58c8f2bfc151 --commands - 2>&1 <<EOF
> +  > pick 58c8f2bfc151 f
> +  > fold bab801520cec d
>    > EOF
>    allow non-folding commit
>    ==== before editing
> @@ -209,37 +217,37 @@
>    $ cd ..
>    $ rm -r r
>
> -folding preserves initial author
> ---------------------------------
> +folding preserves initial author but uses later date
> +----------------------------------------------------
>
>    $ initrepo
>
> -  $ hg ci --user "someone else" --amend --quiet
> +  $ hg ci -d '7 0' --user "someone else" --amend --quiet
>
>  tip before edit
>    $ hg log --rev .
> -  changeset:   5:a00ad806cb55
> +  changeset:   5:10c36dd37515
>    tag:         tip
>    user:        someone else
> -  date:        Thu Jan 01 00:00:00 1970 +0000
> +  date:        Thu Jan 01 00:00:07 1970 +0000
>    summary:     f
>
>
>    $ hg --config progress.debug=1 --debug \
> -  > histedit e860deea161a --commands - 2>&1 <<EOF | \
> +  > histedit 1ddb6c90f2ee --commands - 2>&1 <<EOF | \
>    > egrep 'editing|unresolved'
> -  > pick e860deea161a e
> -  > fold a00ad806cb55 f
> +  > pick 1ddb6c90f2ee e
> +  > fold 10c36dd37515 f
>    > EOF
> -  editing: pick e860deea161a 4 e 1/2 changes (50.00%)
> -  editing: fold a00ad806cb55 5 f 2/2 changes (100.00%)
> +  editing: pick 1ddb6c90f2ee 4 e 1/2 changes (50.00%)
> +  editing: fold 10c36dd37515 5 f 2/2 changes (100.00%)
>
> -tip after edit
> +tip after edit, which should use the later date, from the second changeset
>    $ hg log --rev .
> -  changeset:   4:698d4e8040a1
> +  changeset:   4:e4f3ec5d0b40
>    tag:         tip
>    user:        test
> -  date:        Thu Jan 01 00:00:00 1970 +0000
> +  date:        Thu Jan 01 00:00:07 1970 +0000
>    summary:     e
>
>
> diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
> --- a/tests/test-histedit-obsolete.t
> +++ b/tests/test-histedit-obsolete.t
> @@ -136,7 +136,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>    $ hg histedit 1 --commands - --verbose <<EOF | grep histedit
>    > pick 177f92b77385 2 c
> diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
> --- a/tests/test-histedit-outgoing.t
> +++ b/tests/test-histedit-outgoing.t
> @@ -54,7 +54,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>    $ cd ..
>
> @@ -88,7 +88,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>    $ cd ..
>
> @@ -114,7 +114,7 @@
>    #  p, pick = use commit
>    #  d, drop = remove commit from history
>    #  f, fold = use commit, but combine it with the one above
> -  #  r, roll = like fold, but discard this commit's description
> +  #  r, roll = like fold, but discard this commit's description and date
>    #
>
>  test to check number of roots in outgoing revisions
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Feb. 20, 2017, 1:39 a.m.
> On Feb 19, 2017, at 8:23 PM, Augie Fackler <raf@durin42.com> wrote:
> 
> On Sun, Feb 19, 2017 at 02:51:46PM +1100, Ben Schmidt wrote:
>> # HG changeset patch
>> # User Ben Schmidt <insightfuls@users.noreply.github.com>
>> # Date 1487413828 -39600
>> #      Sat Feb 18 21:30:28 2017 +1100
>> # Node ID 4037ff1c9713d73b21ddc182580eacacba254ea7
>> # Parent  1f51b4658f21bbb797e922d155c1046eddccf91d
>> histedit: improve documentation and behaviour of dates (issue4820)
>> 
>> This clarifies in the histedit documentation that the 'edit' action preserves
>> the date and that the 'fold' action uses the later date. The documentation was
>> previously silent on this issue which left users in doubt.
> 
> Wow, that's a great fix.

I’m excited enough about this that I’ve done the split, see:

https://hg.durin42.com/hg-wip/log?rev=only%28histedit%29

With your permission, I’d like to just take that first patch (the documentation fix), and then we can discuss the behavior change to `roll` on the list as a followup. Sound good?
Ben Schmidt - Feb. 20, 2017, 4:38 a.m.
On 20/02/2017 12:39 pm, Augie Fackler wrote:
>> On Feb 19, 2017, at 8:23 PM, Augie Fackler <raf@durin42.com> wrote:
>> On Sun, Feb 19, 2017 at 02:51:46PM +1100, Ben Schmidt wrote:
>>> # HG changeset patch
>>> # User Ben Schmidt <insightfuls@users.noreply.github.com>
>>> # Date 1487413828 -39600
>>> #      Sat Feb 18 21:30:28 2017 +1100
>>> # Node ID 4037ff1c9713d73b21ddc182580eacacba254ea7
>>> # Parent  1f51b4658f21bbb797e922d155c1046eddccf91d
>>> histedit: improve documentation and behaviour of dates (issue4820)
>>>
>>> This clarifies in the histedit documentation that the 'edit' action preserves
>>> the date and that the 'fold' action uses the later date. The documentation was
>>> previously silent on this issue which left users in doubt.
>>
>> Wow, that's a great fix.
>
> I’m excited enough about this that I’ve done the split, see:
>
> https://hg.durin42.com/hg-wip/log?rev=only%28histedit%29
>
> With your permission, I’d like to just take that first patch (the documentation fix), and then we can discuss the behavior change to `roll` on the list as a followup. Sound good?

Yes, sorry I didn't split it. I did actually think of it, but about an
hour after I emailed the patch off.

Your split looks pretty good except for the commit messages. It's really
the alteration of the rollup behaviour that addresses issue4820, and of
course the description of that part of the change belongs with that
commit, but it's currently at the bottom of the commit for the doc
change.

But yes, feel free to go ahead and land that part, and we can continue
discussion of the other part.

Smiles,

Ben
timeless - Feb. 20, 2017, 5 a.m.
Fwiw, recently someone identified that if's are roughly as expensive
as method calls.

I /think/ that means it'd be better for:
+        if self.firstdate():
+            commitopts['date'] = ctx.date()
+        else:
+            commitopts['date'] = max(ctx.date(), oldctx.date())

to be managed as:

def date(self, ctx, oldctx):
   return ctx.date()

def date(self, ctx, oldctx):
    return max(ctx.date(), oldctx.date())
Augie Fackler - Feb. 20, 2017, 5:06 a.m.
> On Feb 20, 2017, at 12:00 AM, timeless <timeless@gmail.com> wrote:
> 
> Fwiw, recently someone identified that if's are roughly as expensive
> as method calls.
> 
> I /think/ that means it'd be better for:
> +        if self.firstdate():
> +            commitopts['date'] = ctx.date()
> +        else:
> +            commitopts['date'] = max(ctx.date(), oldctx.date())
> 
> to be managed as:
> 
> def date(self, ctx, oldctx):
>   return ctx.date()
> 
> def date(self, ctx, oldctx):
>    return max(ctx.date(), oldctx.date())

Maybe. I’d do whatever’s architecturally more readable without concern for performance here, since it’s histedit and we’ll be doing this computation ~once a commit. The overhead of an extra function call is minor compared to the disk IO that implies.

AF

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Ben Schmidt - Feb. 20, 2017, 5:17 a.m.
>> It also adjusts and documents the new behaviour of 'roll'. It now fits nicely
>> with the behaviour of 'commit --amend' and the 'edit' action, by discarding the
>> date as well as the commit message of the second commit. Previously it used the
>> later date, like 'fold', but this often wasn't desirable, for example, in the
>> common use case of using 'roll' to add forgotten changes to a changeset
>> (because 'hg add' was previously forgotten or not all changes were identified
>> while using 'hg record').
>
> This...could stand to be its own patch (generally any time a commit
> message contains the word "also" that's a sign you've really got two patches).
>
> I'm also not sure I'm sold: why shouldn't roll advance the date?

I originally added another action, 'amnd' for 'amend', but then
modifying 'roll' seemed equally appropriate, and with the benefit of not
adding another action. For some back-story, see:

https://bz.mercurial-scm.org/show_bug.cgi?id=4820

There was some brief discussion on this list a year ago:

https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083475.html
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083477.html
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083488.html
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083489.html

I recognise there are probably use cases for the current 'roll'
behaviour as well. What I'm primarily interested in is solving the
problems raised in the bug, so if we can do that another way, such as
adding a new action, that will satisfy me just fine.

Smiles,

Ben



>> diff --git a/hgext/histedit.py b/hgext/histedit.py
>> --- a/hgext/histedit.py
>> +++ b/hgext/histedit.py
>> @@ -36,7 +36,7 @@
>>   #  p, pick = use commit
>>   #  e, edit = use commit, but stop for amending
>>   #  f, fold = use commit, but combine it with the one above
>> - #  r, roll = like fold, but discard this commit's description
>> + #  r, roll = like fold, but discard this commit's description and date
>>   #  d, drop = remove commit from history
>>   #  m, mess = edit commit message without changing commit content
>>   #
>> @@ -58,7 +58,7 @@
>>   #  p, pick = use commit
>>   #  e, edit = use commit, but stop for amending
>>   #  f, fold = use commit, but combine it with the one above
>> - #  r, roll = like fold, but discard this commit's description
>> + #  r, roll = like fold, but discard this commit's description and date
>>   #  d, drop = remove commit from history
>>   #  m, mess = edit commit message without changing commit content
>>   #
>> @@ -71,11 +71,11 @@
>>   ***
>>   Add delta
>>
>> -Edit the commit message to your liking, then close the editor. For
>> -this example, let's assume that the commit message was changed to
>> -``Add beta and delta.`` After histedit has run and had a chance to
>> -remove any old or temporary revisions it needed, the history looks
>> -like this::
>> +Edit the commit message to your liking, then close the editor. The date used
>> +for the commit will be the later of the two commits' dates. For this example,
>> +let's assume that the commit message was changed to ``Add beta and delta.``
>> +After histedit has run and had a chance to remove any old or temporary
>> +revisions it needed, the history looks like this::
>>
>>   @  2[tip]   989b4d060121   2009-04-27 18:04 -0500   durin42
>>   |    Add beta and delta.
>> @@ -97,9 +97,10 @@
>>  allowing you to edit files freely, or even use ``hg record`` to commit
>>  some changes as a separate commit. When you're done, any remaining
>>  uncommitted changes will be committed as well. When done, run ``hg
>> -histedit --continue`` to finish this step. You'll be prompted for a
>> -new commit message, but the default commit message will be the
>> -original message for the ``edit`` ed revision.
>> +histedit --continue`` to finish this step. If there are uncommitted
>> +changes, you'll be prompted for a new commit message, but the default
>> +commit message will be the original message for the ``edit`` ed
>> +revision, and the date of the original commit will be preserved.
>>
>>  The ``message`` operation will give you a chance to revise a commit
>>  message without changing the contents. It's a shortcut for doing
>> @@ -724,6 +725,15 @@
>>          """
>>          return True
>>
>> +    def firstdate(self):
>> +        """Returns true if the rule should preserve the date of the first
>> +        change.
>> +
>> +        This exists mainly so that 'rollup' rules can be a subclass of
>> +        'fold'.
>> +        """
>> +        return False
>> +
>>      def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges):
>>          parent = ctx.parents()[0].node()
>>          repo.ui.pushbuffer()
>> @@ -742,7 +752,10 @@
>>                  [oldctx.description()]) + '\n'
>>          commitopts['message'] = newmessage
>>          # date
>> -        commitopts['date'] = max(ctx.date(), oldctx.date())
>> +        if self.firstdate():
>> +            commitopts['date'] = ctx.date()
>> +        else:
>> +            commitopts['date'] = max(ctx.date(), oldctx.date())
>>          extra = ctx.extra().copy()
>>          # histedit_source
>>          # note: ctx is likely a temporary commit but that the best we can do
>> @@ -809,7 +822,7 @@
>>          return True
>>
>>  @action(["roll", "r"],
>> -        _("like fold, but discard this commit's description"))
>> +        _("like fold, but discard this commit's description and date"))
>>  class rollup(fold):
>>      def mergedescs(self):
>>          return False
>> @@ -817,6 +830,9 @@
>>      def skipprompt(self):
>>          return True
>>
>> +    def firstdate(self):
>> +        return True
>> +
>>  @action(["drop", "d"],
>>          _('remove commit from history'))
>>  class drop(histeditaction):
>> @@ -884,11 +900,11 @@
>>
>>      - `mess` to reword the changeset commit message
>>
>> -    - `fold` to combine it with the preceding changeset
>> +    - `fold` to combine it with the preceding changeset (using the later date)
>>
>> -    - `roll` like fold, but discarding this commit's description
>> +    - `roll` like fold, but discarding this commit's description and date
>>
>> -    - `edit` to edit this changeset
>> +    - `edit` to edit this changeset (preserving date)
>>
>>      There are a number of ways to select the root changeset:
>>
>> diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
>> --- a/tests/test-histedit-arguments.t
>> +++ b/tests/test-histedit-arguments.t
>> @@ -72,7 +72,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>
>>  Run on a revision not ancestors of the current working directory.
>> @@ -308,7 +308,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>
>>  Test --continue with --keep
>> @@ -544,7 +544,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>
>>    $ cd ..
>> diff --git a/tests/test-histedit-bookmark-motion.t b/tests/test-histedit-bookmark-motion.t
>> --- a/tests/test-histedit-bookmark-motion.t
>> +++ b/tests/test-histedit-bookmark-motion.t
>> @@ -78,7 +78,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>    $ hg histedit 1 --commands - --verbose << EOF | grep histedit
>>    > pick 177f92b77385 2 c
>> @@ -141,7 +141,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>    $ hg histedit 1 --commands - --verbose << EOF | grep histedit
>>    > pick b346ab9a313d 1 c
>> diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t
>> --- a/tests/test-histedit-commute.t
>> +++ b/tests/test-histedit-commute.t
>> @@ -72,7 +72,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>
>>  edit the history
>> @@ -350,7 +350,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>
>>  should also work if a commit message is missing
>> diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
>> --- a/tests/test-histedit-edit.t
>> +++ b/tests/test-histedit-edit.t
>> @@ -478,5 +478,5 @@
>>    #  p, fold = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>> 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
>> @@ -5,6 +5,12 @@
>>    > histedit=
>>    > EOF
>>
>> +  $ modwithdate ()
>> +  > {
>> +  >     echo $1 > $1
>> +  >     hg ci -m $1 -d "$2 0"
>> +  > }
>> +
>>    $ initrepo ()
>>    > {
>>    >     hg init $1
>> @@ -14,12 +20,14 @@
>>    >         hg add $x
>>    >     done
>>    >     hg ci -m 'Initial commit'
>> -  >     for x in a b c d e f ; do
>> -  >         echo $x > $x
>> -  >         hg ci -m $x
>> -  >     done
>> +  >     modwithdate a 1
>> +  >     modwithdate b 2
>> +  >     modwithdate c 3
>> +  >     modwithdate d 4
>> +  >     modwithdate e 5
>> +  >     modwithdate f 6
>>    >     echo 'I can haz no commute' > e
>> -  >     hg ci -m 'does not commute with e'
>> +  >     hg ci -m 'does not commute with e' -d '7 0'
>>    >     cd ..
>>    > }
>>
>> @@ -34,48 +42,48 @@
>>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
>>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
>>    $ cat $EDITED
>> -  pick 65a9a84f33fd 3 c
>> -  pick 00f1c5383965 4 d
>> -  fold 39522b764e3d 7 does not commute with e
>> -  pick 7b4e2f4b7bcd 5 e
>> -  pick 500cac37a696 6 f
>> +  pick 092e4ce14829 3 c
>> +  pick ae78f4c9d74f 4 d
>> +  fold 42abbb61bede 7 does not commute with e
>> +  pick 7f3755409b00 5 e
>> +  pick dd184f2faeb0 6 f
>>
>>  log before edit
>>    $ hg log --graph
>> -  @  changeset:   7:39522b764e3d
>> +  @  changeset:   7:42abbb61bede
>>    |  tag:         tip
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:07 1970 +0000
>>    |  summary:     does not commute with e
>>    |
>> -  o  changeset:   6:500cac37a696
>> +  o  changeset:   6:dd184f2faeb0
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>>    |  summary:     f
>>    |
>> -  o  changeset:   5:7b4e2f4b7bcd
>> +  o  changeset:   5:7f3755409b00
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:05 1970 +0000
>>    |  summary:     e
>>    |
>> -  o  changeset:   4:00f1c5383965
>> +  o  changeset:   4:ae78f4c9d74f
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:04 1970 +0000
>>    |  summary:     d
>>    |
>> -  o  changeset:   3:65a9a84f33fd
>> +  o  changeset:   3:092e4ce14829
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>>    |  summary:     c
>>    |
>> -  o  changeset:   2:da6535b52e45
>> +  o  changeset:   2:40ccdd8beb95
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>>    |  summary:     b
>>    |
>> -  o  changeset:   1:c1f09da44841
>> +  o  changeset:   1:cd997a145b29
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>>    |  summary:     a
>>    |
>>    o  changeset:   0:1715188a53c7
>> @@ -89,7 +97,7 @@
>>    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>    merging e
>>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
>> -  Fix up the change (fold 39522b764e3d)
>> +  Fix up the change (fold 42abbb61bede)
>>    (hg histedit --continue to resume)
>>
>>  fix up
>> @@ -113,7 +121,7 @@
>>    HG: changed e
>>    merging e
>>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
>> -  Fix up the change (pick 7b4e2f4b7bcd)
>> +  Fix up the change (pick 7f3755409b00)
>>    (hg histedit --continue to resume)
>>
>>  just continue this time
>> @@ -124,34 +132,34 @@
>>    continue: hg histedit --continue
>>    $ hg diff
>>    $ hg histedit --continue 2>&1 | fixbundle
>> -  7b4e2f4b7bcd: skipping changeset (no changes)
>> +  7f3755409b00: skipping changeset (no changes)
>>
>>  log after edit
>>    $ hg log --graph
>> -  @  changeset:   5:d9cf42e54966
>> +  @  changeset:   5:1300355b1a54
>>    |  tag:         tip
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>>    |  summary:     f
>>    |
>> -  o  changeset:   4:10486af2e984
>> +  o  changeset:   4:e2ac33269083
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:07 1970 +0000
>>    |  summary:     d
>>    |
>> -  o  changeset:   3:65a9a84f33fd
>> +  o  changeset:   3:092e4ce14829
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>>    |  summary:     c
>>    |
>> -  o  changeset:   2:da6535b52e45
>> +  o  changeset:   2:40ccdd8beb95
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>>    |  summary:     b
>>    |
>> -  o  changeset:   1:c1f09da44841
>> +  o  changeset:   1:cd997a145b29
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>>    |  summary:     a
>>    |
>>    o  changeset:   0:1715188a53c7
>> @@ -175,7 +183,7 @@
>>
>>    $ cd ..
>>
>> -Repeat test using "roll", not "fold". "roll" folds in changes but drops message
>> +Repeat test using "roll", not "fold". "roll" folds in changes but drops message and date
>>
>>    $ initrepo r2
>>    $ cd r2
>> @@ -189,48 +197,48 @@
>>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
>>    $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
>>    $ cat $EDITED
>> -  pick 65a9a84f33fd 3 c
>> -  pick 00f1c5383965 4 d
>> -  roll 39522b764e3d 7 does not commute with e
>> -  pick 7b4e2f4b7bcd 5 e
>> -  pick 500cac37a696 6 f
>> +  pick 092e4ce14829 3 c
>> +  pick ae78f4c9d74f 4 d
>> +  roll 42abbb61bede 7 does not commute with e
>> +  pick 7f3755409b00 5 e
>> +  pick dd184f2faeb0 6 f
>>
>>  log before edit
>>    $ hg log --graph
>> -  @  changeset:   7:39522b764e3d
>> +  @  changeset:   7:42abbb61bede
>>    |  tag:         tip
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:07 1970 +0000
>>    |  summary:     does not commute with e
>>    |
>> -  o  changeset:   6:500cac37a696
>> +  o  changeset:   6:dd184f2faeb0
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>>    |  summary:     f
>>    |
>> -  o  changeset:   5:7b4e2f4b7bcd
>> +  o  changeset:   5:7f3755409b00
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:05 1970 +0000
>>    |  summary:     e
>>    |
>> -  o  changeset:   4:00f1c5383965
>> +  o  changeset:   4:ae78f4c9d74f
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:04 1970 +0000
>>    |  summary:     d
>>    |
>> -  o  changeset:   3:65a9a84f33fd
>> +  o  changeset:   3:092e4ce14829
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>>    |  summary:     c
>>    |
>> -  o  changeset:   2:da6535b52e45
>> +  o  changeset:   2:40ccdd8beb95
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>>    |  summary:     b
>>    |
>> -  o  changeset:   1:c1f09da44841
>> +  o  changeset:   1:cd997a145b29
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>>    |  summary:     a
>>    |
>>    o  changeset:   0:1715188a53c7
>> @@ -244,7 +252,7 @@
>>    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>    merging e
>>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
>> -  Fix up the change (roll 39522b764e3d)
>> +  Fix up the change (roll 42abbb61bede)
>>    (hg histedit --continue to resume)
>>
>>  fix up
>> @@ -255,7 +263,7 @@
>>    $ hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
>>    merging e
>>    warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
>> -  Fix up the change (pick 7b4e2f4b7bcd)
>> +  Fix up the change (pick 7f3755409b00)
>>    (hg histedit --continue to resume)
>>
>>  just continue this time
>> @@ -264,34 +272,34 @@
>>    (no more unresolved files)
>>    continue: hg histedit --continue
>>    $ hg histedit --continue 2>&1 | fixbundle
>> -  7b4e2f4b7bcd: skipping changeset (no changes)
>> +  7f3755409b00: skipping changeset (no changes)
>>
>>  log after edit
>>    $ hg log --graph
>> -  @  changeset:   5:e7c4f5d4eb75
>> +  @  changeset:   5:b538bcb461be
>>    |  tag:         tip
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:06 1970 +0000
>>    |  summary:     f
>>    |
>> -  o  changeset:   4:803d1bb561fc
>> +  o  changeset:   4:317e37cb6d66
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:04 1970 +0000
>>    |  summary:     d
>>    |
>> -  o  changeset:   3:65a9a84f33fd
>> +  o  changeset:   3:092e4ce14829
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:03 1970 +0000
>>    |  summary:     c
>>    |
>> -  o  changeset:   2:da6535b52e45
>> +  o  changeset:   2:40ccdd8beb95
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:02 1970 +0000
>>    |  summary:     b
>>    |
>> -  o  changeset:   1:c1f09da44841
>> +  o  changeset:   1:cd997a145b29
>>    |  user:        test
>> -  |  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  |  date:        Thu Jan 01 00:00:01 1970 +0000
>>    |  summary:     a
>>    |
>>    o  changeset:   0:1715188a53c7
>> @@ -316,16 +324,16 @@
>>  description is taken from rollup target commit
>>
>>    $ hg log --debug --rev 4
>> -  changeset:   4:803d1bb561fceac3129ec778db9da249a3106fc3
>> +  changeset:   4:317e37cb6d66c1c84628c00e5bf4c8c292831951
>>    phase:       draft
>> -  parent:      3:65a9a84f33fdeb1ad5679b3941ec885d2b24027b
>> +  parent:      3:092e4ce14829f4974399ce4316d59f64ef0b6725
>>    parent:      -1:0000000000000000000000000000000000000000
>>    manifest:    4:b068a323d969f22af1296ec6a5ea9384cef437ac
>>    user:        test
>> -  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  date:        Thu Jan 01 00:00:04 1970 +0000
>>    files:       d e
>>    extra:       branch=default
>> -  extra:       histedit_source=00f1c53839651fa5c76d423606811ea5455a79d0,39522b764e3d26103f08bd1fa2ccd3e3d7dbcf4e
>> +  extra:       histedit_source=ae78f4c9d74ffa4b6cb5045001c303fe9204e890,42abbb61bede6f4366fa1e74a664343e5d558a70
>>    description:
>>    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
>> @@ -20,52 +20,60 @@
>>
>>  Simple folding
>>  --------------------
>> +  $ addwithdate ()
>> +  > {
>> +  >     echo $1 > $1
>> +  >     hg add $1
>> +  >     hg ci -m $1 -d "$2 0"
>> +  > }
>> +
>>    $ initrepo ()
>>    > {
>>    >     hg init r
>>    >     cd r
>> -  >     for x in a b c d e f ; do
>> -  >         echo $x > $x
>> -  >         hg add $x
>> -  >         hg ci -m $x
>> -  >     done
>> +  >     addwithdate a 1
>> +  >     addwithdate b 2
>> +  >     addwithdate c 3
>> +  >     addwithdate d 4
>> +  >     addwithdate e 5
>> +  >     addwithdate f 6
>>    > }
>>
>>    $ initrepo
>>
>>  log before edit
>>    $ hg logt --graph
>> -  @  5:652413bf663e f
>> +  @  5:178e35e0ce73 f
>>    |
>> -  o  4:e860deea161a e
>> +  o  4:1ddb6c90f2ee e
>>    |
>> -  o  3:055a42cdd887 d
>> +  o  3:532247a8969b d
>>    |
>> -  o  2:177f92b77385 c
>> +  o  2:ff2c9fa2018b c
>>    |
>> -  o  1:d2ae7f538514 b
>> +  o  1:97d72e5f12c7 b
>>    |
>> -  o  0:cb9a9f314b8b a
>> +  o  0:8580ff50825a a
>>
>>
>> -  $ hg histedit 177f92b77385 --commands - 2>&1 <<EOF | fixbundle
>> -  > pick e860deea161a e
>> -  > pick 652413bf663e f
>> -  > fold 177f92b77385 c
>> -  > pick 055a42cdd887 d
>> +  $ hg histedit ff2c9fa2018b --commands - 2>&1 <<EOF | fixbundle
>> +  > pick 1ddb6c90f2ee e
>> +  > pick 178e35e0ce73 f
>> +  > fold ff2c9fa2018b c
>> +  > pick 532247a8969b d
>>    > EOF
>>
>>  log after edit
>>    $ hg logt --graph
>> -  @  4:9c277da72c9b d
>> +  @  4:c4d7f3def76d d
>>    |
>> -  o  3:6de59d13424a f
>> +  o  3:575228819b7e f
>>    |
>> -  o  2:ee283cb5f2d5 e
>> +  o  2:505a591af19e e
>>    |
>> -  o  1:d2ae7f538514 b
>> +  o  1:97d72e5f12c7 b
>>    |
>> -  o  0:cb9a9f314b8b a
>> +  o  0:8580ff50825a a
>>
>>
>>  post-fold manifest
>> @@ -78,19 +86,19 @@
>>    f
>>
>>
>> -check histedit_source
>> +check histedit_source, including that it uses the later date, from the first changeset
>>
>>    $ hg log --debug --rev 3
>> -  changeset:   3:6de59d13424a8a13acd3e975514aed29dd0d9b2d
>> +  changeset:   3:575228819b7e6ed69e8c0a6a383ee59a80db7358
>>    phase:       draft
>> -  parent:      2:ee283cb5f2d5955443f23a27b697a04339e9a39a
>> +  parent:      2:505a591af19eed18f560af827b9e03d2076773dc
>>    parent:      -1:0000000000000000000000000000000000000000
>>    manifest:    3:81eede616954057198ead0b2c73b41d1f392829a
>>    user:        test
>> -  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  date:        Thu Jan 01 00:00:06 1970 +0000
>>    files+:      c f
>>    extra:       branch=default
>> -  extra:       histedit_source=a4f7421b80f79fcc59fff01bcbf4a53d127dd6d3,177f92b773850b59254aa5e923436f921b55483b
>> +  extra:       histedit_source=7cad1d7030207872dfd1c3a7cb430f24f2884086,ff2c9fa2018b15fa74b33363bda9527323e2a99f
>>    description:
>>    f
>>    ***
>> @@ -98,43 +106,43 @@
>>
>>
>>
>> -rollup will fold without preserving the folded commit's message
>> +rollup will fold without preserving the folded commit's message or date
>>
>>    $ OLDHGEDITOR=$HGEDITOR
>>    $ HGEDITOR=false
>> -  $ hg histedit d2ae7f538514 --commands - 2>&1 <<EOF | fixbundle
>> -  > pick d2ae7f538514 b
>> -  > roll ee283cb5f2d5 e
>> -  > pick 6de59d13424a f
>> -  > pick 9c277da72c9b d
>> +  $ hg histedit 97d72e5f12c7 --commands - 2>&1 <<EOF | fixbundle
>> +  > pick 97d72e5f12c7 b
>> +  > roll 505a591af19e e
>> +  > pick 575228819b7e f
>> +  > pick c4d7f3def76d d
>>    > EOF
>>
>>    $ HGEDITOR=$OLDHGEDITOR
>>
>>  log after edit
>>    $ hg logt --graph
>> -  @  3:c4a9eb7989fc d
>> +  @  3:bab801520cec d
>>    |
>> -  o  2:8e03a72b6f83 f
>> +  o  2:58c8f2bfc151 f
>>    |
>> -  o  1:391ee782c689 b
>> +  o  1:5d939c56c72e b
>>    |
>> -  o  0:cb9a9f314b8b a
>> +  o  0:8580ff50825a a
>>
>>
>>  description is taken from rollup target commit
>>
>>    $ hg log --debug --rev 1
>> -  changeset:   1:391ee782c68930be438ccf4c6a403daedbfbffa5
>> +  changeset:   1:5d939c56c72e77e29f5167696218e2131a40f5cf
>>    phase:       draft
>> -  parent:      0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
>> +  parent:      0:8580ff50825a50c8f716709acdf8de0deddcd6ab
>>    parent:      -1:0000000000000000000000000000000000000000
>>    manifest:    1:b5e112a3a8354e269b1524729f0918662d847c38
>>    user:        test
>> -  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  date:        Thu Jan 01 00:00:02 1970 +0000
>>    files+:      b e
>>    extra:       branch=default
>> -  extra:       histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a
>> +  extra:       histedit_source=97d72e5f12c7e84f85064aa72e5a297142c36ed9,505a591af19eed18f560af827b9e03d2076773dc
>>    description:
>>    b
>>
>> @@ -163,13 +171,13 @@
>>    > EOF
>>
>>    $ rm -f .hg/last-message.txt
>> -  $ hg status --rev '8e03a72b6f83^1::c4a9eb7989fc'
>> +  $ hg status --rev '58c8f2bfc151^1::bab801520cec'
>>    A c
>>    A d
>>    A f
>> -  $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF
>> -  > pick 8e03a72b6f83 f
>> -  > fold c4a9eb7989fc d
>> +  $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 58c8f2bfc151 --commands - 2>&1 <<EOF
>> +  > pick 58c8f2bfc151 f
>> +  > fold bab801520cec d
>>    > EOF
>>    allow non-folding commit
>>    ==== before editing
>> @@ -209,37 +217,37 @@
>>    $ cd ..
>>    $ rm -r r
>>
>> -folding preserves initial author
>> ---------------------------------
>> +folding preserves initial author but uses later date
>> +----------------------------------------------------
>>
>>    $ initrepo
>>
>> -  $ hg ci --user "someone else" --amend --quiet
>> +  $ hg ci -d '7 0' --user "someone else" --amend --quiet
>>
>>  tip before edit
>>    $ hg log --rev .
>> -  changeset:   5:a00ad806cb55
>> +  changeset:   5:10c36dd37515
>>    tag:         tip
>>    user:        someone else
>> -  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  date:        Thu Jan 01 00:00:07 1970 +0000
>>    summary:     f
>>
>>
>>    $ hg --config progress.debug=1 --debug \
>> -  > histedit e860deea161a --commands - 2>&1 <<EOF | \
>> +  > histedit 1ddb6c90f2ee --commands - 2>&1 <<EOF | \
>>    > egrep 'editing|unresolved'
>> -  > pick e860deea161a e
>> -  > fold a00ad806cb55 f
>> +  > pick 1ddb6c90f2ee e
>> +  > fold 10c36dd37515 f
>>    > EOF
>> -  editing: pick e860deea161a 4 e 1/2 changes (50.00%)
>> -  editing: fold a00ad806cb55 5 f 2/2 changes (100.00%)
>> +  editing: pick 1ddb6c90f2ee 4 e 1/2 changes (50.00%)
>> +  editing: fold 10c36dd37515 5 f 2/2 changes (100.00%)
>>
>> -tip after edit
>> +tip after edit, which should use the later date, from the second changeset
>>    $ hg log --rev .
>> -  changeset:   4:698d4e8040a1
>> +  changeset:   4:e4f3ec5d0b40
>>    tag:         tip
>>    user:        test
>> -  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  date:        Thu Jan 01 00:00:07 1970 +0000
>>    summary:     e
>>
>>
>> diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
>> --- a/tests/test-histedit-obsolete.t
>> +++ b/tests/test-histedit-obsolete.t
>> @@ -136,7 +136,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>    $ hg histedit 1 --commands - --verbose <<EOF | grep histedit
>>    > pick 177f92b77385 2 c
>> diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
>> --- a/tests/test-histedit-outgoing.t
>> +++ b/tests/test-histedit-outgoing.t
>> @@ -54,7 +54,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>    $ cd ..
>>
>> @@ -88,7 +88,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>    $ cd ..
>>
>> @@ -114,7 +114,7 @@
>>    #  p, pick = use commit
>>    #  d, drop = remove commit from history
>>    #  f, fold = use commit, but combine it with the one above
>> -  #  r, roll = like fold, but discard this commit's description
>> +  #  r, roll = like fold, but discard this commit's description and date
>>    #
>>
>>  test to check number of roots in outgoing revisions
Augie Fackler - Feb. 21, 2017, 9:25 p.m.
On Mon, Feb 20, 2017 at 12:17 AM, Ben Schmidt
<dev@insightful-schmidt.info> wrote:
> I recognise there are probably use cases for the current 'roll'
> behaviour as well. What I'm primarily interested in is solving the
> problems raised in the bug, so if we can do that another way, such as
> adding a new action, that will satisfy me just fine.

Having thought about this more over the balance of my weekend, it
makes sense that this is consistent with 'hg amend' from evolve, and
it feels right enough. Since it wasn't previously documented we'll go
ahead and do this, and if anyone complains we can revert it between
now and 4.2 being final.

I'll push both patches with the commit message adjustments you pointed
out upthread. Many thanks!
Ben Schmidt - Feb. 21, 2017, 9:32 p.m.
On 22/02/2017 8:25 am, Augie Fackler wrote:
> Having thought about this more over the balance of my weekend, it
> makes sense that this is consistent with 'hg amend' from evolve, and
> it feels right enough. Since it wasn't previously documented we'll go
> ahead and do this, and if anyone complains we can revert it between
> now and 4.2 being final.

I agree entirely!

> I'll push both patches with the commit message adjustments you pointed
> out upthread. Many thanks!

Thank you greatly, also.

Ben

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -36,7 +36,7 @@ 
  #  p, pick = use commit
  #  e, edit = use commit, but stop for amending
  #  f, fold = use commit, but combine it with the one above
- #  r, roll = like fold, but discard this commit's description
+ #  r, roll = like fold, but discard this commit's description and date
  #  d, drop = remove commit from history
  #  m, mess = edit commit message without changing commit content
  #
@@ -58,7 +58,7 @@ 
  #  p, pick = use commit
  #  e, edit = use commit, but stop for amending
  #  f, fold = use commit, but combine it with the one above
- #  r, roll = like fold, but discard this commit's description
+ #  r, roll = like fold, but discard this commit's description and date
  #  d, drop = remove commit from history
  #  m, mess = edit commit message without changing commit content
  #
@@ -71,11 +71,11 @@ 
  ***
  Add delta
 
-Edit the commit message to your liking, then close the editor. For
-this example, let's assume that the commit message was changed to
-``Add beta and delta.`` After histedit has run and had a chance to
-remove any old or temporary revisions it needed, the history looks
-like this::
+Edit the commit message to your liking, then close the editor. The date used
+for the commit will be the later of the two commits' dates. For this example,
+let's assume that the commit message was changed to ``Add beta and delta.``
+After histedit has run and had a chance to remove any old or temporary
+revisions it needed, the history looks like this::
 
  @  2[tip]   989b4d060121   2009-04-27 18:04 -0500   durin42
  |    Add beta and delta.
@@ -97,9 +97,10 @@ 
 allowing you to edit files freely, or even use ``hg record`` to commit
 some changes as a separate commit. When you're done, any remaining
 uncommitted changes will be committed as well. When done, run ``hg
-histedit --continue`` to finish this step. You'll be prompted for a
-new commit message, but the default commit message will be the
-original message for the ``edit`` ed revision.
+histedit --continue`` to finish this step. If there are uncommitted
+changes, you'll be prompted for a new commit message, but the default
+commit message will be the original message for the ``edit`` ed
+revision, and the date of the original commit will be preserved.
 
 The ``message`` operation will give you a chance to revise a commit
 message without changing the contents. It's a shortcut for doing
@@ -724,6 +725,15 @@ 
         """
         return True
 
+    def firstdate(self):
+        """Returns true if the rule should preserve the date of the first
+        change.
+
+        This exists mainly so that 'rollup' rules can be a subclass of
+        'fold'.
+        """
+        return False
+
     def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges):
         parent = ctx.parents()[0].node()
         repo.ui.pushbuffer()
@@ -742,7 +752,10 @@ 
                 [oldctx.description()]) + '\n'
         commitopts['message'] = newmessage
         # date
-        commitopts['date'] = max(ctx.date(), oldctx.date())
+        if self.firstdate():
+            commitopts['date'] = ctx.date()
+        else:
+            commitopts['date'] = max(ctx.date(), oldctx.date())
         extra = ctx.extra().copy()
         # histedit_source
         # note: ctx is likely a temporary commit but that the best we can do
@@ -809,7 +822,7 @@ 
         return True
 
 @action(["roll", "r"],
-        _("like fold, but discard this commit's description"))
+        _("like fold, but discard this commit's description and date"))
 class rollup(fold):
     def mergedescs(self):
         return False
@@ -817,6 +830,9 @@ 
     def skipprompt(self):
         return True
 
+    def firstdate(self):
+        return True
+
 @action(["drop", "d"],
         _('remove commit from history'))
 class drop(histeditaction):
@@ -884,11 +900,11 @@ 
 
     - `mess` to reword the changeset commit message
 
-    - `fold` to combine it with the preceding changeset
+    - `fold` to combine it with the preceding changeset (using the later date)
 
-    - `roll` like fold, but discarding this commit's description
+    - `roll` like fold, but discarding this commit's description and date
 
-    - `edit` to edit this changeset
+    - `edit` to edit this changeset (preserving date)
 
     There are a number of ways to select the root changeset:
 
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -72,7 +72,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
 
 Run on a revision not ancestors of the current working directory.
@@ -308,7 +308,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
 
 Test --continue with --keep
@@ -544,7 +544,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
 
   $ cd ..
diff --git a/tests/test-histedit-bookmark-motion.t b/tests/test-histedit-bookmark-motion.t
--- a/tests/test-histedit-bookmark-motion.t
+++ b/tests/test-histedit-bookmark-motion.t
@@ -78,7 +78,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
   $ hg histedit 1 --commands - --verbose << EOF | grep histedit
   > pick 177f92b77385 2 c
@@ -141,7 +141,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
   $ hg histedit 1 --commands - --verbose << EOF | grep histedit
   > pick b346ab9a313d 1 c
diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t
--- a/tests/test-histedit-commute.t
+++ b/tests/test-histedit-commute.t
@@ -72,7 +72,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
 
 edit the history
@@ -350,7 +350,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
 
 should also work if a commit message is missing
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -478,5 +478,5 @@ 
   #  p, fold = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
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
@@ -5,6 +5,12 @@ 
   > histedit=
   > EOF
 
+  $ modwithdate ()
+  > {
+  >     echo $1 > $1
+  >     hg ci -m $1 -d "$2 0"
+  > }
+
   $ initrepo ()
   > {
   >     hg init $1
@@ -14,12 +20,14 @@ 
   >         hg add $x
   >     done
   >     hg ci -m 'Initial commit'
-  >     for x in a b c d e f ; do
-  >         echo $x > $x
-  >         hg ci -m $x
-  >     done
+  >     modwithdate a 1
+  >     modwithdate b 2
+  >     modwithdate c 3
+  >     modwithdate d 4
+  >     modwithdate e 5
+  >     modwithdate f 6
   >     echo 'I can haz no commute' > e
-  >     hg ci -m 'does not commute with e'
+  >     hg ci -m 'does not commute with e' -d '7 0'
   >     cd ..
   > }
 
@@ -34,48 +42,48 @@ 
   $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
   $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
   $ cat $EDITED
-  pick 65a9a84f33fd 3 c
-  pick 00f1c5383965 4 d
-  fold 39522b764e3d 7 does not commute with e
-  pick 7b4e2f4b7bcd 5 e
-  pick 500cac37a696 6 f
+  pick 092e4ce14829 3 c
+  pick ae78f4c9d74f 4 d
+  fold 42abbb61bede 7 does not commute with e
+  pick 7f3755409b00 5 e
+  pick dd184f2faeb0 6 f
 
 log before edit
   $ hg log --graph
-  @  changeset:   7:39522b764e3d
+  @  changeset:   7:42abbb61bede
   |  tag:         tip
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:07 1970 +0000
   |  summary:     does not commute with e
   |
-  o  changeset:   6:500cac37a696
+  o  changeset:   6:dd184f2faeb0
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:06 1970 +0000
   |  summary:     f
   |
-  o  changeset:   5:7b4e2f4b7bcd
+  o  changeset:   5:7f3755409b00
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:05 1970 +0000
   |  summary:     e
   |
-  o  changeset:   4:00f1c5383965
+  o  changeset:   4:ae78f4c9d74f
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:04 1970 +0000
   |  summary:     d
   |
-  o  changeset:   3:65a9a84f33fd
+  o  changeset:   3:092e4ce14829
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:03 1970 +0000
   |  summary:     c
   |
-  o  changeset:   2:da6535b52e45
+  o  changeset:   2:40ccdd8beb95
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     b
   |
-  o  changeset:   1:c1f09da44841
+  o  changeset:   1:cd997a145b29
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     a
   |
   o  changeset:   0:1715188a53c7
@@ -89,7 +97,7 @@ 
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
-  Fix up the change (fold 39522b764e3d)
+  Fix up the change (fold 42abbb61bede)
   (hg histedit --continue to resume)
 
 fix up
@@ -113,7 +121,7 @@ 
   HG: changed e
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
-  Fix up the change (pick 7b4e2f4b7bcd)
+  Fix up the change (pick 7f3755409b00)
   (hg histedit --continue to resume)
 
 just continue this time
@@ -124,34 +132,34 @@ 
   continue: hg histedit --continue
   $ hg diff
   $ hg histedit --continue 2>&1 | fixbundle
-  7b4e2f4b7bcd: skipping changeset (no changes)
+  7f3755409b00: skipping changeset (no changes)
 
 log after edit
   $ hg log --graph
-  @  changeset:   5:d9cf42e54966
+  @  changeset:   5:1300355b1a54
   |  tag:         tip
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:06 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:10486af2e984
+  o  changeset:   4:e2ac33269083
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:07 1970 +0000
   |  summary:     d
   |
-  o  changeset:   3:65a9a84f33fd
+  o  changeset:   3:092e4ce14829
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:03 1970 +0000
   |  summary:     c
   |
-  o  changeset:   2:da6535b52e45
+  o  changeset:   2:40ccdd8beb95
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     b
   |
-  o  changeset:   1:c1f09da44841
+  o  changeset:   1:cd997a145b29
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     a
   |
   o  changeset:   0:1715188a53c7
@@ -175,7 +183,7 @@ 
 
   $ cd ..
 
-Repeat test using "roll", not "fold". "roll" folds in changes but drops message
+Repeat test using "roll", not "fold". "roll" folds in changes but drops message and date
 
   $ initrepo r2
   $ cd r2
@@ -189,48 +197,48 @@ 
   $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
   $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
   $ cat $EDITED
-  pick 65a9a84f33fd 3 c
-  pick 00f1c5383965 4 d
-  roll 39522b764e3d 7 does not commute with e
-  pick 7b4e2f4b7bcd 5 e
-  pick 500cac37a696 6 f
+  pick 092e4ce14829 3 c
+  pick ae78f4c9d74f 4 d
+  roll 42abbb61bede 7 does not commute with e
+  pick 7f3755409b00 5 e
+  pick dd184f2faeb0 6 f
 
 log before edit
   $ hg log --graph
-  @  changeset:   7:39522b764e3d
+  @  changeset:   7:42abbb61bede
   |  tag:         tip
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:07 1970 +0000
   |  summary:     does not commute with e
   |
-  o  changeset:   6:500cac37a696
+  o  changeset:   6:dd184f2faeb0
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:06 1970 +0000
   |  summary:     f
   |
-  o  changeset:   5:7b4e2f4b7bcd
+  o  changeset:   5:7f3755409b00
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:05 1970 +0000
   |  summary:     e
   |
-  o  changeset:   4:00f1c5383965
+  o  changeset:   4:ae78f4c9d74f
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:04 1970 +0000
   |  summary:     d
   |
-  o  changeset:   3:65a9a84f33fd
+  o  changeset:   3:092e4ce14829
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:03 1970 +0000
   |  summary:     c
   |
-  o  changeset:   2:da6535b52e45
+  o  changeset:   2:40ccdd8beb95
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     b
   |
-  o  changeset:   1:c1f09da44841
+  o  changeset:   1:cd997a145b29
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     a
   |
   o  changeset:   0:1715188a53c7
@@ -244,7 +252,7 @@ 
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
-  Fix up the change (roll 39522b764e3d)
+  Fix up the change (roll 42abbb61bede)
   (hg histedit --continue to resume)
 
 fix up
@@ -255,7 +263,7 @@ 
   $ hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
-  Fix up the change (pick 7b4e2f4b7bcd)
+  Fix up the change (pick 7f3755409b00)
   (hg histedit --continue to resume)
 
 just continue this time
@@ -264,34 +272,34 @@ 
   (no more unresolved files)
   continue: hg histedit --continue
   $ hg histedit --continue 2>&1 | fixbundle
-  7b4e2f4b7bcd: skipping changeset (no changes)
+  7f3755409b00: skipping changeset (no changes)
 
 log after edit
   $ hg log --graph
-  @  changeset:   5:e7c4f5d4eb75
+  @  changeset:   5:b538bcb461be
   |  tag:         tip
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:06 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:803d1bb561fc
+  o  changeset:   4:317e37cb6d66
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:04 1970 +0000
   |  summary:     d
   |
-  o  changeset:   3:65a9a84f33fd
+  o  changeset:   3:092e4ce14829
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:03 1970 +0000
   |  summary:     c
   |
-  o  changeset:   2:da6535b52e45
+  o  changeset:   2:40ccdd8beb95
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     b
   |
-  o  changeset:   1:c1f09da44841
+  o  changeset:   1:cd997a145b29
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     a
   |
   o  changeset:   0:1715188a53c7
@@ -316,16 +324,16 @@ 
 description is taken from rollup target commit
 
   $ hg log --debug --rev 4
-  changeset:   4:803d1bb561fceac3129ec778db9da249a3106fc3
+  changeset:   4:317e37cb6d66c1c84628c00e5bf4c8c292831951
   phase:       draft
-  parent:      3:65a9a84f33fdeb1ad5679b3941ec885d2b24027b
+  parent:      3:092e4ce14829f4974399ce4316d59f64ef0b6725
   parent:      -1:0000000000000000000000000000000000000000
   manifest:    4:b068a323d969f22af1296ec6a5ea9384cef437ac
   user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
+  date:        Thu Jan 01 00:00:04 1970 +0000
   files:       d e
   extra:       branch=default
-  extra:       histedit_source=00f1c53839651fa5c76d423606811ea5455a79d0,39522b764e3d26103f08bd1fa2ccd3e3d7dbcf4e
+  extra:       histedit_source=ae78f4c9d74ffa4b6cb5045001c303fe9204e890,42abbb61bede6f4366fa1e74a664343e5d558a70
   description:
   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
@@ -20,52 +20,60 @@ 
 
 Simple folding
 --------------------
+  $ addwithdate ()
+  > {
+  >     echo $1 > $1
+  >     hg add $1
+  >     hg ci -m $1 -d "$2 0"
+  > }
+
   $ initrepo ()
   > {
   >     hg init r
   >     cd r
-  >     for x in a b c d e f ; do
-  >         echo $x > $x
-  >         hg add $x
-  >         hg ci -m $x
-  >     done
+  >     addwithdate a 1
+  >     addwithdate b 2
+  >     addwithdate c 3
+  >     addwithdate d 4
+  >     addwithdate e 5
+  >     addwithdate f 6
   > }
 
   $ initrepo
 
 log before edit
   $ hg logt --graph
-  @  5:652413bf663e f
+  @  5:178e35e0ce73 f
   |
-  o  4:e860deea161a e
+  o  4:1ddb6c90f2ee e
   |
-  o  3:055a42cdd887 d
+  o  3:532247a8969b d
   |
-  o  2:177f92b77385 c
+  o  2:ff2c9fa2018b c
   |
-  o  1:d2ae7f538514 b
+  o  1:97d72e5f12c7 b
   |
-  o  0:cb9a9f314b8b a
+  o  0:8580ff50825a a
   
 
-  $ hg histedit 177f92b77385 --commands - 2>&1 <<EOF | fixbundle
-  > pick e860deea161a e
-  > pick 652413bf663e f
-  > fold 177f92b77385 c
-  > pick 055a42cdd887 d
+  $ hg histedit ff2c9fa2018b --commands - 2>&1 <<EOF | fixbundle
+  > pick 1ddb6c90f2ee e
+  > pick 178e35e0ce73 f
+  > fold ff2c9fa2018b c
+  > pick 532247a8969b d
   > EOF
 
 log after edit
   $ hg logt --graph
-  @  4:9c277da72c9b d
+  @  4:c4d7f3def76d d
   |
-  o  3:6de59d13424a f
+  o  3:575228819b7e f
   |
-  o  2:ee283cb5f2d5 e
+  o  2:505a591af19e e
   |
-  o  1:d2ae7f538514 b
+  o  1:97d72e5f12c7 b
   |
-  o  0:cb9a9f314b8b a
+  o  0:8580ff50825a a
   
 
 post-fold manifest
@@ -78,19 +86,19 @@ 
   f
 
 
-check histedit_source
+check histedit_source, including that it uses the later date, from the first changeset
 
   $ hg log --debug --rev 3
-  changeset:   3:6de59d13424a8a13acd3e975514aed29dd0d9b2d
+  changeset:   3:575228819b7e6ed69e8c0a6a383ee59a80db7358
   phase:       draft
-  parent:      2:ee283cb5f2d5955443f23a27b697a04339e9a39a
+  parent:      2:505a591af19eed18f560af827b9e03d2076773dc
   parent:      -1:0000000000000000000000000000000000000000
   manifest:    3:81eede616954057198ead0b2c73b41d1f392829a
   user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
+  date:        Thu Jan 01 00:00:06 1970 +0000
   files+:      c f
   extra:       branch=default
-  extra:       histedit_source=a4f7421b80f79fcc59fff01bcbf4a53d127dd6d3,177f92b773850b59254aa5e923436f921b55483b
+  extra:       histedit_source=7cad1d7030207872dfd1c3a7cb430f24f2884086,ff2c9fa2018b15fa74b33363bda9527323e2a99f
   description:
   f
   ***
@@ -98,43 +106,43 @@ 
   
   
 
-rollup will fold without preserving the folded commit's message
+rollup will fold without preserving the folded commit's message or date
 
   $ OLDHGEDITOR=$HGEDITOR
   $ HGEDITOR=false
-  $ hg histedit d2ae7f538514 --commands - 2>&1 <<EOF | fixbundle
-  > pick d2ae7f538514 b
-  > roll ee283cb5f2d5 e
-  > pick 6de59d13424a f
-  > pick 9c277da72c9b d
+  $ hg histedit 97d72e5f12c7 --commands - 2>&1 <<EOF | fixbundle
+  > pick 97d72e5f12c7 b
+  > roll 505a591af19e e
+  > pick 575228819b7e f
+  > pick c4d7f3def76d d
   > EOF
 
   $ HGEDITOR=$OLDHGEDITOR
 
 log after edit
   $ hg logt --graph
-  @  3:c4a9eb7989fc d
+  @  3:bab801520cec d
   |
-  o  2:8e03a72b6f83 f
+  o  2:58c8f2bfc151 f
   |
-  o  1:391ee782c689 b
+  o  1:5d939c56c72e b
   |
-  o  0:cb9a9f314b8b a
+  o  0:8580ff50825a a
   
 
 description is taken from rollup target commit
 
   $ hg log --debug --rev 1
-  changeset:   1:391ee782c68930be438ccf4c6a403daedbfbffa5
+  changeset:   1:5d939c56c72e77e29f5167696218e2131a40f5cf
   phase:       draft
-  parent:      0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
+  parent:      0:8580ff50825a50c8f716709acdf8de0deddcd6ab
   parent:      -1:0000000000000000000000000000000000000000
   manifest:    1:b5e112a3a8354e269b1524729f0918662d847c38
   user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
+  date:        Thu Jan 01 00:00:02 1970 +0000
   files+:      b e
   extra:       branch=default
-  extra:       histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a
+  extra:       histedit_source=97d72e5f12c7e84f85064aa72e5a297142c36ed9,505a591af19eed18f560af827b9e03d2076773dc
   description:
   b
   
@@ -163,13 +171,13 @@ 
   > EOF
 
   $ rm -f .hg/last-message.txt
-  $ hg status --rev '8e03a72b6f83^1::c4a9eb7989fc'
+  $ hg status --rev '58c8f2bfc151^1::bab801520cec'
   A c
   A d
   A f
-  $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF
-  > pick 8e03a72b6f83 f
-  > fold c4a9eb7989fc d
+  $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 58c8f2bfc151 --commands - 2>&1 <<EOF
+  > pick 58c8f2bfc151 f
+  > fold bab801520cec d
   > EOF
   allow non-folding commit
   ==== before editing
@@ -209,37 +217,37 @@ 
   $ cd ..
   $ rm -r r
 
-folding preserves initial author
---------------------------------
+folding preserves initial author but uses later date
+----------------------------------------------------
 
   $ initrepo
 
-  $ hg ci --user "someone else" --amend --quiet
+  $ hg ci -d '7 0' --user "someone else" --amend --quiet
 
 tip before edit
   $ hg log --rev .
-  changeset:   5:a00ad806cb55
+  changeset:   5:10c36dd37515
   tag:         tip
   user:        someone else
-  date:        Thu Jan 01 00:00:00 1970 +0000
+  date:        Thu Jan 01 00:00:07 1970 +0000
   summary:     f
   
 
   $ hg --config progress.debug=1 --debug \
-  > histedit e860deea161a --commands - 2>&1 <<EOF | \
+  > histedit 1ddb6c90f2ee --commands - 2>&1 <<EOF | \
   > egrep 'editing|unresolved'
-  > pick e860deea161a e
-  > fold a00ad806cb55 f
+  > pick 1ddb6c90f2ee e
+  > fold 10c36dd37515 f
   > EOF
-  editing: pick e860deea161a 4 e 1/2 changes (50.00%)
-  editing: fold a00ad806cb55 5 f 2/2 changes (100.00%)
+  editing: pick 1ddb6c90f2ee 4 e 1/2 changes (50.00%)
+  editing: fold 10c36dd37515 5 f 2/2 changes (100.00%)
 
-tip after edit
+tip after edit, which should use the later date, from the second changeset
   $ hg log --rev .
-  changeset:   4:698d4e8040a1
+  changeset:   4:e4f3ec5d0b40
   tag:         tip
   user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
+  date:        Thu Jan 01 00:00:07 1970 +0000
   summary:     e
   
 
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -136,7 +136,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
   $ hg histedit 1 --commands - --verbose <<EOF | grep histedit
   > pick 177f92b77385 2 c
diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
--- a/tests/test-histedit-outgoing.t
+++ b/tests/test-histedit-outgoing.t
@@ -54,7 +54,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
   $ cd ..
 
@@ -88,7 +88,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
   $ cd ..
 
@@ -114,7 +114,7 @@ 
   #  p, pick = use commit
   #  d, drop = remove commit from history
   #  f, fold = use commit, but combine it with the one above
-  #  r, roll = like fold, but discard this commit's description
+  #  r, roll = like fold, but discard this commit's description and date
   #
 
 test to check number of roots in outgoing revisions