Patchwork [19,of,55,RFC,c-hglib:level1] hg_copy: creating a high level function for mercurial copy command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <a3fa5ba234aeda27121c.1379118931@doppler>
Download mbox | patch
Permalink /patch/2463/
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 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

Patch

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.
  *