Patchwork [43,of,55,RFC,c-hglib:level1] hg_resolve: creating a high level function for mercurial resolve command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <3667967c03d750d6bac9.1379118955@doppler>
Download mbox | patch
Permalink /patch/2486/
State Deferred, archived
Headers show

Comments

Iulian Stana - Sept. 14, 2013, 12:35 a.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1379115889 -10800
#      Sat Sep 14 02:44:49 2013 +0300
# Node ID 3667967c03d750d6bac9dd92555eaf79d8029b1d
# Parent  090280176f15747e6e85587990c689ecbbc92891
hg_resolve: creating a high level function for mercurial resolve command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1197,6 +1197,26 @@ 
 	return exitcode;
 }
 
+/* The high level resolve command for hglib API. */
+hg_linestream_buffer *hg_resolve(hg_handle *handle, int(*callback)
+			(const char *msg, size_t len), char *argument[])
+{
+	hg_linestream_buffer *lbuf = malloc(sizeof(hg_linestream_buffer));
+	lbuf->handle = handle;
+
+	lbuf->command = cmdbuilder("resolve", argument, NULL);
+
+	if(hg_rawcommand(handle, lbuf->command) < 0){
+		return NULL;
+	}
+
+	lbuf->callback = callback;
+	lbuf->buffer = NULL;
+	lbuf->buf_size = 0;
+
+	return lbuf;
+}
+
 /* 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
@@ -1811,7 +1811,46 @@ 
  * */
 int hg_rename(hg_handle *handle, int(*callback)(const char *msg, size_t len),
 							char *argument[]);
-				
+
+/**
+ * \brief hg_resolve command for hglib API.
+ *
+ * Merges with unresolved conflicts are often the result of non-interactive
+ * merging using the internal:merge configuration setting, or a command-line
+ * merge tool like diff3. The resolve command is used to manage the files
+ * involved in a merge, after hg merge has been run, and before hg commit is run
+ * (i.e. the working directory must have two parents). See hg help merge-tools
+ * for information on configuring merge tools.
+ *
+ * Options/Argument list option:
+ * 
+ *	-a, --all		select all unresolved files
+ *	-l, --list		list state of files needing merge
+ *	-m, --mark		mark files as resolved
+ *	-u, --unmark	mark files as unresolved
+ *	-n, --no-status	hide status prefix
+ *	-t, --tool		specify merge tool
+ *	-I, --include	include names matching the given patterns
+ *	-X, --exclude	exclude names matching the given patterns
+ *
+ * To get locate information use the returned hg_linestream_buffer strucutre 
+ * with hg_fetch_line_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_linestream_buffer A pointer to hg_linestream_buffer structure if 
+ *                              successful
+ * \retval NULL to indicate an error, with errno set appropriately.
+ 
+ * errno can be:
+ *      - hg_rawcommand errors
+ *
+ * */
+hg_linestream_buffer *hg_resolve(hg_handle *handle, int(*callback)(const char *msg, 
+						size_t len), char *argument[]);
+
 /**
  * \brief The yield mechanism that will get the next entry.
  *