From patchwork Sat Sep 14 00:35:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [06, of, 55, RFC, c-hglib:level1] hg_addremove: creating a high level function for mercurial addremove command From: Iulian Stana X-Patchwork-Id: 2450 Message-Id: <33c4d1b5c5f037e4163f.1379118918@doppler> To: mercurial-devel@selenic.com Date: Sat, 14 Sep 2013 03:35:18 +0300 # HG changeset patch # User Iulian Stana # Date 1379109222 -10800 # Sat Sep 14 00:53:42 2013 +0300 # Node ID 33c4d1b5c5f037e4163f681e7b1ee5141fae1842 # Parent 1d2acde6fdfd8d4c7fecf8c40d8f56e686e9a9bd hg_addremove: creating a high level function for mercurial addremove command diff --git a/client.c b/client.c --- a/client.c +++ b/client.c @@ -384,3 +384,19 @@ return exitcode; } +/* The high level addremove command for hglib API.*/ +int hg_addremove(hg_handle *handle, int(*callback)(const char *msg, size_t len), + char *argument[]) +{ + int exitcode; + char **command = cmdbuilder("addremove", argument, NULL); + + if(hg_rawcommand(handle, command) < 0){ + return -1; + } + free(command); + + exitcode = hg_runcommand(handle, callback, NULL); + + return exitcode; +} diff --git a/client.h b/client.h --- a/client.h +++ b/client.h @@ -232,7 +232,7 @@ * \retval exitcode To indicate the end of runned commend. **/ int hg_runcommand(hg_handle *handle, int (*callback)(const char *msg, size_t len), - char *(*prompt)(const char *msg, size_t len)) + char *(*prompt)(const char *msg, size_t len)); /** * \brief hg_add command for hglib API. @@ -259,5 +259,40 @@ int hg_add(hg_handle *handle, int (*callback)(const char *msg, size_t len), char *argument[]); +/** + * \brief hg_addremove command for hglib API. + * + * Add all new files and remove all missing files from the repository. + * + * New files are ignored if they match any of the patterns in .hgignore. As with + * add, these changes take effect at the next commit. + * + * Use the -s/--similarity option to detect renamed files. This option takes a + * percentage between 0 (disabled) and 100 (files must be identical) as its + * parameter. With a parameter greater than 0, this compares every removed file + * with every added file and records those similar enough as renames. Detecting + * renamed files this way can be expensive. After using this option, hg status + * -C can be used to check which files were identified as moved or renamed. If + * not specified, -s/--similarity defaults to 100 and only renames of identical + * files are detected. + * + * Options/Argument list option: + * + * -s, --similarity guess renamed files by similarity (0<=s<=100) + * -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 addremove_command. + * + * errno can be: + * - hg_rawcommand errors + * */ +int hg_addremove(hg_handle *handle, int(*callback)(const char *msg, size_t len), + char *argument[]); #endif