mercurial/cmdutil.py
changeset 42932 e4803231f538
parent 42921 4690902850df
child 42933 7e9997041781
--- a/mercurial/cmdutil.py	Wed Sep 11 15:03:08 2019 -0700
+++ b/mercurial/cmdutil.py	Sat Sep 14 15:13:16 2019 -0400
@@ -184,6 +184,9 @@
 
 def resolvecommitoptions(ui, opts):
     """modify commit options dict to handle related options
+
+    The return value indicates that ``rewrite.update-timestamp`` is the reason
+    the ``date`` option is set.
     """
     if opts.get('date') and opts.get('currentdate'):
         raise error.Abort(_('--date and --currentdate are mutually '
@@ -192,12 +195,21 @@
         raise error.Abort(_('--user and --currentuser are mutually '
                             'exclusive'))
 
-    # N.B. this is extremely similar to setupheaderopts() in mq.py
+    datemaydiffer = False  # date-only change should be ignored?
+
     if opts.get(b'currentdate'):
         opts[b'date'] = b'%d %d' % dateutil.makedate()
+    elif (not opts.get('date')
+          and ui.configbool('rewrite', 'update-timestamp')
+          and opts.get('currentdate') is None):
+        opts[b'date'] = b'%d %d' % dateutil.makedate()
+        datemaydiffer = True
+
     if opts.get(b'currentuser'):
         opts[b'user'] = ui.username()
 
+    return datemaydiffer
+
 def ishunk(x):
     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
     return isinstance(x, hunkclasses)
@@ -2470,22 +2482,13 @@
         # Also update it from the from the wctx
         extra.update(wctx.extra())
 
-        user = opts.get('user') or old.user()
-
-        datemaydiffer = False  # date-only change should be ignored?
-        if opts.get('date') and opts.get('currentdate'):
-            raise error.Abort(_('--date and --currentdate are mutually '
-                                'exclusive'))
+        # date-only change should be ignored?
+        datemaydiffer = resolvecommitoptions(ui, opts)
+
+        date = old.date()
         if opts.get('date'):
             date = dateutil.parsedate(opts.get('date'))
-        elif opts.get('currentdate'):
-            date = dateutil.makedate()
-        elif (ui.configbool('rewrite', 'update-timestamp')
-              and opts.get('currentdate') is None):
-            date = dateutil.makedate()
-            datemaydiffer = True
-        else:
-            date = old.date()
+        user = opts.get('user') or old.user()
 
         if len(old.parents()) > 1:
             # ctx.files() isn't reliable for merges, so fall back to the