From patchwork Sat Sep 14 00:35:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [34, of, 55, RFC, c-hglib:level1] hg_outgoing: creating a high level function for mercurial outgoing command From: Iulian Stana X-Patchwork-Id: 2479 Message-Id: <9dfc32e3848e753f3b13.1379118946@doppler> To: mercurial-devel@selenic.com Date: Sat, 14 Sep 2013 03:35:46 +0300 # HG changeset patch # User Iulian Stana # Date 1379113077 -10800 # Sat Sep 14 01:57:57 2013 +0300 # Node ID 9dfc32e3848e753f3b13d1cb324a251f8afc2ff3 # Parent fa2e98dc607122732e6a49b2d34606f303e4a4b6 hg_outgoing: creating a high level function for mercurial outgoing command diff --git a/client.c b/client.c --- a/client.c +++ b/client.c @@ -990,6 +990,27 @@ return exitcode; } +/* The high level outgoing command for hglib API. */ +hg_csetstream_buffer *hg_outgoing(hg_handle *handle, int (*callback) + (const char *msg, size_t len), char *argument[]) +{ + hg_csetstream_buffer *cbuf = malloc(sizeof(hg_csetstream_buffer)); + cbuf->handle = handle; + + cbuf->command = cmdbuilder("outgoing", argument, "--template", + CHANGESET, NULL); + + if(hg_rawcommand(handle, cbuf->command) < 0){ + return NULL; + } + + cbuf->callback = callback; + cbuf->buffer = NULL; + cbuf->buf_size = 0; + + return cbuf; +} + /* The yield next step. Getting the next entry. */ int hg_fetch_entry(hg_stream_buffer *stream, int (*detect_byte)(char *buff, int buf_size, int data_on_pipe), int func_type) diff --git a/client.h b/client.h --- a/client.h +++ b/client.h @@ -1494,6 +1494,55 @@ char *(*prompt)(const char *msg, size_t len), char *argument[]); /** + * \brief hg_outgoing command for hglib API. + * + * Show changesets not found in the specified destination repository or the + * default push location. These are the changesets that would be pushed if a + * push was requested. + * + * See pull for details of valid destination formats. + * + * Options/Argument list option: + * + * -f, --force run even when the destination is unrelated + * -r, --rev a changeset intended to be included in the + * destination + * -n, --newest-first show newest record first + * -B, --bookmarks compare bookmarks + * -b, --branch a specific branch you would like to push + * -p, --patch show patch + * -g, --git use git extended diff format + * -l, --limit limit number of changes displayed + * -M, --no-merges do not show merges + * --stat output diffstat-style summary of changes + * -G, --graph show the revision DAG + * --style display using template map file + * --template display with template + * -e, --ssh specify ssh command to use + * --remotecmd specify hg command to run on the remote side + * --insecure do not verify server certificate (ignoring + * web.cacerts config) + * -S, --subrepos recurse into subrepositories + * aliases: out + * + * To get outgoing information use the returned hg_csetstream_buffer structure + * with hg_fetch_cset_entry function. + * + * \param handle The handle of the connection, wherewith I want to communicate + * \param callback A function that will handle error data. + * A NULL pointer will ignore error data. + * \param argument The option list. Will contain all option that you wish. + * \retval hg_csetstream_buffer A pointer to hg_csetstream_buffer structure if + * successful + * \retval NULL to indicate an error, with errno set appropriately. + * + * errno can be: + * - hg_rawcommand errors + * */ +hg_csetstream_buffer *hg_outgoing(hg_handle *handle, int (*callback) + (const char *msg, size_t len), char *argument[]); + +/** * \brief The yield mechanism that will get the next entry. * * This function is used inside of hg_fetch_cset_entry() and hg_fetch_line_entry()