<div dir="ltr">
        
        
        


Even if level 0 is not validated yet, I am exploring what level 1 might look like. Here are some sketches:<br><br>Start with some basic commands that everybody will use.<br>(add, commit, push, pull, log, import/export, merge, verify)<br>
<br>add command:<br>1) int hg_add(hg_handle *handle, char *argv[], size_t argc);<br>The return values for this function is the exitcode received from cmdserver for this command.<br>You can still have data on cmdserver output channels (error/ output)<br>
    hg add “a wrong file” “a good file” --debug<br>From the error data you will know each of those two files is the corrupt one.<br><br>2) I think that the best solution for all those commands will be to return a structure of the following form:<br>
struct hg_ret{<br>    int exitcode;<div>    char *out_data;<br>    char *err_data;<br>};<br><br>In this way the user will have his data (error/ output) and will have the chance to make what ever he want with it. (parsing, process, ignore) . I know that this thing is not following the read paradigm ( ssize_t read(int fd, void *buf, size_t count);), but I think that could fit well in our case.<br>
<br>– from now on I will adopt this paradigm ( using the return structure), it's just a sketch all the ideas and comments are welcomed –<br><br>Following this paradigm I sketch the rest of the mercurial command. Also I made a small comparison with python-hglib.<br>
<br>commit command<br>  - hg_ret hg_commit(hg_handle *handle, char *argv[], size_t argc);<br>The commit command on python-hglib is returning some parse data ( rev, node)<br><a href="http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l514">http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l514</a><br>
(I think that will be a later discussion about this, parsing data, for now I will just put the data on hg_ret structure)<br><br>pull/push commands:<br>  - hg_ret hg_pull(hg_handle *handle, char *argv[], size_t argc);<br>  - hg_ret hg_push(hg_handle *handle, char *argv[], size_t argc);<br>
For those commands python-hglib return a bool value that indicate the success or the failing/nothing happened.<br><a href="http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l1127">http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l1127</a><br>
<br>log command:<br>  - hg_ret hg_log(hg_handle *handle, char *argv[], size_t argc);<br>On this case the python-hglib return the log data. On our case we can put the out data on out_data field from hg_ret structure.<br><a href="http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l903">http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l903</a><br>
<br>export/import commands:<br>  - hg_ret hg_export(hg_handle *handle, char *argv[], size_t argc);<br>  - hg_ret hg_import(hg_handle *handle, char *argv[], size_t argc);<br><br>For export command the python-hglib will return the output data, if there is no output file where to write it. In our case the data will be put on out_data field from hg_ret if there is no specific file in argv list.<br>
<a href="http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l650">http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l650</a><br><br></div><div>For import command the python-hglib will return nothing, in our case the exitcode will be the only interesting thing.<br>
<a href="http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l811">http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l811</a><br><br><br>merge command:<br>  - hg_ret hg_merge(hg_handle *handle, char *argv[], size_t argc, void (*prompt)(void *));</div>
<div><br>In the signature function will be a prompt function that will handle the prompts.<br>For this function the python-hglib will return nothing, in out case the exitcode will be put on hg_ret structure.<br><a href="http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l980">http://selenic.com/repo/python-hglib/file/661f78f395ea/hglib/client.py#l980</a><br>
<br>verify command:<br>  - hg_ret hg_verify(hg_handle *handle, char *argv[], size_t argc);<br><br>The output data will be set on out_data field and the error data will be set on err_data field.<br><br>**<br>From a first point, this paradigm could look nice, but will give user a lot of freedom. Sometime this thing could be good but I don't know exactly if in our case will be the best choice.<br>
If we adopt this paradigm, the main problem will be to make a strong documentation, for how the argument list must look and what options must contain.<br><br>A good thing for this paradigm is that of maintaining the same signature for almost all functions.<br>
<br>-- <br>Iulian
</div></div>