Patchwork [42,of,55,RFC,c-hglib:level1] hg_rename: creating a high level function for mercurial rename command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <090280176f15747e6e85.1379118954@doppler>
Download mbox | patch
Permalink /patch/2487/
State Deferred, archived
Headers show

Comments

Iulian Stana - Sept. 14, 2013, 12:35 a.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1379115608 -10800
#      Sat Sep 14 02:40:08 2013 +0300
# Node ID 090280176f15747e6e85587990c689ecbbc92891
# Parent  a27d088e451fcf982bf8baaa2ef8687f72acfbdd
hg_rename: creating a high level function for mercurial rename command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1180,6 +1180,23 @@ 
 	return exitcode;
 }
 
+/* The high level rename command for hglib API. */
+int hg_rename(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("rename", 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
@@ -1779,6 +1779,38 @@ 
  * */
 int hg_remove(hg_handle *handle, int(*callback)(const char *msg, size_t len),
 							char *argument[]);
+
+/**
+ * \brief hg_rename command for hglib API.
+ *
+ * Mark dest as copies of sources; mark sources for deletion. If dest is a
+ * directory, copies are put in that directory. If dest is a file, there can
+ * only be one source.
+ *
+ * By default, this command copies the contents of files as they exist in the
+ * working directory. If invoked with -A/--after, the operation is recorded, but
+ * no copying is performed.
+ *
+ * Options/Argument list option:
+ *
+ *	-A, --after 	record a rename 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
+ *	aliases: move mv
+ *
+ * \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 rename_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_rename(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[]);
 				
 /**
  * \brief The yield mechanism that will get the next entry.