From patchwork Fri Jun 6 01:34:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 3] amend: add -D/--current-date option, just like mq's qrefresh has From: Greg Ward X-Patchwork-Id: 4940 Message-Id: <66468b1c62d53b16bf0f.1402018440@queequeg.renesys.com> To: pierre-yves.david@ens-lyon.org Cc: mercurial-devel@selenic.com Date: Thu, 05 Jun 2014 21:34:00 -0400 # HG changeset patch # User Greg Ward # Date 1402018075 14400 # Thu Jun 05 21:27:55 2014 -0400 # Node ID 66468b1c62d53b16bf0f003c962b90d9314f1d51 # Parent a3332548e7fb4c18815ecaf1b608f320b6f6d1f2 amend: add -D/--current-date option, just like mq's qrefresh has diff --git a/hgext/evolve.py b/hgext/evolve.py --- a/hgext/evolve.py +++ b/hgext/evolve.py @@ -325,6 +325,15 @@ ### experimental behavior ### ##################################################################### +commitopts3 = [ + ('D', 'current-date', None, + _('record the current date as commit date')), +] + +def _tweakcommitopts(opts): + if not opts.get('date') and opts.get('current_date'): + opts['date'] = '%d %d' % util.makedate() + @eh.wrapfunction(mercurial.obsolete, 'createmarkers') def _createmarkers(orig, repo, relations, *args, **kwargs): """register parent information at prune time""" @@ -1795,7 +1804,7 @@ ('', 'close-branch', None, _('mark a branch as closed, hiding it from the branch list')), ('s', 'secret', None, _('use the secret phase for committing')), - ] + walkopts + commitopts + commitopts2, + ] + walkopts + commitopts + commitopts2 + commitopts3, _('[OPTION]... [FILE]...')) def amend(ui, repo, *pats, **opts): """combine a changeset with updates and replace it with a new one @@ -1820,6 +1829,7 @@ opts['amend'] = True if not (edit or opts['message']): opts['message'] = repo['.'].description() + _tweakcommitopts(opts) _alias, commitcmd = cmdutil.findcmd('commit', commands.table) return commitcmd[0](ui, repo, *pats, **opts) diff --git a/tests/test-amend.t b/tests/test-amend.t --- a/tests/test-amend.t +++ b/tests/test-amend.t @@ -83,3 +83,12 @@ $ hg parents --template '{rev} {date|date}\n' 5 Sat Feb 03 04:05:06 2001 +0700 +Specify "now" as commit date with -D + $ before=`date +%s` + $ hg amend -D + $ commit=`hg parents --template '{date|hgdate} rev{rev}\n'` + $ after=`date +%s` + $ (echo $before ; echo $commit; echo $after) | sort -k1 -n -s + \d+ (re) + \d+ 0 rev6 (re) + \d+ (re)