This is an archive of the discontinued Mercurial Phabricator instance.

formatter: add support for -Tcbor
Changes PlannedPublic

Authored by indygreg on Apr 13 2018, 2:26 AM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

The implementation in the formatter is hopefully pretty
straightforward.

Unlike other formats, we don't emit a list/array or need to
handle "joining" elements between emitted items. That's because
CBOR doesn't require any joining element: you just read the
next byte to see what type it is then decode it. You do that for
as long as there are bytes to read.

As long as we aren't nesting formatters, the choice to omit
an outer container for data seems acceptable. If nothing else,
it will make it easier for decoders who don't support streaming
to decode data without buffering the entire array first.

I'm a bit unsure about add --cbor support to the f tool by importing
Mercurial modules. It does work in the test environment. But there's
no demand module importer, etc. Unlike the existing JSON and pickle
formatters, there isn't an implementation in the standard library
for us to use. So unless we want to forgo parsing the CBOR (this
doesn't seem great because the data isn't human readable), we'll
need to import at least the CBOR package from mercurial.*.

This commit also doesn't implement -Tcbor for changeset printing.
I'll have to figure that out...

I added tests for -Tcbor for most of the instances of -Tjson in
the test harness.

.. feature::

`--template/-T cbor` can now be specified to emit data as CBOR.

(This feature is experimental and the data format may change.)

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped