Patchwork [12,of,55,RFC,c-hglib:level1] hg_bookmark: creating a high level function for mercurial bookmark command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:35 a.m.
Message ID <6036c2b6cf10a8d09e68.1379118924@doppler>
Download mbox | patch
Permalink /patch/2456/
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 1379110846 -10800
#      Sat Sep 14 01:20:46 2013 +0300
# Node ID 6036c2b6cf10a8d09e681b7f6a2f0052ee85384e
# Parent  ecfab8d2d133735e88a809c0077ce19a563a19b6
hg_bookmark: creating a high level function for mercurial bookmark command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -530,6 +530,27 @@ 
 	return exitcode;
 }
 
+/* The high level bookmark command for hglib API. */
+int hg_bookmark(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+
+	if(argument == NULL || argument[0] == NULL)
+		return -1;
+
+	char **command = cmdbuilder("bookmark", 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
@@ -561,6 +561,39 @@ 
 		char *(*prompt)(const char *msg, size_t len), char *argument[]);
 
 /**
+ * \brief hg_bookmark command for hglib API.
+ *
+ * Bookmarks are pointers to certain commits that move when committing.
+ * Bookmarks are local. They can be renamed, copied and deleted. It is possible
+ * to use hg merge NAME to merge from a given bookmark, and hg update NAME to
+ * update to a given bookmark.
+ *
+ * You can use hg bookmark NAME to set a bookmark on the working directory's
+ * parent revision with the given name. If you specify a revision using -r REV
+ * (where REV may be an existing bookmark), the bookmark is assigned to that
+ * revision.
+ *
+ * Options/Argument list option:
+ *
+ *	-f, --force	force
+ *	-r, --rev		revision
+ *	-d, --delete	delete a given bookmark
+ *	-m, --rename	rename a given bookmark
+ *	-i, --inactive	mark a bookmark inactive
+ *
+ * \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 bookmark_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ * */
+int hg_bookmark(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()