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

Iulian Stana julian.stana at gmail.com
Fri Sep 13 19:35:24 CDT 2013


# HG changeset patch
# User Iulian Stana <julian.stana at 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

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()


More information about the Mercurial-devel mailing list