[PATCH 16 of 55 RFC c-hglib:level1] hg_bundle: creating a high level function for mercurial bundle command

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


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379111421 -10800
#      Sat Sep 14 01:30:21 2013 +0300
# Node ID e3a0213de50dc628b9e4d8cb610657c37c1dee24
# Parent  2c9552a85a2610d09b92328405e471e73a018a12
hg_bundle: creating a high level function for mercurial bundle command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -633,6 +633,23 @@
 	return bbuf;
 }
 
+/* The high level bundle command for hglib API. */
+int hg_bundle(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("bundle", 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
@@ -720,6 +720,43 @@
  * */
 hg_linestream_buffer *hg_branches(hg_handle *handle, int (*callback)
 			(const char *msg, size_t len), char *argument[]);
+
+/**
+ * \brief hg_bundle command for hglib API.
+ *
+ * Generate a compressed changegroup file collecting changesets not known to be
+ * in another repository.
+ *
+ * If you omit the destination repository, then hg assumes the destination will
+ * have all the nodes you specify with --base parameters. To create a bundle
+ * containing all changesets, use -a/--all (or --base null).
+ *
+ * Options/Argument list option:
+ *
+ *	-f, --force	run even when the destination is unrelated
+ *	-r, --rev		a changeset intended to be added to the 
+ *				destination
+ *	-b, --branch	a specific branch you would like to bundle
+ *	--base		a base changeset assumed to be available at the 
+ *				destination
+ *	-a, --all		bundle all changesets in the repository
+ *	-t, --type		bundle compression type to use (default: bzip2)
+ *	-e, --ssh		specify ssh command to use
+ *	--remotecmd	specify hg command to run on the remote side
+ *	--insecure		do not verify server certificate (ignoring 
+ *				web.cacerts config)
+ *
+ * \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 bundle_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_bundle(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