[PATCH 46 of 55 RFC c-hglib:level1] hg_showconfig: creating a high level function for mercurial showconfig command

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


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379116179 -10800
#      Sat Sep 14 02:49:39 2013 +0300
# Node ID 83c346aa0bc9688fa96f5083cb6eb5735870c776
# Parent  bb03786cfbb1f9fcf1867ddc1f6fef79fab01b18
hg_showconfig: creating a high level function for mercurial showconfig command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1252,6 +1252,26 @@
 	return get_output_data(handle);
 }
 
+/* The high level help command for hglib API. */
+hg_linestream_buffer *hg_showconfig(hg_handle *handle, int (*callback)
+			(const char *msg, size_t len), char *argument[])
+{
+	hg_linestream_buffer *lbuf = malloc(sizeof(hg_csetstream_buffer));
+	lbuf->handle = handle;
+
+	lbuf->command = cmdbuilder("showconfig", argument, NULL);
+
+	if(hg_rawcommand(handle, lbuf->command) < 0){
+		return NULL;
+	}
+
+	lbuf->callback = callback;
+	lbuf->buffer = NULL;
+	lbuf->buf_size = 0;
+
+	return lbuf;
+}
+
 /* 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
@@ -1906,6 +1906,42 @@
 char *hg_root(hg_handle *handle, int(*callback)(const char *msg, size_t len));
 
 /**
+ * \brief hg_showconfig command for hglib API.
+ *
+ * With no arguments, print names and values of all config items.
+ *
+ * With one argument of the form section.name, print just the value of that
+ * config item.
+ *
+ * With multiple arguments, print names and values of all config items with
+ * matching section names.
+ *
+ * With --debug, the source (filename and line number) is printed for each
+ * config item.
+ *
+ * Options/Argument list option:
+ *
+ *	-u, --untrusted	show untrusted configuration options
+ *	aliases: debugconfigi
+ *
+ * To get showconfig information use the hg_linestream_buffer returned value 
+ * with hg_fetch_line_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_linestream_buffer A pointer to hg_linestream_buffer structure if 
+ *                              successful
+ * \retval NULL to indicate an error, with errno set appropriately.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+hg_linestream_buffer *hg_showconfig(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