tweakdefaults: make absorb update commit time

Summary: Similar to amend, absorb now defaults to updating the commit time rather than preserving the old commit's time.

Reviewed By: sggutier

Differential Revision: D37820061

fbshipit-source-id: e0471b323fdf2596420e82d31d62fa53729ff244
This commit is contained in:
Muir Manders 2022-07-14 13:41:55 -07:00 committed by Facebook GitHub Bot
parent 6bf4b2d59f
commit aadf195913
2 changed files with 41 additions and 0 deletions

View File

@ -101,6 +101,7 @@ configitem("tweakdefaults", "amendkeepdate", default=False)
configitem("tweakdefaults", "graftkeepdate", default=False)
configitem("tweakdefaults", "histeditkeepdate", default=False)
configitem("tweakdefaults", "rebasekeepdate", default=False)
configitem("tweakdefaults", "absorbkeepdate", default=False)
rebasemsg = _(
"you must use a bookmark with tracking "
@ -193,6 +194,13 @@ def extsetup(ui):
wrapcommand(amendmodule.cmdtable, "amend", amendcmd)
except KeyError:
pass
try:
amendmodule = extensions.find("absorb")
wrapcommand(amendmodule.cmdtable, "absorb", absorbcmd)
except KeyError:
pass
try:
histeditmodule = extensions.find("histedit")
wrapfunction(histeditmodule, "commitfuncfor", histeditcommitfuncfor)
@ -600,6 +608,9 @@ def _checkobsrebasewrapper(orig, repo, ui, *args):
def currentdate():
if util.istest():
# Use a stub value for test stability.
return "1657671627 0"
return "%d %d" % util.makedate(time.time())
@ -609,6 +620,12 @@ def graftcmd(orig, ui, repo, *revs, **opts):
return orig(ui, repo, *revs, **opts)
def absorbcmd(orig, ui, repo, *pats, **opts):
if not opts.get("date") and not ui.configbool("tweakdefaults", "absorbkeepdate"):
opts["date"] = currentdate()
return orig(ui, repo, *pats, **opts)
def amendcmd(orig, ui, repo, *pats, **opts):
if (
not opts.get("date")

View File

@ -0,0 +1,24 @@
#debugruntest-compatible
#chg-compatible
$ enable tweakdefaults
$ enable absorb
Commit date defaults based on tweakdefaults
$ newrepo
$ echo foo > a
$ hg ci -m 'a' -A a
$ echo bar >> a
$ hg absorb -qa
$ hg log -r . -T '{date}\n'
1657671627.00
Don't default when absorbkeepdate is set
$ newrepo
$ echo foo > a
$ hg ci -m 'a' -A a
$ echo bar >> a
$ hg absorb -qa --config tweakdefaults.absorbkeepdate=true
$ hg log -r . -T '{date}\n'
0.00