[PATCH 2 of 2] keyword: add: SVN-like keywords and config section to select their use

Kevin Grover kevin at kevingrover.net
Wed Feb 3 17:22:47 CST 2010


On Wed, Feb 3, 2010 at 1:57 AM, Christian Ebert <blacktrash at gmx.net> wrote:

> Hi Kevin,
>
> I'm a bit late, but I was (and still am) a bit ill, so ...
>
> I'll come back to your other proposals later, but I think first
> we should decide whether the {date|utcdate} filter is a cheating
> bug, and repair it.
>
>
I'm all for getting things right.  I noticed while checking the svn stuff
that the utc date did not corrospond to the other date.  It just had no
timezone.

2010-02-03 13:02:02 -0800     # A date in PST (8 time hours behind GMT)

Then, if I went to in UTC, I want the time it represents in UTC, not just
the TZ zeroed

So, that the above time PST, the time in GMT is

2010-02-03 21:02:02Z             # The time in Greenwich England

It would be nice if there were a utcdate function in util that took an
normal Hg date (with a TZ) then incorporate the offset into the time, and
return the GMT time (with an empty TZ offset).


> * Kevin Grover on Sunday, January 31, 2010 at 21:50:13 -0600
> > On Sun, Jan 31, 2010 at 9:08 PM, Kevin Grover <kevin at kevingrover.net>
> wrote:
> >> On Sun, Jan 31, 2010 at 6:26 AM, David Soria Parra <sn_ at gmx.net> wrote:
> >>> On 2010-01-30, Kevin Grover <kevin at kevingrover.net> wrote:
> >>>> -An additional date template filter {date|utcdate} is provided. It
> >>>> -returns a date like "2006/09/18 15:13:13".
> >>>> +Additional date template filters are provided:
> >>>> +
> >>>> +Filter                 For  Sample of Return
> >>>> +---------------------  ---
> >>> --------------------------------------------
> >>>> +{date|utcdate}         CVS  "2006/09/18 15:13:13"
> >>>> +{date|utcisodate}      SVN  "2006-09-18 15:13:13Z"
> >>>> +{date|utcisodatelong}  SVN  "2006-09-18 15:13:13 PST (Mon, 18 Sep
> >>>> 2006)"
>
> [...]
>
> >> # provide svn-like dates
> >> utcisodate = lambda d: util.datestr(d, '%Y-%m-%d %H:%M:%SZ')
> >> -utcisodatelong = lambda d: util.datestr(d, '%Y-%m-%d %H:%M:%S %Z (%a,
> %d
> >> %b %Y)')
> >> +utcisodatelong = lambda d: util.datestr(d, '%Y-%m-%d %H:%M:%S %z (%a,
> %d
> >> %b %Y)')
> >>
> >> # make keyword tools accessible
> >>
> >> kwtools = {'templater': None, 'hgcmd': '', 'style': 'cvs', 'inc': [],
> >> 'exc': ['.hg*']}
> >
> > Another problem I noticed (and I think this applies to the CVS Date/time
> > also).  It says it's adjusted to UTC, but it does not appear to be so.
>
> Uh, nasty bug?
>
> > Does anyone know how to adjust the date/time to UTC for output?  I just
> > spent a while looking.  I'll try more later.
>
> Feed util.datestring the 1st element of hg's time tuple only, and
> set the timezone to 0? Like:
>
> # provide cvs-like UTC date filter
> utcdate = lambda x: util.datestr((x[0], 0), '%Y/%m/%d %H:%M:%S')
>
> which should be the equivalent of:
>
> import time
> utcdate = lambda a: time.strftime('%Y/%m/%d %H:%M:%S',
> time.gmtime(float(x[0])))
>
> Testing:
>
> ~$ hg init testdate
> ~$ cd testdate
> ~/testdate$ cat <<EOF > .hg/hgrc
> > [extensions]
> > keyword =
> > [keywordmaps]
> > Utcdate = {date|utcdate}
> > Isodate = {date|isodate}
> > EOF
> ~/testdate$ date; hg kwdemo -q; TZ="PST+8PDT" hg kwdemo -q
> Wed Feb  3 07:43:49 GMT 2010
> [extensions]
> keyword =
> [keyword]
> demo.txt =
> [keywordmaps]
> Isodate = {date|isodate}
> Utcdate = {date|utcdate}
> $Isodate: 2010-02-03 07:43 +0000 $
> $Utcdate: 2010/02/03 07:43:49 $
> [extensions]
> keyword =
> [keyword]
> demo.txt =
> [keywordmaps]
> Isodate = {date|isodate}
> Utcdate = {date|utcdate}
> $Isodate: 2010-02-02 23:43 -0800 $
> $Utcdate: 2010/02/03 07:43:49 $
>
> Current version just omits the timezone:
>
> ~/testdate$ date; hg kwdemo -q; TZ="PST+8PDT" hg kwdemo -q
> Wed Feb  3 07:46:15 GMT 2010
> [extensions]
> keyword =
> [keyword]
> demo.txt =
> [keywordmaps]
> Isodate = {date|isodate}
> Utcdate = {date|utcdate}
> $Isodate: 2010-02-03 07:46 +0000 $
> $Utcdate: 2010/02/03 07:46:15 $
> [extensions]
> keyword =
> [keyword]
> demo.txt =
> [keywordmaps]
> Isodate = {date|isodate}
> Utcdate = {date|utcdate}
> $Isodate: 2010-02-02 23:46 -0800 $
> $Utcdate: 2010/02/02 23:46:15 $
>
>
>
But, like I mentioned above, the above isodate and utcdate represent two
different times

This would be correct output
$Isodate: 2010-02-02 23:46 -0800 $
$Utcdate: 2010-02-03 07:46 $



> I guess I should fix this?
>
> c
> --
> Wer auf sein Elend tritt, steht höher.
> _HÖLDERLIN: H Y P E R I O N_  --->> http://www.blacktrash.org/hyperion/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100203/c18c1dea/attachment.htm>


More information about the Mercurial-devel mailing list