Design document for hg_rawread

Matt outlined the desired beahaviour as

char buf[4096];
hg_handle *handle;

handle = hg_open("some/repo");
hg_rawcommand(handle, "hg log -v");
while(hg_rawread(handle, buf, 4096))
        printf("got: %s", buf); 
printf("exit code is: %d", hg_exitcode(handle)); 
hg_close(handle); 

at http://markmail.org/message/tc6hsvl7fofdjqcl

Experimenting with the problem domain lead to something different, more like

while(hg_rawread(handle, buff, 4096)){
        printf("%s", buff);
}

if(hg_channel(handle) == 'r'){
        exitcode = hg_exitcode(handle);
        printf("exitcode = %d\n", exitcode);
}

Note how the channel type has to be checked before using hg_rawread. Moreover, in other usage case, the usage pattern is like

while(hg_channel(handle) != 'r'){
    if(hg_channel(handle) == 'o'){
        hg_rawread(handle, buff, 4096);
        printf("%s", buff);
    } else if(hg_channel(handle) == 'e'){
        hg_rawread(handle, buff, 4096);
        printf("%s", buff);
    } else if(hg_channel(handle) == 'L'){
        /* ... */
    }
}

remarks

attachments

IRC conversation about this topic here: http://bpaste.net/show/z2YXazAQti2NFrCp8qFl/

C-Hglib/hg_rawreadUsageParadigm (last edited 2013-07-24 09:09:07 by ncewpo01-ext)