From patchwork Sat Sep 14 00:35:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [19, of, 55, RFC, c-hglib:level1] hg_copy: creating a high level function for mercurial copy command From: Iulian Stana X-Patchwork-Id: 2463 Message-Id: To: mercurial-devel@selenic.com Date: Sat, 14 Sep 2013 03:35:31 +0300 # HG changeset patch # User Iulian Stana # Date 1379111736 -10800 # Sat Sep 14 01:35:36 2013 +0300 # Node ID a3fa5ba234aeda27121ccb80a61fa73125b5f423 # Parent 1c5cade9911e847792db151f4adb35fbb9e0daa2 hg_copy: creating a high level function for mercurial copy command diff --git a/client.c b/client.c --- a/client.c +++ b/client.c @@ -703,6 +703,23 @@ return exitcode; } +/* The high level copy command for hglib API. */ +int hg_copy(hg_handle *handle, int(*callback)(const char *msg, size_t len), + char *argument[]) +{ + int exitcode; + char **command = cmdbuilder("copy", argument, NULL); + + if(hg_rawcommand(handle, command) < 0){ + return -1; + } + free(command); + + exitcode = hg_runcommand(handle, callback, NULL); + + return exitcode; +} + /* 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 @@ -835,7 +835,37 @@ * */ int hg_commit(hg_handle *handle, int (*callback)(const char *msg, size_t len), char *argument[]); - + +/** + * \brief hg_copy command for hglib API. + * + * Mark dest as having copies of source files. If dest is a directory, copies + * are put in that directory. If dest is a file, the source must be a single + * file. + * + * This command takes effect with the next commit. To undo a copy before that, + * see hg revert. + * + * Options/Argument list option: + * + * -A, --after record a copy that has already occurred + * -f, --force forcibly copy over an existing managed file + * -I, --include include names matching the given patterns + * -X, --exclude exclude names matching the given patterns + * -n, --dry-run do not perform actions, just print output + * + * \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 exitcode To indicate the end of copy_command. + + * errno can be: + * - hg_rawcommand errors + * */ +int hg_copy(hg_handle *handle, int(*callback)(const char *msg, size_t len), + char *argument[]); + /** * \brief The yield mechanism that will get the next entry. *