[PATCH 11 of 55 RFC c-hglib:level1] hg_backout: creating a high level function for mercurial backout command

Iulian Stana julian.stana at gmail.com
Fri Sep 13 19:35:23 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379110776 -10800
#      Sat Sep 14 01:19:36 2013 +0300
# Node ID ecfab8d2d133735e88a809c0077ce19a563a19b6
# Parent  a74f54214315594dc69836005089d45e211e1fc5
hg_backout: creating a high level function for mercurial backout command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -513,6 +513,23 @@
 	return exitcode;
 }
 
+/* The high level backout command for hglib API. */
+int hg_backout(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("backout", 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
@@ -518,6 +518,49 @@
 							char *argument[]);
 
 /**
+ * \brief hg_backout command for hglib API.
+ *
+ * Prepare a new changeset with the effect of rev undone in the current
+ * working directory.
+ *
+ * If rev is the parent of the working directory, then this new changeset is
+ * committed automatically. Otherwise, hg needs to merge the changes and the
+ * merged result is left uncommitted.
+ *
+ * By default, the pending changeset will have one parent, maintaining a linear
+ * history. With --merge, the pending changeset will instead have two parents:
+ * the old parent of the working directory and a new child of REV that simply
+ * undoes REV.
+ *
+ * Options/Argument list option:
+ *
+ *	--merge		merge with old dirstate parent after backout
+ *	--parent		parent to choose when backing out merge 
+ *				(DEPRECATED)
+ *	-r, --rev		revision to backout
+ *	-t, --tool		specify merge tool
+ *	-I, --include	include names matching the given patterns
+ *	-X, --exclude	exclude names matching the given patterns
+ *	-m, --message	use text as commit message
+ *	-l, --logfile	read commit message from file
+ *	-d, --date		record the specified date as commit date
+ *	-u, --user		record the specified user as committer
+ *
+ * \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 backout_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_backout(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