Patchwork [33,of,55,RFC,c-hglib:level1] hg_merge: creating a high level function for mercurial merge command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <fa2e98dc607122732e6a.1379118945@doppler>
Download mbox | patch
Permalink /patch/2476/
State Superseded, archived
Commit 9bfa86746c9c1f6ab51deb8f174ffc482417d09f
Headers show

Comments

Iulian Stana - Sept. 14, 2013, 12:35 a.m.
# HG changeset patch
# User Iulian Stana <julian.stana@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

Patch

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()