Patchwork [29,of,55,RFC,c-hglib:level1] hg_incoming: creating a high level function for mercurial incoming command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <9e2ee0ccc497cc713e0d.1379118941@doppler>
Download mbox | patch
Permalink /patch/2474/
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 1379112487 -10800
#      Sat Sep 14 01:48:07 2013 +0300
# Node ID 9e2ee0ccc497cc713e0d7e3799fa3e7a85adc333
# Parent  a2485c47f38be5505e9fd1ef6cf3fb60eef86a66
hg_incoming: creating a high level function for mercurial incoming command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -891,6 +891,27 @@ 
 	return exitcode;
 }
 
+/* The high level incoming command for hglib API. */
+hg_csetstream_buffer *hg_incoming(hg_handle *handle, int (*callback)
+			(const char *msg, size_t len), char *argument[])
+{
+	hg_csetstream_buffer *cbuf = malloc(sizeof(hg_csetstream_buffer));
+	cbuf->handle = handle;
+
+	cbuf->command = cmdbuilder("incoming", argument, "--template", 
+						CHANGESET, NULL);
+
+	if(hg_rawcommand(handle, cbuf->command) < 0){
+		return NULL;
+	}
+
+	cbuf->callback = callback;
+	cbuf->buffer = NULL;
+	cbuf->buf_size = 0;
+
+	return cbuf;
+}
+
 /* 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
@@ -1262,6 +1262,56 @@ 
 			int buf_size, int data_on_pipe), int func_type);
 
 /**
+ * \brief hg_incoming command for hglib API.
+ * 
+ * Show new changesets found in the specified path/URL or the default pull
+ * location. These are the changesets that would have been pulled if a pull at
+ * the time you issued this command.
+ *
+ * For remote repository, using --bundle avoids downloading the changesets twice
+ * if the incoming is followed by a pull.
+ *
+ * Options/Argument list option:
+ *
+ *	-f, --force	run even if remote repository is unrelated
+ *	-n, --newest-first	show newest record first
+ *	--bundle		file to store the bundles into
+ *	-r, --rev		a remote changeset intended to be added
+ *	-B, --bookmarks	compare bookmarks
+ *	-b, --branch	a specific branch you would like to pull
+ *	-p, --patch	show patch
+ *	-g, --git		use git extended diff format
+ *	-l, --limit	limit number of changes displayed
+ *	-M, --no-merges	do not show merges
+ *	--stat		output diffstat-style summary of changes
+ *	-G, --graph	show the revision DAG
+ *	--style		display using template map file
+ *	--template		display with template
+ *	-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)
+ *	-S, --subrepos	recurse into subrepositories
+ *	aliases: in
+ *
+ * To get incoming information use the returned hg_csetstream_buffer structure 
+ * with hg_fetch_cset_entry() function.
+ *
+ * \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 hg_csetstream_buffer A pointer to hg_csetstream_buffer structure if 
+ *                              successful
+ * \retval NULL to indicate an error, with errno set appropriately.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+hg_csetstream_buffer *hg_incoming(hg_handle *handle, int (*callback)
+			(const char *msg, size_t len), char *argument[]);
+
+/**
  * \brief The yield mechanism that will get the next changeset.
  *
  * The revision history could have a huge mass of data. You cannot pass the