[PATCH 35 of 55 RFC c-hglib:level1] hg_parents: creating a high level function for mercurial parents command
Iulian Stana
julian.stana at gmail.com
Fri Sep 13 19:35:47 CDT 2013
# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379113419 -10800
# Sat Sep 14 02:03:39 2013 +0300
# Node ID a6f8421b57f2d0c21942612b1b1a4d5bce1ea227
# Parent 9dfc32e3848e753f3b13d1cb324a251f8afc2ff3
hg_parents: creating a high level function for mercurial parents command
diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1011,6 +1011,27 @@
return cbuf;
}
+/* The high level parents command for hglib API. */
+hg_csetstream_buffer *hg_parents(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("parents", 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
@@ -1543,6 +1543,37 @@
(const char *msg, size_t len), char *argument[]);
/**
+ * \brief hg_parents command for hglib API.
+ *
+ * Print the working directory's parent revisions. If a revision is given via
+ * -r/--rev, the parent of that revision will be printed. If a file argument is
+ * given, the revision in which the file was last changed (before the working
+ * directory revision or the argument to --rev if given) is printed.
+ *
+ * Options/Argument list option:
+ *
+ * -r, --rev show parents of the specified revision
+ * --style display using template map file
+ * --template display with template
+ *
+ * To get parents 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 cset The command return succesful, with a parse data.
+ * \retval NULL The command failed.
+ *
+ * errno can be:
+ * - hg_rawcommand errors
+ *
+ * */
+hg_csetstream_buffer *hg_parents(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