Download:
child 4:33d49b3bcab5
parent 2:2038aaa338fb
3:48f6ea626b5c
Anton Shestakov <av6@dwimlabs.net>, Thu, 08 Sep 2016 13:05:13 +0800
hglib: sending getencoding command

2 файлов изменено, 22 вставок(+), 0 удалений(-) [+]
hglib.lua file | annotate | diff | comparison | revisions
spec/hglib_spec.lua file | annotate | diff | comparison | revisions
--- a/hglib.lua Thu Sep 08 13:03:21 2016 +0800
+++ b/hglib.lua Thu Sep 08 13:05:13 2016 +0800
@@ -83,6 +83,20 @@
end
end
+function Client:getencoding()
+ if not self.capabilities.getencoding then
+ return nil, 'getencoding is not supported by this command server'
+ end
+ self.wh:write('getencoding\n')
+ self.wh:flush()
+ local channel, message = read_channel(self.rh)
+ if channel == 'r' then
+ return message
+ elseif channel == 'e' then
+ return nil, message
+ end
+end
+
return {
read_u4 = read_u4,
read_c = read_c,
--- a/spec/hglib_spec.lua Thu Sep 08 13:03:21 2016 +0800
+++ b/spec/hglib_spec.lua Thu Sep 08 13:05:13 2016 +0800
@@ -21,4 +21,12 @@
assert.are_equal('number', type(client.lpcpid))
client:close()
end)
+
+ it('can send getencoding command', function()
+ local client = hglib.Client.open()
+ local encoding, err = client:getencoding()
+ client:close()
+ assert.is_nil(err)
+ assert.are_equal('string', type(encoding))
+ end)
end)