[PATCH] histedit: improve documentation and behaviour of dates (issue4820)

Ben Schmidt dev at insightful-schmidt.info
Mon Feb 20 00:17:26 EST 2017


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


More information about the Mercurial-devel mailing list