[PATCH 26 of 55 RFC c-hglib:level1] hg_help: creating a high level function for mercurial help command

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


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379112191 -10800
#      Sat Sep 14 01:43:11 2013 +0300
# Node ID e10357d5501c34d611ab04b8f8990b0fa09a4588
# Parent  5a4400516c39d59eaedd9649728027a05f3bc1a9
hg_help: creating a high level function for mercurial help command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -835,6 +835,26 @@
 	return cbuf;
 }
 
+/* The high level help command for hglib API. */
+hg_linestream_buffer *hg_help(hg_handle *handle, int (*callback)
+			(const char *msg, size_t len), char *argument[])
+{
+	hg_linestream_buffer *hbuf = malloc(sizeof(hg_csetstream_buffer));
+	hbuf->handle = handle;
+
+	hbuf->command = cmdbuilder("help", argument, NULL);
+
+	if(hg_rawcommand(handle, hbuf->command) < 0){
+		return NULL;
+	}
+
+	hbuf->callback = callback;
+	hbuf->buffer = NULL;
+	hbuf->buf_size = 0;
+
+	return hbuf;
+}
+
 /* 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
@@ -1113,7 +1113,40 @@
  * */
 hg_csetstream_buffer *hg_heads(hg_handle *handle, int (*callback)
 			(const char *msg, size_t len), char *argument[]);
-			
+
+/**
+ * \brief hg_help command for hglib API.
+ *
+ * With no arguments, print a list of commands with short help messages.
+ *
+ * Given a topic, extension, or command name, print help for that topic.
+ *
+ * Returns 0 if successful.
+ *
+ * Options/Argument list option:
+ *
+ *	-e, --extension	show only help for extensions
+ *	-c, --command	show only help for commands
+ *	-k, --keyword	show topics matching keyword
+ *
+ *
+ * To get help information use the returned hg_linestream_buffer structure 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_help(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