Anton Shestakov <av6@dwimlabs.net>, Sun, 23 Oct 2016 17:53:32 +0800
hglib: make inner loop in runcommand() use a coroutine
Then it's possible to do something nontrivial using the more low-level
client.runcommand_co().
examples/log.lua
Permissions: -rw-r--r--
local cjson_safe = require 'cjson.safe' local hglib = require 'hglib' local client = hglib.Client.open() client:runcommand({'clone', '-U', 'https://bitbucket.org/av6/lua-hglib', '/tmp/testrepo'}) local code, o, e, d = client:runcommand({'log', '-l', '5', '-T', 'json', '-R', '/tmp/testrepo'}) local data = cjson_safe.decode(o) for _, changeset in ipairs(data) do local firstline = changeset.desc:match('^[^\n]*') print(changeset.rev .. '·' .. changeset.node:sub(1, 12) .. ' ' .. firstline) print("Couldn't get log: " .. e)