mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 06:18:07 +03:00
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:
parent
6bf4b2d59f
commit
aadf195913
@ -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")
|
||||
|
24
eden/scm/tests/test-fb-hgext-tweakdefaults-absorb.t
Normal file
24
eden/scm/tests/test-fb-hgext-tweakdefaults-absorb.t
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user