Patchwork [5,of,5] journal: use fm.formatdate() to pass date tuple in appropriate type (BC)

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 3, 2016, 1:04 p.m.
Message ID <1d44d617da9fc6d52034.1470229468@mimosa>
Download mbox | patch
Permalink /patch/16055/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 3, 2016, 1:04 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1469952708 -32400
#      Sun Jul 31 17:11:48 2016 +0900
# Node ID 1d44d617da9fc6d520341771daaabcb2537bf255
# Parent  2e03c852e430516e4bc881cb0b70a6ec922cf5bf
journal: use fm.formatdate() to pass date tuple in appropriate type (BC)
Pierre-Yves David - Aug. 4, 2016, 1:13 p.m.
On 08/03/2016 03:04 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1469952708 -32400
> #      Sun Jul 31 17:11:48 2016 +0900
> # Node ID 1d44d617da9fc6d520341771daaabcb2537bf255
> # Parent  2e03c852e430516e4bc881cb0b70a6ec922cf5bf
> journal: use fm.formatdate() to pass date tuple in appropriate type (BC)

The code looks fine to me, I've pushed these.

Very happy to see the json output getting this long waited feature.
Martijn Pieters - Aug. 4, 2016, 1:52 p.m.
Thanks for this series, this is excellent!

On 3 August 2016 at 14:04, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1469952708 -32400
> #      Sun Jul 31 17:11:48 2016 +0900
> # Node ID 1d44d617da9fc6d520341771daaabcb2537bf255
> # Parent  2e03c852e430516e4bc881cb0b70a6ec922cf5bf
> journal: use fm.formatdate() to pass date tuple in appropriate type (BC)
>
> diff --git a/hgext/journal.py b/hgext/journal.py
> --- a/hgext/journal.py
> +++ b/hgext/journal.py
> @@ -488,7 +488,7 @@ def journal(ui, repo, *args, **opts):
>              opts.get('all') or name.startswith('re:'),
>              'name', '  %-8s', entry.name)
>
> -        timestring = util.datestr(entry.timestamp, '%Y-%m-%d %H:%M %1%2')
> +        timestring = fm.formatdate(entry.timestamp, '%Y-%m-%d %H:%M %1%2')
>          fm.condwrite(ui.verbose, 'date', ' %s', timestring)
>          fm.write('command', '  %s\n', entry.command)
>
> diff --git a/tests/test-journal.t b/tests/test-journal.t
> --- a/tests/test-journal.t
> +++ b/tests/test-journal.t
> @@ -146,7 +146,7 @@ Test that verbose, JSON, template and co
>    [
>     {
>      "command": "up",
> -    "date": "1970-01-01 00:00 +0000",
> +    "date": [5.0, 0],
>      "name": ".",
>      "newhashes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"],
>      "oldhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
> @@ -154,7 +154,7 @@ Test that verbose, JSON, template and co
>     },
>     {
>      "command": "up 0",
> -    "date": "1970-01-01 00:00 +0000",
> +    "date": [2.0, 0],
>      "name": ".",
>      "newhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
>      "oldhashes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"],
> @@ -162,7 +162,7 @@ Test that verbose, JSON, template and co
>     },
>     {
>      "command": "commit -Aqm b",
> -    "date": "1970-01-01 00:00 +0000",
> +    "date": [1.0, 0],
>      "name": ".",
>      "newhashes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"],
>      "oldhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
> @@ -170,7 +170,7 @@ Test that verbose, JSON, template and co
>     },
>     {
>      "command": "commit -Aqm a",
> -    "date": "1970-01-01 00:00 +0000",
> +    "date": [0.0, 0],
>      "name": ".",
>      "newhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
>      "oldhashes": ["0000000000000000000000000000000000000000"],
> @@ -183,6 +183,7 @@ Test that verbose, JSON, template and co
>    > j = "{oldhashes % '{node|upper}'} -> {newhashes % '{node|upper}'}
>    >      - user: {user}
>    >      - command: {command}
> +  >      - date: {date|rfc3339date}
>    >      - newhashes: {newhashes}
>    >      - oldhashes: {oldhashes}
>    >      "
> @@ -192,6 +193,7 @@ Test that verbose, JSON, template and co
>    CB9A9F314B8B07BA71012FCDBC544B5A4D82FF5B -> 1E6C11564562B4ED919BACA798BC4338BD299D6A
>    - user: foobar
>    - command: up
> +  - date: 1970-01-01T00:00:05+00:00
>    - newhashes: 1e6c11564562b4ed919baca798bc4338bd299d6a
>    - oldhashes: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/journal.py b/hgext/journal.py
--- a/hgext/journal.py
+++ b/hgext/journal.py
@@ -488,7 +488,7 @@  def journal(ui, repo, *args, **opts):
             opts.get('all') or name.startswith('re:'),
             'name', '  %-8s', entry.name)
 
-        timestring = util.datestr(entry.timestamp, '%Y-%m-%d %H:%M %1%2')
+        timestring = fm.formatdate(entry.timestamp, '%Y-%m-%d %H:%M %1%2')
         fm.condwrite(ui.verbose, 'date', ' %s', timestring)
         fm.write('command', '  %s\n', entry.command)
 
diff --git a/tests/test-journal.t b/tests/test-journal.t
--- a/tests/test-journal.t
+++ b/tests/test-journal.t
@@ -146,7 +146,7 @@  Test that verbose, JSON, template and co
   [
    {
     "command": "up",
-    "date": "1970-01-01 00:00 +0000",
+    "date": [5.0, 0],
     "name": ".",
     "newhashes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"],
     "oldhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
@@ -154,7 +154,7 @@  Test that verbose, JSON, template and co
    },
    {
     "command": "up 0",
-    "date": "1970-01-01 00:00 +0000",
+    "date": [2.0, 0],
     "name": ".",
     "newhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
     "oldhashes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"],
@@ -162,7 +162,7 @@  Test that verbose, JSON, template and co
    },
    {
     "command": "commit -Aqm b",
-    "date": "1970-01-01 00:00 +0000",
+    "date": [1.0, 0],
     "name": ".",
     "newhashes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"],
     "oldhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
@@ -170,7 +170,7 @@  Test that verbose, JSON, template and co
    },
    {
     "command": "commit -Aqm a",
-    "date": "1970-01-01 00:00 +0000",
+    "date": [0.0, 0],
     "name": ".",
     "newhashes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
     "oldhashes": ["0000000000000000000000000000000000000000"],
@@ -183,6 +183,7 @@  Test that verbose, JSON, template and co
   > j = "{oldhashes % '{node|upper}'} -> {newhashes % '{node|upper}'}
   >      - user: {user}
   >      - command: {command}
+  >      - date: {date|rfc3339date}
   >      - newhashes: {newhashes}
   >      - oldhashes: {oldhashes}
   >      "
@@ -192,6 +193,7 @@  Test that verbose, JSON, template and co
   CB9A9F314B8B07BA71012FCDBC544B5A4D82FF5B -> 1E6C11564562B4ED919BACA798BC4338BD299D6A
   - user: foobar
   - command: up
+  - date: 1970-01-01T00:00:05+00:00
   - newhashes: 1e6c11564562b4ed919baca798bc4338bd299d6a
   - oldhashes: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b