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

Christian Ebert blacktrash at gmx.net
Wed Feb 3 01:57:32 CST 2010


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.

* 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 $


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/


More information about the Mercurial-devel mailing list