Patchwork [49,of,55,RFC,c-hglib:level1] hg_tag: creating a high level function for mercurial tag command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 14, 2013, 12:36 a.m.
Message ID <06c9374f55e90df473cb.1379118961@doppler>
Download mbox | patch
Permalink /patch/2492/
State Deferred, archived
Headers show

Comments

Iulian Stana - Sept. 14, 2013, 12:36 a.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1379116587 -10800
#      Sat Sep 14 02:56:27 2013 +0300
# Node ID 06c9374f55e90df473cbd274027cb8527e125406
# Parent  f364c9f6e36ff1a50bb5ffa13f3a04ee0e42f9d9
hg_tag: creating a high level function for mercurial tag command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -1356,6 +1356,23 @@ 
 	return sum;
 }
 
+/* The high level tag command for hglib API. */
+int hg_tag(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[])
+{
+	int exitcode;
+	char **command = cmdbuilder("tag", 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
@@ -2066,6 +2066,41 @@ 
  **/
 hg_summary_entry *hg_summary(hg_handle *handle, int(*callback)
 			(const char *msg, size_t len), char *argument[]);
+
+/**
+ * \brief hg_tag command for hglib API.
+ *
+ * Name a particular revision using <name>.
+ * 
+ * Tags are used to name particular revisions of the repository and are very
+ * useful to compare different revisions, to go back to significant earlier
+ * versions or to mark branch points as releases, etc. Changing an existing tag
+ * is normally disallowed; use -f/--force to override.
+ *
+ * If no revision is given, the parent of the working directory is used.
+ *
+ * Options/Argument list option:
+ *
+ *	-f, --force	force tag
+ *	-l, --local	make the tag local
+ *	-r, --rev		revision to tag
+ *	--remove		remove a tag
+ *	-e, --edit		edit commit message
+ *	-m, --message	use <text> as commit message
+ *	-d, --date		record the specified date as commit date
+ *	-u, --user		record the specified user as committer
+ *
+ * \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 tag_command.
+ *
+ * errno can be:
+ *      - hg_rawcommand errors
+ **/
+int hg_tag(hg_handle *handle, int(*callback)(const char *msg, size_t len),
+							char *argument[]);
 	
 /**
  * \brief The yield mechanism that will get the next entry.