diff --git a/hgext3rd/tweakdefaults.py b/hgext3rd/tweakdefaults.py --- a/hgext3rd/tweakdefaults.py +++ b/hgext3rd/tweakdefaults.py @@ -23,10 +23,12 @@ # default destination used by pull --rebase / --update defaultdest = '' - # whether to keep the commit date when doing amend / graft / rebase + # whether to keep the commit date when doing amend / graft / rebase / + # histedit amendkeepdate = False graftkeepdate = False rebasekeepdate = False + histeditkeepdate = False # whether to allow or disable some commands allowbranch = True @@ -181,6 +183,11 @@ wrapcommand(fbamendmodule.cmdtable, 'amend', opawareamend) except KeyError: pass + try: + histeditmodule = extensions.find('histedit') + wrapfunction(histeditmodule, 'commitfuncfor', histeditcommitfuncfor) + except KeyError: + pass # wrapped createmarkers knows how to write operation-aware # metadata (e.g. 'amend', 'rebase' and so forth) @@ -741,6 +748,14 @@ opts["date"] = currentdate() return orig(ui, repo, *pats, **opts) +def histeditcommitfuncfor(orig, repo, src): + origcommitfunc = orig(repo, src) + def commitfunc(**kwargs): + if not repo.ui.configbool('tweakdefaults', 'histeditkeepdate'): + kwargs['date'] = util.makedate(time.time()) + origcommitfunc(**kwargs) + return commitfunc + def log(orig, ui, repo, *pats, **opts): # 'hg log' defaults to -f # All special uses of log (--date, --branch, etc) will also now do follow. diff --git a/tests/test-smartlog-obsolete.t b/tests/test-smartlog-obsolete.t --- a/tests/test-smartlog-obsolete.t +++ b/tests/test-smartlog-obsolete.t @@ -6,6 +6,8 @@ > rebase= > smartlog=$TESTDIR/../hgext3rd/smartlog.py > tweakdefaults=$TESTDIR/../hgext3rd/tweakdefaults.py + > [tweakdefaults] + > histeditkeepdate = true > [experimental] > evolution = createmarkers, allowunstable > allowdivergence = on diff --git a/tests/test-tweakdefaults.t b/tests/test-tweakdefaults.t --- a/tests/test-tweakdefaults.t +++ b/tests/test-tweakdefaults.t @@ -1,8 +1,11 @@ + $ . "$TESTDIR/histedit-helpers.sh" + $ cat >> $HGRCPATH << EOF > [extensions] > tweakdefaults=$TESTDIR/../hgext3rd/tweakdefaults.py > fbamend=$TESTDIR/../hgext3rd/fbamend > rebase= + > histedit= > [experimental] > updatecheck=noconflict > EOF @@ -414,6 +417,36 @@ 0.00 15 0.00 14 +Test histedit date when tweakdefaults.histeditkeepdate is set + $ hg bookmark histedit_test + $ echo test_1 > histedit_1 + $ hg commit -Aqm "commit 1 for histedit" + $ echo test_2 > histedit_2 + $ hg commit -Aqm "commit 2 for histedit" + $ echo test_3 > histedit_3 + $ hg commit -Aqm "commit 3 for histedit" + $ hg histedit 16 --commands - --config tweakdefaults.histeditkeepdate=True 2>&1 < pick 16 + > pick 18 + > pick 17 + > EOF + [1] + $ hg log -l 3 -T "{date} {rev} {desc}\n" + 0.00 18 commit 2 for histedit + 0.00 17 commit 3 for histedit + 0.00 16 commit 1 for histedit + +Test histedit date when tweakdefaults.histeditkeepdate is not set + $ hg histedit 16 --commands - 2>&1 < pick 16 + > pick 18 + > pick 17 + > EOF + [1] + $ hg log -l 2 -T "{rev} {desc}\n" -d "yesterday to today" + 18 commit 3 for histedit + 17 commit 2 for histedit + Test reuse message flag by taking message from previous commit $ cd ../.. $ hg up -q hyphen-book @@ -449,7 +482,7 @@ $ cd $TESTTMP $ hg clone repo clone updating to branch default - 9 files updated, 0 files merged, 0 files removed, 0 files unresolved + 12 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd clone $ hg pull --rebase abort: you must use a bookmark with tracking or manually specify a destination for the rebase