Patchwork [2,of,4] amend: refactor commit date handling

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

Comments

Yuya Nishihara - Jan. 7, 2019, 1:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1546864198 -32400
#      Mon Jan 07 21:29:58 2019 +0900
# Node ID 224a7e7feb44b205dcb3900e1a0e003287278640
# Parent  37086867ab18484c093a188851c3847d695c8629
amend: refactor commit date handling

There's no need to parse a date tuple. Just do it for user option.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2441,16 +2441,13 @@  def amend(ui, repo, old, extra, pats, op
         extra.update(wctx.extra())
 
         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)
+
+        if opts.get('date'):
+            date = dateutil.parsedate(opts.get('date'))
+        elif ui.configbool('rewrite', 'update-timestamp'):
+            date = dateutil.makedate()
+        else:
+            date = old.date()
 
         if len(old.parents()) > 1:
             # ctx.files() isn't reliable for merges, so fall back to the