New stuff: -T json

Matt Mackall mpm at selenic.com
Mon Sep 15 17:41:13 CDT 2014


We've finally grown some JSON output support, as described in:

http://mercurial.selenic.com/wiki/GenericTemplatingPlan

Currently supported commands are log, parents, heads, incoming,
outgoing, status, manifest, tags, and the new files command:

$ hg log -r . -Tjson
[
 {
  "rev": 24069,
  "node": "eaeee6f95fc07ed22acd3e62db4d241d0ee97b84",
  "branch": "default",
  "phase": "public",
  "user": "Matt Mackall <mpm at selenic.com>",
  "date": [1394994548, 18000],
  "desc": "locate: deprecate in favor of files",
  "bookmarks": ["@", "files-command"],
  "tags": ["tip"],
  "parents": ["968247e8f4ac1ad90ae77ae067cf7db2c0fe4c4e"]
 }
]

$ hg files -v "set:grep('set us up the BOM')" -Tjson
[
 {
  "abspath": "mercurial/config.py",
  "flags": "",
  "path": "mercurial/config.py",
  "size": 5914
 }
]

The non-log-like commands also support a "debug" format with a
Python-compatible syntax, Python's "pickle" format, and will eventually
allow our full template syntax as well.

Adding support to the other commands like branches/bookmarks/annotate is
really easy (hint hint), they just need to start using a formatter:

http://www.selenic.com/hg/file/edf07a804ac4/mercurial/commands.py#l3120

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list