The mercurial commands for C-hglib

Matt Mackall mpm at selenic.com
Thu Jun 27 16:27:16 CDT 2013


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

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list