Patchwork [40,of,55,RFC,c-hglib:level1] hg_recover: creating a high level function for mercurial recover command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <8fcdd165d31f87fe3d67.1379118952@doppler>
Download mbox | patch
Permalink /patch/2484/
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 1379115506 -10800
#      Sat Sep 14 02:38:26 2013 +0300
# Node ID 8fcdd165d31f87fe3d6728d2647f91bf0bda5a4a
# Parent  22d76e515da520e67c8856545da82ce47a1dfb9c
hg_recover: creating a high level function for mercurial recover command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1146,6 +1146,23 @@ 
 	return exitcode;
 }
 
+/* The high level recover command for hglib API. */
+int hg_recover(hg_handle *handle, int(*callback)(const char *msg, size_t len))
+{
+	int exitcode;
+	char *argument[] = {NULL};
+	char **command = cmdbuilder("recover", 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
@@ -1734,7 +1734,25 @@ 
  * */
 int hg_push(hg_handle *handle, int(*callback)(const char *msg, size_t len),
 							char *argument[]);
-							
+
+/**
+ * \brief hg_recover command for hglib API.
+ * 
+ * Recover from an interrupted commit or pull.
+ *
+ * This command tries to fix the repository status after an interrupted
+ * operation. It should only be necessary when Mercurial suggests it.
+ *
+ * \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.
+ * \retval exitcode  To indicate the end of recover_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_recover(hg_handle *handle, int(*callback)(const char *msg, size_t len));
+				
 /**
  * \brief The yield mechanism that will get the next entry.
  *