Patchwork [3,of,4] amend: add boolean to ignore date-only change

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 7, 2019, 1:33 p.m.
Message ID <d3181b286250540ecae3.1546867992@mimosa>
Download mbox | patch
Permalink /patch/37529/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 7, 2019, 1:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1546864775 -32400
#      Mon Jan 07 21:39:35 2019 +0900
# Node ID d3181b286250540ecae30e46518c0fbdd43b5bb9
# Parent  224a7e7feb44b205dcb3900e1a0e003287278640
amend: add boolean to ignore date-only change

I want to add -D/--currentdate option, which should behave slightly different
from the update-timestamp option.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2442,10 +2442,12 @@  def amend(ui, repo, old, extra, pats, op
 
         user = opts.get('user') or old.user()
 
+        datemaydiffer = False  # date-only change should be ignored?
         if opts.get('date'):
             date = dateutil.parsedate(opts.get('date'))
         elif ui.configbool('rewrite', 'update-timestamp'):
             date = dateutil.makedate()
+            datemaydiffer = True
         else:
             date = old.date()
 
@@ -2561,15 +2563,13 @@  def amend(ui, repo, old, extra, pats, op
         if ((not changes)
             and newdesc == old.description()
             and user == old.user()
+            and (date == old.date() or datemaydiffer)
             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.
-            if (date == old.date() or
-                (ui.configbool('rewrite', 'update-timestamp') and
-                 not opts.get('date'))):
-                return old.node()
+            return old.node()
 
         commitphase = None
         if opts.get('secret'):