[PATCH 23 of 55 RFC c-hglib:level1] hg_graft: creating a high level function for mercurial graft command

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


# HG changeset patch
# User Iulian Stana <julian.stana at gmail.com>
# Date 1379111996 -10800
#      Sat Sep 14 01:39:56 2013 +0300
# Node ID 80cead1fa1ce3870bffc797bf1b8cefafa1a1fc8
# Parent  83ef0a283b1a285e5bbdf13752d2e9d44ddc0c7a
hg_graft: creating a high level function for mercurial graft command

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -777,6 +777,23 @@
 	return exitcode;
 }
 
+/* The high level graft command for hglib API. */
+int hg_graft(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("graft", argument, NULL);
+
+	if(hg_rawcommand(handle, command) < 0){
+		return -1;
+	}
+	free(command);
+
+	exitcode = hg_runcommand(handle, callback, NULL);
+
+	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
@@ -981,6 +981,42 @@
 							char *argument[]);
 
 /**
+ * \brief hg_graft command for hglib API.
+ *
+ * This command uses Mercurial's merge logic to copy individual changes from
+ * other branches without merging branches in the history graph. This is
+ * sometimes known as 'backporting' or 'cherry-picking'. By default, graft will
+ * copy user, date, and description from the source changesets.
+ *
+ * Changesets that are ancestors of the current revision, that have already been
+ * grafted, or that are merges will be skipped.
+ *
+ * Options/Argument list option:
+ *
+ *	-r, --rev		revisions to graft
+ *	-c, --continue	resume interrupted graft
+ *	-e, --edit		invoke editor on commit messages
+ *	--log		append graft info to log message
+ *	-D, --currentdate	record the current date as commit date
+ *	-U, --currentuser	record the current user as committer
+ *	-d, --date		record the specified date as commit date
+ *	-u, --user		record the specified user as committer
+ *	-t, --tool		specify merge tool
+ *	-n, --dry-run	do not perform actions, just print output
+ *
+ * \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 exitcode  To indicate the end of graft_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_graft(hg_handle *handle, int(*callback)(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