Patchwork [38,of,55,RFC,c-hglib:level1] hg_pull: creating a high level function for mercurial pull command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <8d3947f315bc60cf63af.1379118950@doppler>
Download mbox | patch
Permalink /patch/2482/
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 1379115394 -10800
#      Sat Sep 14 02:36:34 2013 +0300
# Node ID 8d3947f315bc60cf63af3dab59d49c665ee151b7
# Parent  2ef0b9466449a194a4d71aa61996efdcd5e75b0a
hg_pull: creating a high level function for mercurial pull command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1112,6 +1112,23 @@ 
 	return lbuf;
 }
 
+/* The high level pull command for hglib API. */
+int hg_pull(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("pull", 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
@@ -1670,6 +1670,40 @@ 
 			(const char *msg, size_t len), char *argument[]);
 
 /**
+ * \brief hg_pull command for hglib API.
+ *
+ * Pull changes from a remote repository to a local one.
+ *
+ * This finds all changes from the repository at the specified path or URL and
+ * adds them to a local repository (the current one unless -R is specified). By
+ * default, this does not update the copy of the project in the working
+ * directory.
+ *
+ * Options/Argument list option:
+ *
+ *	-u, --update	update to new branch head if changesets were pulled
+ *	-f, --force	run even when remote repository is unrelated
+ *	-r, --rev		a remote changeset intended to be added
+ *	-B, --bookmark	bookmark to pull
+ *	-b, --branch	a specific branch you would like to pull
+ *	-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_pull(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()