diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -36,7 +36,7 @@ file open in your editor:: # 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 @@ would reorganize the file to look like t # 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 # @@ -725,6 +725,15 @@ class fold(histeditaction): """ 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() @@ -743,7 +752,10 @@ class fold(histeditaction): [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 @@ -810,7 +822,7 @@ class _multifold(fold): 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 @@ -818,6 +830,9 @@ class rollup(fold): def skipprompt(self): return True + def firstdate(self): + return True + @action(["drop", "d"], _('remove commit from history')) class drop(histeditaction): @@ -887,7 +902,7 @@ def histedit(ui, repo, *freeargs, **opts - `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 (preserving date) 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 @@ Run a dummy edit to make sure we get tip # 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 @@ Test that trimming description using mul # 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 @@ Check that 'roll' is selected by default # 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 @@ show the edit commands offered # 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 @@ Verify that revsetalias entries work wit # 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 @@ Attempting to fold a change into a publi # 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 @@ -183,7 +183,7 @@ manifest $ 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 @@ -276,15 +276,15 @@ just continue this time log after edit $ hg log --graph - @ changeset: 5:162978f027fb + @ changeset: 5:b538bcb461be | tag: tip | user: test | date: Thu Jan 01 00:00:06 1970 +0000 | summary: f | - o changeset: 4:74e5e6c6c32f + o changeset: 4:317e37cb6d66 | user: test - | date: Thu Jan 01 00:00:07 1970 +0000 + | date: Thu Jan 01 00:00:04 1970 +0000 | summary: d | o changeset: 3:092e4ce14829 @@ -324,13 +324,13 @@ manifest description is taken from rollup target commit $ hg log --debug --rev 4 - changeset: 4:74e5e6c6c32fa39f0eeed43302fd48633ea5926f + changeset: 4:317e37cb6d66c1c84628c00e5bf4c8c292831951 phase: draft parent: 3:092e4ce14829f4974399ce4316d59f64ef0b6725 parent: -1:0000000000000000000000000000000000000000 manifest: 4:b068a323d969f22af1296ec6a5ea9384cef437ac user: test - date: Thu Jan 01 00:00:07 1970 +0000 + date: Thu Jan 01 00:00:04 1970 +0000 files: d e extra: branch=default extra: histedit_source=ae78f4c9d74ffa4b6cb5045001c303fe9204e890,42abbb61bede6f4366fa1e74a664343e5d558a70 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 @@ -106,7 +106,7 @@ check histedit_source, including that it -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 @@ -121,11 +121,11 @@ rollup will fold without preserving the log after edit $ hg logt --graph - @ 3:fb13f1f49340 d + @ 3:bab801520cec d | - o 2:6d4bc3727566 f + o 2:58c8f2bfc151 f | - o 1:563995ddbe65 b + o 1:5d939c56c72e b | o 0:8580ff50825a a @@ -133,13 +133,13 @@ log after edit description is taken from rollup target commit $ hg log --debug --rev 1 - changeset: 1:563995ddbe650c0e6b0e1c1d75f0a197b61cec50 + changeset: 1:5d939c56c72e77e29f5167696218e2131a40f5cf phase: draft parent: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab parent: -1:0000000000000000000000000000000000000000 manifest: 1:b5e112a3a8354e269b1524729f0918662d847c38 user: test - date: Thu Jan 01 00:00:05 1970 +0000 + date: Thu Jan 01 00:00:02 1970 +0000 files+: b e extra: branch=default extra: histedit_source=97d72e5f12c7e84f85064aa72e5a297142c36ed9,505a591af19eed18f560af827b9e03d2076773dc @@ -171,13 +171,13 @@ check saving last-message.txt > EOF $ rm -f .hg/last-message.txt - $ hg status --rev '6d4bc3727566^1::fb13f1f49340' + $ hg status --rev '58c8f2bfc151^1::bab801520cec' A c A d A f - $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 6d4bc3727566 --commands - 2>&1 < pick 6d4bc3727566 f - > fold fb13f1f49340 d + $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 58c8f2bfc151 --commands - 2>&1 < pick 58c8f2bfc151 f + > fold bab801520cec d > EOF allow non-folding commit ==== before editing 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 @@ Base setup for the rest of the testing # 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 < 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 @@ show the edit commands offered by outgoi # 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 @@ show the error from unrelated repos # 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 @@ test sensitivity to branch in URL: # 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