atom feed3 messages in com.selenic.mercurial-develRe: The mercurial commands for C-hglib
FromSent OnAttachments
Iulian StanaJun 27, 2013 12:43 pm 
Brendan CullyJun 27, 2013 12:47 pm 
Matt MackallJun 27, 2013 2:26 pm 
Subject:Re: The mercurial commands for C-hglib
From:Matt Mackall (mp@selenic.com)
Date:Jun 27, 2013 2:26:53 pm
List:com.selenic.mercurial-devel

On Thu, 2013-06-27 at 22:43 +0300, Iulian Stana wrote:

The mercurial commands for C-hglib:

In the last two days, I've tried to come with a good approach for the signatures of API functions. The biggest problem I found it was on the mercurial commands. The number of options for a specific command can be variable.

Start MUCH simpler. Level _0_, which I previously defined as:

0) raw level - pass a raw command string, get unparsed results http://markmail.org/message/wdwlrwv6lcacwmrs

For instance, something like this:

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);

If you want to get _slightly_ fancier than that, you can add some varargs support like printf. Call this level 0.5:

hg_rawcommand(handle, "hg log -v -r %d:%d", rev, rev);

(Do level 0 first and look up vsprintf before trying to tackle 0.5.)