[PATCH 1 of 2] template: add CBOR output format

Matt Harbison matt_harbison at yahoo.com
Fri Mar 22 23:07:27 EDT 2019


On Sun, 10 Mar 2019 00:56:48 -0500, Yuya Nishihara <yuya at tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1552190244 -32400
> #      Sun Mar 10 12:57:24 2019 +0900
> # Node ID 343027851edc0337e4058feb6f51d67dc584bc0b
> # Parent  9d4ae5044b4c96bdfb2bbb33fa696908b664a1d7
> template: add CBOR output format
>
> The whole output is wrapped as an array just like the other serialization
> formats. It's an indefinite-length array since the size is unknown while
> encoding. Maybe we can add 'cbor-stream' (and 'pickle-stream') as needed.

> +  $ hg log -vpr . -Tcbor --stat | "$PYTHON"  
> "$TESTTMP/decodecborarray.py"
> +  [
> +   {
> +    'bookmarks': [],
> +    'branch': 'default',
> +    'date': [
> +     1577872860,
> +     0
> +    ],
> +    'desc': 'third',
> +    'diff': 'diff -r 29114dbae42b -r 95c24699272e fourth\n---  
> /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/fourth\tWed Jan 01  
> 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+second\ndiff -r 29114dbae42b -r  
> 95c24699272e second\n--- a/second\tMon Jan 12 13:46:40 1970 +0000\n+++  
> /dev/null\tThu Jan 01 00:00:00 1970 +0000\n@@ -1,1 +0,0  
> @@\n-second\ndiff -r 29114dbae42b -r 95c24699272e third\n---  
> /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/third\tWed Jan 01  
> 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+third\n',
> +    'diffstat': ' fourth |  1 +\n second |  1 -\n third  |  1 +\n 3  
> files changed, 2 insertions(+), 1 deletions(-)\n',
> +    'files': [
> +     'fourth',
> +     'second',
> +     'third'
> +    ],
> +    'node': '95c24699272ef57d062b8bccc32c878bf841784a',
> +    'parents': [
> +     '29114dbae42b9f078cf2714dbe3a86bba8ec7453'
> +    ],
> +    'phase': 'draft',
> +    'rev': 8,
> +    'tags': [
> +     'tip'
> +    ],
> +    'user': 'test'
> +   }
> +  ]

Not sure why, but this is failing with an assertion on Windows[1].   
Printing out data just prior to the exception shows:

     \x9f\xadIbookmarks\x80FbranchGdefaultDdate\x82

cborformatter.end() is being called, but it's like the \xff byte isn't  
being output.  Adding a flush there didn't help.

[1]  
https://buildbot.mercurial-scm.org/builders/Win7%20x86_64%20hg%20tests/builds/1334/steps/run-tests.py%20%28python%202.7.13%29/logs/stdio



More information about the Mercurial-devel mailing list