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

Iulian Stana julian.stana at gmail.com
Fri Sep 13 19:35:54 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at 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

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.


More information about the Mercurial-devel mailing list