[PATCH 52 of 55 RFC c-hglib:level1] hg_unbundle: creating a high level function for mercurial unbundle command

Iulian Stana julian.stana at gmail.com
Fri Sep 13 19:36:04 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379118349 -10800
#      Sat Sep 14 03:25:49 2013 +0300
# Node ID 164989405186a4fb1a481ea6c57ffbcfc93641ca
# Parent  a2dcea1199e87d6687af9883ee8a00accb65e7bf
hg_unbundle: creating a high level function for mercurial unbundle command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1415,6 +1415,23 @@
 	return tip;
 }
 
+/* The high level unbundle command for hglib API. */
+int hg_unbundle(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("unbundle", 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
@@ -2206,6 +2206,31 @@
 						size_t len), char *argument[]);
 
 /**
+ * \brief hg_unbundle command for hglib API.
+ *
+ * Apply one or more compressed changegroup files generated by the bundle
+ * command.
+ *
+ * Returns 0 on success, 1 if an update has unresolved files.
+ *
+ * Options/Argument list option:
+ *
+ *	-u, --update	update to new branch head if changesets were unbundled
+ *
+ * \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 unbundle_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ *
+ * */
+int hg_unbundle(hg_handle *handle, int(*callback)(const char *msg, 
+						size_t len), char *argument[]);
+
+/**
  * \brief The yield mechanism that will get the next entry.
  *
  * This function is used inside of hg_fetch_cset_entry() and hg_fetch_line_entry()


More information about the Mercurial-devel mailing list