Download:
child 25:7af20c4b0579
parent 23:c66dba9e0892
24:9048a48a9926
Anton Shestakov <av6@dwimlabs.net>, Sat, 10 Sep 2016 20:02:58 +0800
examples: add log -Tjson example

1 файлов изменено, 22 вставок(+), 0 удалений(-) [+]
examples/log.lua file | annotate | diff | comparison | revisions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/log.lua Sat Sep 10 20:02:58 2016 +0800
@@ -0,0 +1,22 @@
+local cjson_safe = require('cjson.safe')
+local hglib = require('hglib')
+
+local client = hglib.Client.open()
+
+client:runcommand('clone', 'https://bitbucket.org/av6/lua-hglib', '/tmp/testrepo')
+local code, o, e, d = client:runcommand('log', '-l', '5', '-T', 'json', '-R', '/tmp/testrepo')
+client:close()
+
+if code == 0 then
+ local data = cjson_safe.decode(o)
+ print('Last 5 commits:')
+ for _, changeset in ipairs(data) do
+ local firstline = changeset.desc:match('^[^\n]*')
+ print(changeset.rev .. '·' .. changeset.node:sub(1, 12) .. ' ' .. firstline)
+ end
+else
+ print("Couldn't get log: " .. e)
+end
+if #d > 0 then
+ print('Debug: ')
+end