Mercurial > evolve
changeset 976:bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Carefully designed so we can easily add -D to other changeset-creating
commands (probably anything that takes -d), and so that we can add
-U/--current-user as well. When that's done, the date and user options
should be very similar to those in MQ.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Fri, 06 Jun 2014 17:43:45 -0400 |
parents | 09d6036ad596 |
children | cc0f0d94bf30 |
files | README hgext/evolve.py tests/test-amend.t |
diffstat | 3 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/README Thu Jun 05 21:27:28 2014 -0400 +++ b/README Fri Jun 06 17:43:45 2014 -0400 @@ -47,6 +47,10 @@ Changelog ========= +4.1.0 -- + +- amend: add -D/--current-date option + 4.0.0 -- 2014-06-03 - require Mercurial version 3.0.1 or above
--- a/hgext/evolve.py Thu Jun 05 21:27:28 2014 -0400 +++ b/hgext/evolve.py Fri Jun 06 17:43:45 2014 -0400 @@ -325,6 +325,21 @@ ### experimental behavior ### ##################################################################### +commitopts3 = [ + ('D', 'current-date', None, + _('record the current date as commit date')), +] + +def _resolveoptions(opts): + """modify commit options dict to handle related options + + For now, all it does is figure out the commit date: respect -D unless + -d was supplied. + """ + # N.B. this is extremely similar to setupheaderopts() in mq.py + 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 +1810,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 +1835,7 @@ opts['amend'] = True if not (edit or opts['message']): opts['message'] = repo['.'].description() + _resolveoptions(opts) _alias, commitcmd = cmdutil.findcmd('commit', commands.table) return commitcmd[0](ui, repo, *pats, **opts)
--- a/tests/test-amend.t Thu Jun 05 21:27:28 2014 -0400 +++ b/tests/test-amend.t Fri Jun 06 17:43:45 2014 -0400 @@ -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)