Patchwork D5483: amend:added config option to update time to current in hg amend(issue5828)

login
register
mail settings
Submitter phabricator
Date Jan. 3, 2019, 12:49 p.m.
Message ID <709973043396c0492e58343cb80b25f4@localhost.localdomain>
Download mbox | patch
Permalink /patch/37440/
State Not Applicable
Headers show

Comments

phabricator - Jan. 3, 2019, 12:49 p.m.
taapas1128 updated this revision to Diff 12998.
taapas1128 retitled this revision from "amend:added  rewrite.updatetimestamp config option(issue5828)" to "amend:added config option to update time to current in hg amend(issue5828)".

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5483?vs=12987&id=12998

REVISION DETAIL
  https://phab.mercurial-scm.org/D5483

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/configitems.py
  mercurial/help/config.txt
  tests/test-amend.t

CHANGE DETAILS




To: taapas1128, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel

Patch

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -365,3 +365,35 @@ 
   $ 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
+
+  $ hg amend --config rewrite.update-timestamp=True
+  $ hg log --limit 1
+  changeset:   1:1789402a4e99
+  tag:         tip
+  user:        test
+  date:        Thu Jan 03 12:33:27 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:1b7ddb503d92
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:01:00 1998 +0000
+  summary:     b
+  
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/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``
 -----------
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/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',
 )
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/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,