diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -71,11 +71,11 @@ those revisions together, offering you a *** 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 @@ The ``edit`` operation will drop you bac 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 @@ -884,11 +885,11 @@ def histedit(ui, repo, *freeargs, **opts - `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 - - `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-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 @@ Initial generation of the command files $ 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 @@ edit the history 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 @@ fix up 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 @@ keep the non-commuting change, and thus 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 @@ -189,48 +197,48 @@ Initial generation of the command files $ 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 @@ edit the history 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 @@ fix up $ 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 @@ just continue this time (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:162978f027fb | 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:74e5e6c6c32f | 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 @@ -316,16 +324,16 @@ manifest description is taken from rollup target commit $ hg log --debug --rev 4 - changeset: 4:803d1bb561fceac3129ec778db9da249a3106fc3 + changeset: 4:74e5e6c6c32fa39f0eeed43302fd48633ea5926f 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:07 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 @@ Initialization 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 < pick e860deea161a e - > pick 652413bf663e f - > fold 177f92b77385 c - > pick 055a42cdd887 d + $ hg histedit ff2c9fa2018b --commands - 2>&1 < 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 @@ post-fold manifest 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 *** @@ -102,39 +110,39 @@ rollup will fold without preserving the $ OLDHGEDITOR=$HGEDITOR $ HGEDITOR=false - $ hg histedit d2ae7f538514 --commands - 2>&1 < pick d2ae7f538514 b - > roll ee283cb5f2d5 e - > pick 6de59d13424a f - > pick 9c277da72c9b d + $ hg histedit 97d72e5f12c7 --commands - 2>&1 < 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:fb13f1f49340 d | - o 2:8e03a72b6f83 f + o 2:6d4bc3727566 f | - o 1:391ee782c689 b + o 1:563995ddbe65 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:563995ddbe650c0e6b0e1c1d75f0a197b61cec50 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:05 1970 +0000 files+: b e extra: branch=default - extra: histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a + extra: histedit_source=97d72e5f12c7e84f85064aa72e5a297142c36ed9,505a591af19eed18f560af827b9e03d2076773dc description: b @@ -163,13 +171,13 @@ check saving last-message.txt > EOF $ rm -f .hg/last-message.txt - $ hg status --rev '8e03a72b6f83^1::c4a9eb7989fc' + $ hg status --rev '6d4bc3727566^1::fb13f1f49340' A c A d A f - $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 < pick 8e03a72b6f83 f - > fold c4a9eb7989fc d + $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 6d4bc3727566 --commands - 2>&1 < pick 6d4bc3727566 f + > fold fb13f1f49340 d > EOF allow non-folding commit ==== before editing @@ -209,37 +217,37 @@ check saving last-message.txt $ 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 < histedit 1ddb6c90f2ee --commands - 2>&1 < 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