Index: mercurial/cmdutil.py =================================================================== --- mercurial/cmdutil.py +++ mercurial/cmdutil.py @@ -2545,6 +2545,12 @@ pureextra = extra.copy() extra['amend_source'] = old.hex() + if ui.configbool('rewrite','update-timestamp')==True: + if opts.get('date'): + pass + else: + date = dateutil.makedate() + new = context.memctx(repo, parents=[base.node(), old.p2().node()], text=message, @@ -2559,13 +2565,15 @@ if ((not changes) and newdesc == old.description() and user == old.user() - and date == old.date() and pureextra == old.extra()): # nothing changed. continuing here would create a new node # anyway because of the amend_source noise. # # This not what we expect from amend. - return old.node() + if (date == old.date() or + (ui.configbool('rewrite','update-timestamp')==True and + not opts.get('date'))): + return old.node() commitphase = None if opts.get('secret'): Index: mercurial/configitems.py =================================================================== --- mercurial/configitems.py +++ mercurial/configitems.py @@ -961,6 +961,9 @@ coreconfigitem('push', 'pushvars.server', default=False, ) +coreconfigitem('rewrite', 'update-timestamp', + default=False, +) coreconfigitem('storage', 'new-repo-backend', default='revlogv1', ) Index: mercurial/help/config.txt =================================================================== --- mercurial/help/config.txt +++ mercurial/help/config.txt @@ -1806,6 +1806,13 @@ Alias definitions for revsets. See :hg:`help revsets` for details. +``rewrite`` +----------- + +``update-timestamp`` + If true updates the date and time of the changeset to current.It is only + applicable for hg amend in current version. + ``storage`` ----------- Index: tests/test-amend.t =================================================================== --- tests/test-amend.t +++ tests/test-amend.t @@ -365,3 +365,46 @@ $ hg amend #endif + +When updatetimestamp is False + + $ hg amend --date '1997-1-1 0:1' + $ hg log --limit 1 + changeset: 1:771a1be14d80 + tag: tip + user: test + date: Wed Jan 01 00:01:00 1997 +0000 + summary: b + + +When update-timestamp is True and no other change than the date + + $ hg amend --config rewrite.update-timestamp=True + nothing changed + [1] + $ hg log --limit 1 + changeset: 1:771a1be14d80 + tag: tip + user: test + date: Wed Jan 01 00:01:00 1997 +0000 + summary: b + + +When update-timestamp is True and there is other change than the date + $ hg amend --user foobar --config rewrite.update-timestamp=True + $ hg log --limit 1 + changeset: 1:4d940abebc37 + tag: tip + user: foobar + date: Fri Jan 04 13:12:38 2019 +0000 + summary: b + +When date option is applicable and update-timestamp is True + $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True + $ hg log --limit 1 + changeset: 1:0bebcd7a8323 + tag: tip + user: foobar + date: Thu Jan 01 00:01:00 1998 +0000 + summary: b +