diff mercurial/cmdutil.py @ 41123:79f8f032c706

amend: add config option to update time to current in hg amend (issue5828) The given config option i.e. `rewrite.update-timestamp` updates date to current when //True//. However when only date is to be updated to current with the working directory clean and no other attributes changing then it does not amend as stated in issue 5828. Further when `--date` flag is specified along with the new config option then `--date` is given priority over the config option. Differential Revision: https://phab.mercurial-scm.org/D5491
author Taapas Agrawal <taapas2897@gmail.com>
date Fri, 04 Jan 2019 20:27:17 +0530
parents 69268a13ffa5
children b153a4aa06f8
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun Jan 06 15:25:10 2019 -0500
+++ b/mercurial/cmdutil.py	Fri Jan 04 20:27:17 2019 +0530
@@ -2443,6 +2443,12 @@
         user = opts.get('user') or old.user()
         date = opts.get('date') or old.date()
 
+        if ui.configbool('rewrite', 'update-timestamp'):
+            if opts.get('date'):
+                pass
+            else:
+                date = dateutil.makedate()
+
         # Parse the date to allow comparison between date and old.date()
         date = dateutil.parsedate(date)
 
@@ -2558,13 +2564,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') and
+                 not opts.get('date'))):
+                return old.node()
 
         commitphase = None
         if opts.get('secret'):