Patchwork [3,of,3] amend: add -D/--current-date option, just like mq's qrefresh has

login
register
mail settings
Submitter Greg Ward
Date June 6, 2014, 1:40 a.m.
Message ID <20140606014046.GB6312@renesys.com>
Download mbox | patch
Permalink /patch/4943/
State Not Applicable
Headers show

Comments

Greg Ward - June 6, 2014, 1:40 a.m.
On 05 June 2014, I said:
> # HG changeset patch
> # User Greg Ward <greg@gerg.ca>
> # 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

I'd really appreciate it if someone with access to non-Linux Unices
could test this patch series. I'm *pretty* sure my test code is
portable -- I even read the man pages for {Open,Free}BSD! -- but it
couldn't hurt to try it out.

> 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

Specifically, this is the bit I'm concerned about. First, the test
should pass as-is on any Unix. But it should also fail after a very
simple code sabotage:


(And again with "+ 5" instead of "- 5".)

       Greg

Patch

--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -332,7 +332,7 @@ 
 
 def _tweakcommitopts(opts):
     if not opts.get('date') and opts.get('current_date'):
-        opts['date'] = '%d %d' % util.makedate()
+        opts['date'] = '%d %d' % (util.makedate()[0] - 5, 0)
 
 @eh.wrapfunction(mercurial.obsolete, 'createmarkers')
 def _createmarkers(orig, repo, relations, *args, **kwargs):