Download:
child 31:aef6b4e933b0
parent 29:7e55aab1b3c4
30:c89104014973
Anton Shestakov <av6@dwimlabs.net>, Fri, 16 Sep 2016 07:55:11 +0800
hglib: consume command as one argument to runcommand() (allows other arguments)

4 файлов изменено, 8 вставок(+), 8 удалений(-) [+]
examples/log.lua file | annotate | diff | comparison | revisions
examples/version.lua file | annotate | diff | comparison | revisions
hglib.lua file | annotate | diff | comparison | revisions
spec/hglib_spec.lua file | annotate | diff | comparison | revisions
--- a/examples/log.lua Sun Sep 11 01:08:22 2016 +0800
+++ b/examples/log.lua Fri Sep 16 07:55:11 2016 +0800
@@ -3,8 +3,8 @@
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')
+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'})
client:close()
if code == 0 then
--- a/examples/version.lua Sun Sep 11 01:08:22 2016 +0800
+++ b/examples/version.lua Fri Sep 16 07:55:11 2016 +0800
@@ -2,7 +2,7 @@
local client = hglib.Client.open()
-local code, o, e, d = client:runcommand('version', '--quiet')
+local code, o, e, d = client:runcommand({'version', '--quiet'})
client:close()
if code == 0 then
--- a/hglib.lua Sun Sep 11 01:08:22 2016 +0800
+++ b/hglib.lua Fri Sep 16 07:55:11 2016 +0800
@@ -128,12 +128,12 @@
end
end
-function Client:runcommand(...)
+function Client:runcommand(command)
if not self.capabilities.runcommand then
return nil, '', 'runcommand is not supported by this command server', ''
end
self.wh:write('runcommand\n')
- write_block(self.wh, ...)
+ write_block(self.wh, unpack(command))
self.wh:flush()
local o = ''
local e = ''
--- a/spec/hglib_spec.lua Sun Sep 11 01:08:22 2016 +0800
+++ b/spec/hglib_spec.lua Fri Sep 16 07:55:11 2016 +0800
@@ -52,7 +52,7 @@
it('can use runcommand to request version', function()
local client = hglib.Client.open()
- local code, o, e, d = client:runcommand('version', '--verbose')
+ local code, o, e, d = client:runcommand({'version', '--verbose'})
client:close()
assert.are_equal(0, code)
assert.is_not_nil(o:find('Mercurial Distributed SCM'))
@@ -63,7 +63,7 @@
it('can use runcommand to run nonexistent command', function()
local client = hglib.Client.open()
- local code, o, e, d = client:runcommand('extirpate')
+ local code, o, e, d = client:runcommand({'extirpate'})
client:close()
assert.are_equal(255, code)
assert.is_not_nil(o:find('use "hg help" for the full list of commands'))
@@ -73,7 +73,7 @@
it('can use runcommand to inspect this repo', function()
local client = hglib.Client.open('.')
- local code, o, e, d = client:runcommand('log', '-r0')
+ local code, o, e, d = client:runcommand({'log', '-r0'})
client:close()
assert.are_equal(0, code)
assert.is_not_nil(o:find('hglib: absolute basics'))