# HG changeset patch # User Yuya Nishihara # Date 1546864986 -32400 # Node ID 126101284e0485baa0e5c8ea845d5ca225ca2821 # Parent cffa8e0ba77a5ceb7965a4083269b3b39c2cf0a7 amend: add -D/--currentdate option It bumps the date field even if there's no other change. The help text is copied from commands.graft(). Unlike graft, --date with --currentdate is disallowed, which I think is saner behavior. diff -r cffa8e0ba77a -r 126101284e04 hgext/amend.py --- a/hgext/amend.py Mon Jan 07 21:39:35 2019 +0900 +++ b/hgext/amend.py Mon Jan 07 21:43:06 2019 +0900 @@ -36,6 +36,8 @@ ('e', 'edit', None, _('invoke editor on commit messages')), ('i', 'interactive', None, _('use interactive mode')), ('n', 'note', '', _('store a note on the amend')), + ('D', 'currentdate', False, + _('record the current date as commit date')), ] + cmdutil.walkopts + cmdutil.commitopts + cmdutil.commitopts2, _('[OPTION]... [FILE]...'), helpcategory=command.CATEGORY_COMMITTING, diff -r cffa8e0ba77a -r 126101284e04 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Mon Jan 07 21:39:35 2019 +0900 +++ b/mercurial/cmdutil.py Mon Jan 07 21:43:06 2019 +0900 @@ -2443,8 +2443,13 @@ 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')) if opts.get('date'): date = dateutil.parsedate(opts.get('date')) + elif opts.get('currentdate'): + date = dateutil.makedate() elif ui.configbool('rewrite', 'update-timestamp'): date = dateutil.makedate() datemaydiffer = True diff -r cffa8e0ba77a -r 126101284e04 tests/test-amend.t --- a/tests/test-amend.t Mon Jan 07 21:39:35 2019 +0900 +++ b/tests/test-amend.t Mon Jan 07 21:43:06 2019 +0900 @@ -438,3 +438,25 @@ user: foobar date: Thu Jan 01 00:01:00 1998 +0000 summary: commit 1 + +Unlike rewrite.update-timestamp, -D/--currentdate always updates the timestamp + + $ hg amend -D + $ hg log --limit 1 + user: foobar + date: Thu Jan 01 00:00:04 1970 +0000 + summary: commit 1 + + $ hg amend -D --config rewrite.update-timestamp=True + $ hg log --limit 1 + user: foobar + date: Thu Jan 01 00:00:05 1970 +0000 + summary: commit 1 + +Bad combination of date options: + + $ hg amend -D --date '0 0' + abort: --date and --currentdate are mutually exclusive + [255] + + $ cd ..