[PATCH 25 of 55 RFC c-hglib:level1] hg_heads: creating a high level function for mercurial heads command
Iulian Stana
julian.stana at gmail.com
Fri Sep 13 19:35:37 CDT 2013
# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379112129 -10800
# Sat Sep 14 01:42:09 2013 +0300
# Node ID 5a4400516c39d59eaedd9649728027a05f3bc1a9
# Parent 72ea63f42ec0e0f871d8c6cd9edb3c093e2df439
hg_heads: creating a high level function for mercurial heads command
diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -814,6 +814,27 @@
return gbuf;
}
+/* The high level heads command for hglib API. */
+hg_csetstream_buffer *hg_heads(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("heads", 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
@@ -1067,6 +1067,54 @@
(const char *msg, size_t len), char *argument[]);
/**
+ * \brief hg_heads command for hglib API.
+ *
+ * With no arguments, show all open branch heads in the repository. Branch heads
+ * are changesets that have no descendants on the same branch. They are where
+ * development generally takes place and are the usual targets for update and
+ * merge operations.
+ *
+ * If one or more REVs are given, only open branch heads on the branches
+ * associated with the specified changesets are shown. This means that you can
+ * use hg heads . to see the heads on the currently checked-out branch.
+ *
+ * If -c/--closed is specified, also show branch heads marked closed (see hg
+ * commit --close-branch).
+ *
+ * If STARTREV is specified, only those heads that are descendants of STARTREV
+ * will be displayed.
+ *
+ * If -t/--topo is specified, named branch mechanics will be ignored and only
+ * topological heads (changesets with no children) will be shown.
+ *
+ * Options/Argument list option:
+ *
+ * -r, --rev show only heads which are descendants of
+ * STARTREV
+ * -t, --topo show topological heads only
+ * -a, --active show active branchheads only (DEPRECATED)
+ * -c, --closed show normal and closed branch heads
+ * --style display using template map file
+ * --template display with template
+ *
+ * To get heads 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_heads(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