Patchwork [39,of,55,RFC,c-hglib:level1] hg_push: creating a high level function for mercurial push command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <22d76e515da520e67c88.1379118951@doppler>
Download mbox | patch
Permalink /patch/2483/
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 1379115454 -10800
#      Sat Sep 14 02:37:34 2013 +0300
# Node ID 22d76e515da520e67c8856545da82ce47a1dfb9c
# Parent  8d3947f315bc60cf63af3dab59d49c665ee151b7
hg_push: creating a high level function for mercurial push command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1129,6 +1129,23 @@ 
 	return exitcode;
 }
 
+/* The high level push command for hglib API. */
+int hg_push(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("push", 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
@@ -1704,6 +1704,38 @@ 
 							char *argument[]);
 
 /**
+ * \brief hg_push command for hglib API.
+ *
+ * Push changesets from this repository to the specified destination.
+ *
+ * This operation is symmetrical to pull: it is identical to a pull in the
+ * destination repository from the current one.
+ *
+ * Options/Argument list option:
+ *
+ *	-f, --force 	force push
+ *	-r, --rev		a changeset intended to be included in the destination
+ *	-B, --bookmark	bookmark to push
+ *	-b, --branch	a specific branch you would like to push
+ *	--new-branch	allow pushing a new branch
+ *	-e, --ssh		specify ssh command to use
+ *	--remotecmd 	specify hg command to run on the remote side
+ *	--insecure		do not verify server certificate (ignoring 
+ *				web.cacerts config)
+ *
+ * \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 pull_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_push(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()