[PATCH 33 of 55 RFC c-hglib:level1] hg_merge: creating a high level function for mercurial merge command
Iulian Stana
julian.stana at gmail.com
Fri Sep 13 19:35:45 CDT 2013
# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379112973 -10800
# Sat Sep 14 01:56:13 2013 +0300
# Node ID fa2e98dc607122732e6a49b2d34606f303e4a4b6
# Parent 6887a39c19974bcf519c0a49797d61e26e9ffef8
hg_merge: creating a high level function for mercurial merge command
diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -973,6 +973,23 @@
return mbuf;
}
+/* The high level merge command for hglib API. */
+int hg_merge(hg_handle *handle, int (*callback)(const char *msg, size_t len),
+ char *(*prompt)(const char *msg, size_t len), char *argument[])
+{
+ int exitcode;
+ char **command = cmdbuilder("merge", argument, NULL);
+
+ if(hg_rawcommand(handle, command) < 0){
+ return -1;
+ }
+ free(command);
+
+ exitcode = hg_runcommand(handle, callback, (prompt)? prompt:hg_abort);
+
+ return exitcode;
+}
+
/* 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
@@ -1459,6 +1459,41 @@
(const char *msg, size_t len), char *argument[]);
/**
+ * \brief hg_merge command for hglib API.
+ *
+ * The current working directory is updated with all changes made in the
+ * requested revision since the last common predecessor revision.
+ *
+ * Files that changed between either parent are marked as changed for the next
+ * commit and a commit must be performed before any further updates to the
+ * repository are allowed. The next commit will have two parents.
+ *
+ * --tool can be used to specify the merge tool used for file merges. It
+ * overrides the HGMERGE environment variable and your configuration files. See
+ * hg help merge-tools for options.
+ *
+ * Options/Argument list option:
+ *
+ * -f, --force force a merge including outstanding changes (DEPRECATED)
+ * -r, --rev revision to merge
+ * -P, --preview review revisions to merge (no merge is performed)
+ * -t, --tool specify merge tool
+ *
+ * \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 prompt A function that will handle prompts messages.
+ * A NULL pointer will use an abort function.
+ * \param argument The option list. Will contain all option that you wish.
+ * \retval exitcode To indicate the end of merge_command.
+ *
+ * errno can be:
+ * - hg_rawcommand errors
+ * */
+int hg_merge(hg_handle *handle, int (*callback)(const char *msg, size_t len),
+ char *(*prompt)(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