Patchwork [44,of,55,RFC,c-hglib:level1] hg_revert creating a high level function for mercurial revert command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <48ab37f7f63c7205339b.1379118956@doppler>
Download mbox | patch
Permalink /patch/2488/
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 1379116026 -10800
#      Sat Sep 14 02:47:06 2013 +0300
# Node ID 48ab37f7f63c7205339b8aad6fddf9a0e79ef31b
# Parent  3667967c03d750d6bac9dd92555eaf79d8029b1d
hg_revert creating a high level function for mercurial revert command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1217,6 +1217,23 @@ 
 	return lbuf;
 }
 
+/* The high level revert command for hglib API. */
+int hg_revert(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("revert", 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
@@ -1852,6 +1852,43 @@ 
 						size_t len), char *argument[]);
 
 /**
+ * \brief hg_revert command for hglib API.
+ * 
+ * With no revision specified, revert the specified files or directories to the
+ * contents they had in the parent of the working directory. This restores the
+ * contents of files to an unmodified state and unschedules adds, removes,
+ * copies, and renames. If the working directory has two parents, you must
+ * explicitly specify a revision.
+ *
+ * Using the -r/--rev or -d/--date options, revert the given files or
+ * directories to their states as of a specific revision. Because revert does
+ * not change the working directory parents, this will cause these files to
+ * appear modified. This can be helpful to "back out" some or all of an earlier
+ * change. See hg backout for a related method.
+ *
+ * Options/Argument list option:
+ *
+ *	-a, --all		revert all changes when no arguments given
+ *	-d, --date		tipmost revision matching date
+ *	-r, --rev		revert to the specified revision
+ *	-C, --no-backup	do not save backup copies of files
+ *	-I, --include	include names matching the given patterns
+ *	-X, --exclude	exclude names matching the given patterns
+ *	-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 rename_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ **/
+int hg_revert(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()