[PATCH 45 of 55 RFC c-hglib:level1] hg_root: creating a high level function for mercurial root command
Iulian Stana
julian.stana at gmail.com
Sat Sep 14 00:35:57 UTC 2013
# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379116087 -10800
# Sat Sep 14 02:48:07 2013 +0300
# Node ID bb03786cfbb1f9fcf1867ddc1f6fef79fab01b18
# Parent 48ab37f7f63c7205339b8aad6fddf9a0e79ef31b
hg_root: creating a high level function for mercurial root command
diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1234,6 +1234,24 @@
return exitcode;
}
+/* The high level root command for hglib API. */
+char *hg_root(hg_handle *handle, int(*callback)(const char *msg, size_t len))
+{
+ int exitcode;
+ char **command = cmdbuilder("root", NULL , NULL);
+
+ if(hg_rawcommand(handle, command) < 0){
+ return NULL;
+ }
+ free(command);
+
+ exitcode = hg_runcommand(handle, callback, NULL);
+ if(exitcode)
+ return NULL;
+
+ return get_output_data(handle);
+}
+
/* 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
@@ -1889,6 +1889,23 @@
char *argument[]);
/**
+ * \brief hg_root command for hglib API.
+ *
+ * Print the root directory of the current repository.
+ *
+ * \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.
+ * \retval repo_root To indicate the end of root_command.
+ * \retval NULL An error appear.
+ *
+ * errno can be:
+ * - hg_rawcommand errors
+ *
+ * */
+char *hg_root(hg_handle *handle, int(*callback)(const char *msg, size_t len));
+
+/**
* \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