--- a/tests/test-amend.t Sun Jan 06 15:25:10 2019 -0500
+++ b/tests/test-amend.t Fri Jan 04 20:27:17 2019 +0530
@@ -365,3 +365,128 @@
$ hg amend
#endif
+==========================================
+Test update-timestamp config option|
+==========================================
+ $ cat >> testmocks.py << EOF
+ > # mock out util.makedate() to supply testable values
+ > import os
+ > from mercurial import pycompat, util
+ > from mercurial.utils import dateutil
+ >
+ > def mockmakedate():
+ > filename = os.path.join(os.environ['TESTTMP'], 'testtime')
+ > try:
+ > with open(filename, 'rb') as timef:
+ > time = float(timef.read()) + 1
+ > except IOError:
+ > time = 0.0
+ > with open(filename, 'wb') as timef:
+ > timef.write(pycompat.bytestr(time))
+ > return (time, 0)
+ >
+ > dateutil.makedate = mockmakedate
+ > EOF
+
+ $ cat >> $HGRCPATH << EOF
+ > [extensions]
+ > amend=
+ > testmocks=`pwd`/testmocks.py
+ > EOF
+
+ $ hg init $TESTTMP/repo5
+ $ cd $TESTTMP/repo5
+ $ echo a>a
+ $ hg ci -Am 'commit 1'
+ adding a
+#if obsstore-on
+
+When updatetimestamp is False
+
+ $ hg amend --date '1997-1-1 0:1'
+ $ hg log --limit 1
+ changeset: 1:036a159be19d
+ tag: tip
+ parent: -1:000000000000
+ user: test
+ date: Wed Jan 01 00:01:00 1997 +0000
+ summary: commit 1
+
+ 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:036a159be19d
+ tag: tip
+ parent: -1:000000000000
+ user: test
+ date: Wed Jan 01 00:01:00 1997 +0000
+ summary: commit 1
+
+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: 2:3ba48b892280
+ tag: tip
+ parent: -1:000000000000
+ user: foobar
+ date: Thu Jan 01 00:00:02 1970 +0000
+ summary: commit 1
+
+
+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: 3:626aee031885
+ tag: tip
+ parent: -1:000000000000
+ user: foobar
+ date: Thu Jan 01 00:01:00 1998 +0000
+ summary: commit 1
+
+#else
+
+When updatetimestamp is False
+
+ $ hg amend --date '1997-1-1 0:1'
+ $ hg log --limit 1
+ changeset: 0:036a159be19d
+ tag: tip
+ user: test
+ date: Wed Jan 01 00:01:00 1997 +0000
+ summary: commit 1
+
+ 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: 0:036a159be19d
+ tag: tip
+ user: test
+ date: Wed Jan 01 00:01:00 1997 +0000
+ summary: commit 1
+
+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: 0:3ba48b892280
+ tag: tip
+ user: foobar
+ date: Thu Jan 01 00:00:02 1970 +0000
+ summary: commit 1
+
+
+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: 0:626aee031885
+ tag: tip
+ user: foobar
+ date: Thu Jan 01 00:01:00 1998 +0000
+ summary: commit 1
+
+#endif